Commit 747cea24 authored by Frédéric Leroy's avatar Frédéric Leroy

feat(conf2uedata): add a selector for displaying files

parent af402766
......@@ -46,7 +46,7 @@ int main(int argc, char**argv) {
exit(1);
}
display_data_from_directory(output_dir);
display_data_from_directory(output_dir, DISPLAY_ALL);
exit(0);
}
......@@ -55,7 +55,7 @@ int main(int argc, char**argv) {
* Displays command line usage
*/
void _display_usage(void) {
fprintf(stderr, "usage: conf2uedata [OPTION] [directory] ...\n");
fprintf(stderr, "usage: conf2uedata [OPTION]...\n");
fprintf(stderr, "\t[-c]\tConfig file to use\n");
fprintf(stderr, "\t[-o]\toutput file directory\n");
fprintf(stderr, "\t[-h]\tDisplay this usage\n");
......
......@@ -28,29 +28,49 @@
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3)
void display_data_from_directory(const char *directory) {
// return number of files displayed
int display_data_from_directory(const char *directory, int flags) {
int user_id = 0;
char *filename;
bool found = true;
int displayed_count = 0;
filename = get_ue_filename(directory, user_id);
while ( file_exist_and_is_readable(filename) ) {
while ( found ) {
found = false;
if ( flags & DISPLAY_UEDATA ) {
filename = get_ue_filename(directory, user_id);
if ( file_exist_and_is_readable(filename) ) {
display_ue_data(filename);
displayed_count += 1;
found = true;
}
free(filename);
}
if ( flags & DISPLAY_EMM ) {
filename = get_emm_filename(directory, user_id);
if ( file_exist_and_is_readable(filename) ) {
display_emm_data(filename);
displayed_count += 1;
found = true;
}
free(filename);
}
if ( flags & DISPLAY_USIM ) {
filename = get_usim_filename(directory, user_id);
if ( file_exist_and_is_readable(filename) ) {
display_usim_data(filename);
displayed_count += 1;
found = true;
}
free(filename);
}
user_id += 1;
filename = get_ue_filename(directory, user_id);
}
free(filename);
return displayed_count;
}
void display_ue_data(const char *filename) {
......
#ifndef _DISPLAY_H
#define _DISPLAY_H
void display_data_from_directory(const char *directory);
#define DISPLAY_EMM 1
#define DISPLAY_USIM 2
#define DISPLAY_UEDATA 4
#define DISPLAY_ALL 7
// return number of files displayed
int display_data_from_directory(const char *directory, int flags);
void display_ue_data(const char *filename);
void display_emm_data(const char *filename);
void display_usim_data(const char *filename);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment