10 #endif /* _WIN32 */ |
10 #endif /* _WIN32 */ |
11 settings->suffixc = 1; |
11 settings->suffixc = 1; |
12 settings->recursive = false; |
12 settings->recursive = false; |
13 settings->includeSuffixes = false; |
13 settings->includeSuffixes = false; |
14 settings->matchesOnly = false; |
14 settings->matchesOnly = false; |
|
15 |
|
16 return settings; |
|
17 } |
|
18 |
|
19 void destroy_settings_t(settings_t* settings) { |
|
20 if (settings->suffixv != NULL) { |
|
21 free(settings->suffixv); |
|
22 } |
|
23 free(settings); |
15 } |
24 } |
16 |
25 |
17 void printHelpText(const char* prgName) { |
26 void printHelpText(const char* prgName) { |
18 // Help text |
27 // Help text |
19 const char* helpText = |
28 const char* helpText = |
175 |
184 |
176 // Open directory |
185 // Open directory |
177 DIR *dir = opendir(directory); |
186 DIR *dir = opendir(directory); |
178 if (dir == NULL) { |
187 if (dir == NULL) { |
179 perror("Operation failed"); |
188 perror("Operation failed"); |
180 free(settings->suffixv); |
189 destroy_settings_t(settings); |
181 free(settings); |
|
182 return 1; |
190 return 1; |
183 } |
191 } |
184 |
192 |
185 // Scan directory |
193 // Scan directory |
186 int lines = scanDirectory(dir, 0, directory, settings); |
194 int lines = scanDirectory(dir, 0, directory, settings); |
|
195 closedir(dir); |
187 |
196 |
188 // Print double line and line count |
197 // Print double line and line count |
189 #ifdef _WIN32 |
198 #ifdef _WIN32 |
190 const int columns = 79; |
199 const int columns = 79; |
191 #else |
200 #else |