github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/bootstrap/bootstrap_string.h (about) 1 /* 2 * File: bootstrap_string.h 3 * Description: string support for bootstrap 4 * Author: John Manferdelli 5 * Copyright (c) 2013 Intel Corporation 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 19 #ifndef _BOOTSTRAP_STRING_H_ 20 #define _BOOTSTRAP_STRING_H_ 21 22 #include "bootstrap_types.h" 23 #include "e820.h" 24 25 26 extern char* vmm_strncpy(char *dest, const char *src, int n); 27 extern char* vmm_strcpy(char *dest, const char *src); 28 extern char* vmm_strchr (const char * str, int character); 29 extern int vmm_strncmp (const char * str1, const char * str2, int n); 30 extern int vmm_strcmp (const char * str1, const char * str2); 31 // TODO(tmroeder): check in CMake for this macro. 32 #ifdef __x86_64__ 33 extern unsigned long long vmm_strlen(const char* p); 34 extern void* vmm_memset(void *dest, int val, unsigned long long count); 35 extern void* vmm_memcpy(void *dest, const void* src, unsigned long long count); 36 #else 37 extern uint32_t vmm_strlen(const char* p); 38 extern void* vmm_memset(void *dest, int val, uint32_t count); 39 extern void* vmm_memcpy(void *dest, const void* src, uint32_t count); 40 #endif 41 extern uint64_t vmm_strtoul (const char* str, char** endptr, int base); 42 extern void HexDump(uint8_t* start, uint8_t* end); 43 44 45 #define _XA 0x00 /* extra alphabetic - not supported */ 46 #define _XS 0x40 /* extra space */ 47 #define _BB 0x00 /* BEL, BS, etc. - not supported */ 48 #define _CN 0x20 /* CR, FF, HT, NL, VT */ 49 #define _DI 0x04 /* ''-'9' */ 50 #define _LO 0x02 /* 'a'-'z' */ 51 #define _PU 0x10 /* punctuation */ 52 #define _SP 0x08 /* space */ 53 #define _UP 0x01 /* 'A'-'Z' */ 54 #define _XD 0x80 /* ''-'9', 'A'-'F', 'a'-'f' */ 55 56 extern bool isdigit(int c); 57 extern bool isspace(int c); 58 extern bool isxdigit(int c); 59 extern bool isupper(int c); 60 extern bool islower(int c); 61 extern bool isprint(int c); 62 extern bool isalpha(int c); 63 64 65 // command line parsing 66 67 typedef struct { 68 const char *name; // set to NULL for last item in list 69 const char *def_val; 70 } cmdline_option_t; 71 72 #define MAX_VALUE_LEN 64 73 extern const char* get_option_val(const cmdline_option_t *options, 74 char vals[][MAX_VALUE_LEN], const char *opt_name); 75 extern void cmdline_parse(const char *cmdline, const cmdline_option_t *options, 76 char vals[][MAX_VALUE_LEN]); 77 extern const char* skip_filename(const char *cmdline); 78 #endif