FreeCalypso > hg > freecalypso-tools
comparison librftab/rftablerd.c @ 281:feb2ee302d25
librftab compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Nov 2017 23:46:27 +0000 |
parents | 36922911e6bb |
children | 64bb50fc470f |
comparison
equal
deleted
inserted
replaced
280:36922911e6bb | 281:feb2ee302d25 |
---|---|
1 /* | 1 /* |
2 * Reading RF tables from formatted ASCII files for the rftw command | 2 * Reading RF tables from formatted ASCII files: used for the rftw command |
3 * in fc-tmsh, for the upload-rf-table command in fc-fsio, and in the | |
4 * standalone fc-cal2bin utility. | |
3 */ | 5 */ |
4 | 6 |
5 #include <sys/types.h> | 7 #include <sys/types.h> |
6 #include <ctype.h> | 8 #include <ctype.h> |
7 #include <stdio.h> | 9 #include <stdio.h> |
8 #include <string.h> | 10 #include <string.h> |
9 #include <strings.h> | 11 #include <strings.h> |
10 #include <stdlib.h> | 12 #include <stdlib.h> |
11 #include "localtypes.h" | 13 #include "../rvinterf/include/exitcodes.h" |
12 #include "l1tm.h" | |
13 #include "exitcodes.h" | |
14 | 14 |
15 #define MAX_FIELDS_PER_LINE 64 | 15 #define MAX_FIELDS_PER_LINE 64 |
16 | 16 |
17 static char *filename; | 17 static char *filename; |
18 static FILE *rdfile; | 18 static FILE *rdfile; |
19 static unsigned lineno; | 19 static unsigned lineno; |
20 static char linebuf[256], *line_fields[MAX_FIELDS_PER_LINE]; | 20 static char linebuf[256], *line_fields[MAX_FIELDS_PER_LINE]; |
21 static unsigned line_nfields, line_field_ptr; | 21 static unsigned line_nfields, line_field_ptr; |
22 static char *format; | 22 static char *format; |
23 static u_char *writeptr; | 23 static u_char *writeptr; |
24 static unsigned written_size; | 24 static unsigned written_size, maxsize; |
25 | 25 |
26 static int | 26 static int |
27 read_line() | 27 read_line() |
28 { | 28 { |
29 char *cp; | 29 char *cp; |
281 if (rc < 0) | 281 if (rc < 0) |
282 return(ERROR_USAGE); | 282 return(ERROR_USAGE); |
283 if (!rc) | 283 if (!rc) |
284 break; | 284 break; |
285 number = strtoul(field, 0, 16); | 285 number = strtoul(field, 0, 16); |
286 if (written_size >= MAX_RF_TABLE_SIZE) { | 286 if (written_size >= maxsize) { |
287 printf("error: raw table %s exceeds maximum size\n", | 287 printf("error: raw table %s exceeds maximum size\n", |
288 filename); | 288 filename); |
289 return(ERROR_USAGE); | 289 return(ERROR_USAGE); |
290 } | 290 } |
291 *writeptr++ = number; | 291 *writeptr++ = number; |
314 {"rx-agc-params", read_rx_agc_params}, | 314 {"rx-agc-params", read_rx_agc_params}, |
315 {"raw", read_raw_table}, | 315 {"raw", read_raw_table}, |
316 {0, 0} | 316 {0, 0} |
317 }; | 317 }; |
318 | 318 |
319 read_rf_table(filename_arg, rdbuf, format_ret, size_ret) | 319 read_rf_table_ext(filename_arg, rdbuf, allow_large, format_ret, size_ret) |
320 char *filename_arg; | 320 char *filename_arg; |
321 u_char *rdbuf; | 321 u_char *rdbuf; |
322 char **format_ret; | 322 char **format_ret; |
323 unsigned *size_ret; | 323 unsigned *size_ret; |
324 { | 324 { |
357 format = tp->kw; | 357 format = tp->kw; |
358 if (format_ret) | 358 if (format_ret) |
359 *format_ret = format; | 359 *format_ret = format; |
360 writeptr = rdbuf; | 360 writeptr = rdbuf; |
361 written_size = 0; | 361 written_size = 0; |
362 if (allow_large) | |
363 maxsize = 512; | |
364 else | |
365 maxsize = 128; | |
362 rc = tp->handler(); | 366 rc = tp->handler(); |
363 fclose(rdfile); | 367 fclose(rdfile); |
364 if (size_ret) | 368 if (size_ret) |
365 *size_ret = written_size; | 369 *size_ret = written_size; |
366 return(rc); | 370 return(rc); |