Changeset 8219
- Timestamp:
- 01/28/13 17:08:48 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/devtools/check_config_tables.sh
r7516 r8219 37 37 grep -w $VAR globals.h | grep -vE "(\[|#define)" | grep -w --color $VAR 38 38 done 39 40 echo "== Checking DEF_OPT_HEX (arrays) -> Var type must be uint8_t[x]" 41 for VAR in `cat $FILES | grep DEF_OPT_HEX | grep OFS | awk '{print $3}' | sed "s|OFS(||;s|)||;s|,||"` 42 do 43 grep -w $VAR globals.h | grep -vw uint8_t | grep -w --color $VAR 44 done -
trunk/oscam-conf.c
r8175 r8219 98 98 return 1; 99 99 } 100 case OPT_HEX_ARRAY: { 101 uint8_t *hex_array = var; 102 if (!strlen(value)) 103 memset(hex_array, 0, c->def.array_size); 104 else if (key_atob_l(value, hex_array, c->def.array_size * 2)) { 105 memset(hex_array, 0, c->def.array_size); 106 fprintf(stderr, "WARNING: Config value for '%s' (%s, len=%u) requires %d chars.\n", 107 token, value, strlen(value), c->def.array_size * 2); 108 } 109 return 1; 110 } 100 111 case OPT_FUNC: { 101 112 c->ops.process_fn(token, value, var, NULL); … … 167 178 continue; 168 179 } 180 case OPT_HEX_ARRAY: { 181 uint8_t *hex_array = var; 182 uint32_t ok = check_filled(hex_array, c->def.array_size); 183 if (save_all || ok) { 184 fprintf_conf(f, c->config_name, "%s", ""); // it should not have \n at the end 185 if (ok) { 186 for (ok = 0; ok < c->def.array_size; ok++) { 187 fprintf(f, "%02X", hex_array[ok]); 188 } 189 } 190 fprintf(f, "\n"); 191 } 192 continue; 193 } 169 194 case OPT_FUNC: { 170 195 c->ops.process_fn((const char *)c->config_name, NULL, var, f); … … 237 262 if (c->def.d_char && strlen(c->def.d_char)) 238 263 cs_strncpy(scfg, c->def.d_char, c->str_size); 264 break; 265 } 266 case OPT_HEX_ARRAY: { 267 uint8_t *hex_array = var; 268 memset(hex_array, 0, c->def.array_size); 239 269 break; 240 270 } -
trunk/oscam-conf.h
r8175 r8219 16 16 OPT_STRING, 17 17 OPT_SSTRING, 18 OPT_HEX_ARRAY, 18 19 OPT_FUNC, 19 20 OPT_FUNC_EXTRA, … … 34 35 char *d_char; 35 36 long d_extra; 37 uint32_t array_size; 36 38 } def; 37 39 union { … … 90 92 .str_size = __str_size, \ 91 93 .def.d_char = __default \ 94 } 95 96 #define DEF_OPT_HEX(__name, __var_ofs, __array_size) \ 97 { \ 98 .opt_type = OPT_HEX_ARRAY, \ 99 .config_name = __name, \ 100 .var_offset = __var_ofs, \ 101 .def.array_size = __array_size \ 92 102 } 93 103 -
trunk/oscam-string.c
r7787 r8219 304 304 } 305 305 306 /* Checks an array if it is filled (a value > 0) and returns the last position (1...length) where something was found.306 /* Checks an array if it is filled (a value > 0) and number of filled bytes. 307 307 length specifies the maximum length to check for. */ 308 308 int32_t check_filled(uchar *value, int32_t length) … … 313 313 for (i = 0; i < length; ++i){ 314 314 if (value[i] > 0) 315 j = i + 1;315 j++; 316 316 } 317 317 return j;
Note:
See TracChangeset
for help on using the changeset viewer.