comparison tools/data2inc.c @ 2408:60e119262c67

Option index re-ordering cleanup work.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 13 Jan 2020 21:21:25 +0200
parents b153bc46241d
children bc05bcfc4598
comparison
equal deleted inserted replaced
2407:c5a32812dd97 2408:60e119262c67
51 optFormatting = TRUE; 51 optFormatting = TRUE;
52 52
53 53
54 static const DMOptArg optList[] = 54 static const DMOptArg optList[] =
55 { 55 {
56 { 0, '?', "help", "Show this help", OPT_NONE }, 56 { 0, '?', "help" , "Show this help", OPT_NONE },
57 { 1, 'n', "name", "Set object name", OPT_ARGREQ }, 57
58 { 2, 't', "type", "Set datatype (unsigned char/byte)", OPT_ARGREQ }, 58 { 10, 'n', "name" , "Set object name", OPT_ARGREQ },
59 { 3, 'f', "format", "Set output format (see list below)", OPT_ARGREQ }, 59 { 12, 't', "type" , "Set datatype (unsigned char/byte)", OPT_ARGREQ },
60 { 4, 'a', "add-line", "Add this line to start of file", OPT_ARGREQ }, 60 { 14, 'f', "format" , "Set output format (see list below)", OPT_ARGREQ },
61 { 5, 'l', "line-items", "Set number of items per line", OPT_ARGREQ }, 61 { 16, 'a', "add-line" , "Add this line to start of file", OPT_ARGREQ },
62 { 6, 'x', "hexadecimal", "Use hexadecimal output", OPT_NONE }, 62 { 18, 'l', "line-items" , "Set number of items per line", OPT_ARGREQ },
63 { 7, 'q', "quiet", "Do not add comments", OPT_NONE }, 63 { 20, 'x', "hexadecimal" , "Use hexadecimal output", OPT_NONE },
64 { 8, 'N', "no-formatting", "Disable additional output formatting", OPT_NONE }, 64 { 22, 'q', "quiet" , "Do not add comments", OPT_NONE },
65 { 9, 'i', "indentation", "Set indentation (negative value = tab)", OPT_ARGREQ }, 65 { 24, 'N', "no-formatting" , "Disable additional output formatting", OPT_NONE },
66 { 10, 'e', "extra-data", "Add object end labels and size in asm output", OPT_NONE }, 66 { 26, 'i', "indentation" , "Set indentation (negative value = tab)", OPT_ARGREQ },
67 { 28, 'e', "extra-data" , "Add object end labels and size in asm output", OPT_NONE },
67 }; 68 };
68 69
69 static const int optListN = sizeof(optList) / sizeof(optList[0]); 70 static const int optListN = sizeof(optList) / sizeof(optList[0]);
70 static const DMOutputFormat dmFormatList[]; 71 static const DMOutputFormat dmFormatList[];
71 static const int ndmFormatList; 72 static const int ndmFormatList;
116 case 0: 117 case 0:
117 argShowHelp(); 118 argShowHelp();
118 exit(0); 119 exit(0);
119 break; 120 break;
120 121
121 case 1: 122 case 10:
122 optObjName = optArg; 123 optObjName = optArg;
123 break; 124 break;
124 125
125 case 2: 126 case 12:
126 optDataType = optArg; 127 optDataType = optArg;
127 break; 128 break;
128 129
129 case 3: 130 case 14:
130 for (int i = 0; i < ndmFormatList; i++) 131 for (int i = 0; i < ndmFormatList; i++)
131 { 132 {
132 const DMOutputFormat *fmt = &dmFormatList[i]; 133 const DMOutputFormat *fmt = &dmFormatList[i];
133 if (strcasecmp(fmt->name, optArg) == 0) 134 if (strcasecmp(fmt->name, optArg) == 0)
134 { 135 {
138 } 139 }
139 dmErrorMsg("Invalid format name '%s'.\n", 140 dmErrorMsg("Invalid format name '%s'.\n",
140 optArg); 141 optArg);
141 return FALSE; 142 return FALSE;
142 143
143 case 4: 144 case 16:
144 optAddLine = optArg; 145 optAddLine = optArg;
145 break; 146 break;
146 147
147 case 5: 148 case 18:
148 optLineLen = atoi(optArg); 149 optLineLen = atoi(optArg);
149 if (optLineLen < 1) 150 if (optLineLen < 1)
150 { 151 {
151 dmErrorMsg("Invalid line length / number of items per line '%s'.\n", 152 dmErrorMsg("Invalid line length / number of items per line '%s'.\n",
152 optArg); 153 optArg);
153 return FALSE; 154 return FALSE;
154 } 155 }
155 break; 156 break;
156 157
157 158 case 20:
158 case 6:
159 optHexMode = TRUE; 159 optHexMode = TRUE;
160 break; 160 break;
161 161
162 case 7: 162 case 22:
163 optQuiet = TRUE; 163 optQuiet = TRUE;
164 break; 164 break;
165 165
166 case 8: 166 case 24:
167 optFormatting = FALSE; 167 optFormatting = FALSE;
168 break; 168 break;
169 169
170 case 9: 170 case 26:
171 optIndentation = atoi(optArg); 171 optIndentation = atoi(optArg);
172 break; 172 break;
173 173
174 case 10: 174 case 28:
175 optExtraData = TRUE; 175 optExtraData = TRUE;
176 break; 176 break;
177 177
178 default: 178 default:
179 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); 179 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg);
421 size_t dataSize; 421 size_t dataSize;
422 off_t totalSize; 422 off_t totalSize;
423 int res; 423 int res;
424 424
425 // Initialize 425 // Initialize
426 dmInitProg("data2inc", "Data to include converter", "0.7", NULL, NULL); 426 dmInitProg("data2inc", "Data to include file converter", "0.7", NULL, NULL);
427 dmVerbosity = 0; 427 dmVerbosity = 0;
428 428
429 // Parse arguments 429 // Parse arguments
430 if (!dmArgsProcess(argc, argv, optList, optListN, 430 if (!dmArgsProcess(argc, argv, optList, optListN,
431 argHandleOpt, argHandleFile, OPTH_BAILOUT)) 431 argHandleOpt, argHandleFile, OPTH_BAILOUT))