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