MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / main

Function main

src/misc/def_awk.c:5–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <string.h>
4
5int main()
6{
7 char s[1024];
8 while (fgets(s, sizeof(s), stdin))
9 {
10 char* toks[3];
11 int n;
12 char* p = s;
13
14 /* get paranoid */
15 s[sizeof(s) - 1] = 0;
16
17 /* parse string to tokens */
18 toks[2] = NULL;
19 for (n = 0; n < 3; ++n)
20 {
21 toks[n] = strtok(p, " \t\n\r,");
22 p = NULL;
23 if (!toks[n])
24 break;
25 }
26
27 /* skip empty & incomplete */
28 if (! toks[2])
29 continue;
30
31 /* skip unknown statements */
32 char* name = NULL;
33 if (strcmp(toks[0], "#define") == 0) // #define isc_info_end 1
34 name = toks[1];
35 else if (strcmp(toks[1], "=") == 0) // isc_info_db_id = 4
36 name = toks[0];
37 if (! name)
38 continue;
39
40 /* skip unknown constants */
41 for (p = toks[2]; *p; ++p)
42 {
43 if (isdigit(*p))
44 break;
45 }
46 if (!*p)
47 continue;
48
49 /* output correct constant */
50 if (*toks[2] == '-')
51 printf("\t%s = %s;\n", name, toks[2]);
52 else if (strncmp(toks[2], "0x", 2) == 0)
53 printf("\t%s = $%s;\n", name, toks[2] + 2);
54 else
55 printf("\t%s = byte(%s);\n", name, toks[2]);
56 }
57
58 return 0;
59}
60

Callers

nothing calls this directly

Calls 1

fgetsFunction · 0.85

Tested by

no test coverage detected