MCPcopy Create free account
hub / github.com/apache/nuttx / main

Function main

tools/lowhex.c:61–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 ****************************************************************************/
60
61int main(int argc, char **argv)
62{
63 FILE *instream;
64 FILE *outstream;
65 bool delimited;
66 bool inhex;
67 int ret = 1;
68 int i;
69 int j;
70
71 if (argc != 3)
72 {
73 fprintf(stderr, "ERROR: Two arguments expected\n");
74 return 1;
75 }
76
77 /* Open the source file read-only */
78
79 instream = fopen(argv[1], "r");
80 if (instream == NULL)
81 {
82 fprintf(stderr, "ERROR: Failed to open %s for reading\n", argv[1]);
83 return 1;
84 }
85
86 /* Open the destination file write-only */
87
88 outstream = fopen(argv[2], "w");
89 if (outstream == NULL)
90 {
91 fprintf(stderr, "ERROR: Failed to open %s for reading\n", argv[2]);
92 goto errout_with_instream;
93 }
94
95 /* Process each line in the file */
96
97 while ((fgets(g_line, LINESIZE, instream) != NULL))
98 {
99 /* Search for a '0x' that preceding some delimiting character */
100
101 delimited = true;
102 inhex = false;
103
104 for (i = 0;
105 i < LINESIZE && g_line[i] != '\n' && g_line[i] != '\0';
106 i++)
107 {
108 if (inhex)
109 {
110 if (isxdigit(g_line[i]))
111 {
112 g_line[i] = tolower(g_line[i]);
113 }
114 else
115 {
116 inhex = false;
117 }
118 }

Callers

nothing calls this directly

Calls 8

fprintfFunction · 0.85
fopenFunction · 0.85
isdelimiterFunction · 0.85
fputsFunction · 0.85
fcloseFunction · 0.85
fgetsFunction · 0.50
isxdigitFunction · 0.50
tolowerFunction · 0.50

Tested by

no test coverage detected