#include <windows.h>
#include "error_management.h"
#include "script.h"
Go to the source code of this file.
Functions | |
int | script_get_value (char *_str) |
void | script_set_is_separator_fct (_fct_is_separator is_separator) |
char * | templates_get_arg (char *_args, int num) |
char * | templates_get_string (char *_src, char *_dst) |
int | templates_is_space (char c) |
char * | templates_skip_spaces (char *_str) |
Variables | |
_fct_is_separator | script_is_separator = NULL |
int script_get_value | ( | char * | _str | ) |
Definition at line 143 of file DATA_EXTRACT/script.c.
00144 { 00145 int value; 00146 char *_pstr; 00147 00148 ASSERT(_str); 00149 // Skip the first spaces 00150 _str = templates_skip_spaces(_str); 00151 00152 value = 0; 00153 00154 // If the number is an hexadecimal value 00155 if (_str[0] == '0' && _str[1] == 'x') 00156 sscanf(&_str[2], "%X", &value); 00157 // The same 00158 else if (_pstr = strchr(_str, 'h')) 00159 { 00160 *_pstr = '\0'; 00161 sscanf(_str, "%X", &value); 00162 *_pstr = 'h'; 00163 } 00164 // Else it is decimal value 00165 else 00166 sscanf(_str, "%i", &value); 00167 00168 return value; 00169 }
void script_set_is_separator_fct | ( | _fct_is_separator | is_separator | ) |
Definition at line 65 of file DATA_EXTRACT/script.c.
00066 { 00067 // Set the new is_separator function as an extension of the templates_is_space function 00068 script_is_separator = is_separator; 00069 }
char* templates_get_arg | ( | char * | _args, | |
int | num | |||
) |
Definition at line 85 of file DATA_EXTRACT/script.c.
00086 { 00087 char *_new_args; 00088 int i; 00089 00090 ASSERT(_args); 00091 00092 _new_args = _args; 00093 // Skip the first spaces 00094 _new_args = templates_skip_spaces(_new_args); 00095 00096 // This loop permits to point on the "num"th argument 00097 for(i=0; i<num; i++) 00098 { 00099 // Skip the non-spaces 00100 while(!templates_is_space(*_new_args)) 00101 _new_args++; 00102 // skip the spaces 00103 _new_args = templates_skip_spaces(_new_args); 00104 } 00105 00106 // Return a pointer on the argument 00107 return _new_args; 00108 }
char* templates_get_string | ( | char * | _src, | |
char * | _dst | |||
) |
Definition at line 110 of file DATA_EXTRACT/script.c.
Referenced by format_data_get_data().
00111 { 00112 BOOL hold; 00113 00114 ASSERT(_src); 00115 // Skip spaces 00116 _src = templates_skip_spaces(_src); 00117 00118 hold = FALSE; 00119 // While it is not a space or we are inside a quotes and the end of the string is not reached 00120 while((!templates_is_space(*_src) || hold) && *_src) 00121 { 00122 // Test the character 00123 switch(*_src) 00124 { 00125 // If it is a " character 00126 case '\"': 00127 // hold the string 00128 hold = !hold; 00129 break; 00130 // Else copy the string 00131 default: 00132 *_dst++ = *_src; 00133 } 00134 *_src++; 00135 } 00136 *_dst = '\0'; 00137 // Skip spaces 00138 _src = templates_skip_spaces(_src); 00139 00140 return _src; 00141 }
int templates_is_space | ( | char | c | ) |
Definition at line 38 of file DATA_EXTRACT/script.c.
Referenced by templates_get_arg(), templates_get_string(), and templates_skip_spaces().
00039 { 00040 int result; 00041 00042 switch(c) 00043 { 00044 // If the character is a basic space 00045 case ' ': 00046 case '\t': 00047 case '\n': 00048 case '\r': 00049 // Return 1 00050 result = 1; 00051 break; 00052 // Else 00053 default: 00054 // If the extension function is set returns its result 00055 if (script_is_separator) 00056 result = script_is_separator(c); 00057 // Else returns 0 00058 else 00059 result = 0; 00060 } 00061 00062 return result; 00063 }
char* templates_skip_spaces | ( | char * | _str | ) |
Definition at line 71 of file DATA_EXTRACT/script.c.
Referenced by script_get_value(), templates_get_arg(), and templates_get_string().
00072 { 00073 char *_pstr; 00074 00075 ASSERT(_str); 00076 00077 _pstr = _str; 00078 // Skip spaces 00079 while(templates_is_space(*_pstr)) 00080 _pstr++; 00081 00082 return _pstr; 00083 }
Definition at line 36 of file DATA_EXTRACT/script.c.
Referenced by script_set_is_separator_fct(), and templates_is_space().