00001 /** 00002 * @file op_string.h 00003 * general purpose C string handling declarations. 00004 * 00005 * @remark Copyright 2003 OProfile authors 00006 * @remark Read the file COPYING 00007 * 00008 * @author John Levon 00009 * @author Philippe Elie 00010 */ 00011 00012 #ifndef OP_STRING_H 00013 #define OP_STRING_H 00014 00015 #include <string.h> 00016 00017 #ifdef __cplusplus 00018 extern "C" { 00019 #endif 00020 00021 /** 00022 * @param s: input string 00023 * @param len: len char to copy 00024 * 00025 * Allocate and copy len character from s to a newly allocated buffer then 00026 * append a '\0' terminator. Return the newly allocated string 00027 */ 00028 char * op_xstrndup(char const * s, size_t len); 00029 00030 /** 00031 * @param s: string to hash 00032 * 00033 * Generate a hash code from a string 00034 */ 00035 size_t op_hash_string(char const * s); 00036 00037 /** 00038 * @param str: string to test 00039 * @param prefix: prefix string 00040 * 00041 * return non zero if prefix parameters is a prefix of str 00042 */ 00043 int strisprefix(char const * str, char const * prefix); 00044 00045 /** 00046 * @param c: input string 00047 * 00048 * return a pointer to the first location in c which is not a blank space 00049 * where blank space are in " \t\n" 00050 */ 00051 char const * skip_ws(char const * c); 00052 00053 /** 00054 * @param c: input string 00055 * 00056 * return a pointer to the first location in c which is a blank space 00057 * where blank space are in " \t\n" 00058 */ 00059 char const * skip_nonws(char const * c); 00060 00061 /** 00062 * @param c: input string 00063 * 00064 * return non zero if c string contains only blank space 00065 * where blank space are in " \t\n" 00066 */ 00067 int empty_line(char const * c); 00068 00069 /** 00070 * @param c: input string 00071 * 00072 * return non zero if c string is a comment. Comment are lines with optional 00073 * blank space at left then a '#' character. Blank space are in " \t\n" 00074 */ 00075 int comment_line(char const * c); 00076 00077 #ifdef __cplusplus 00078 } 00079 #endif 00080 00081 #endif /* !OP_STRING_H */
1.6.1