Commit fc125a75 authored by Frédéric Leroy's avatar Frédéric Leroy

feat(conf2uedata): add a selector for displaying files

parent 5c0e9d13
...@@ -46,7 +46,7 @@ int main(int argc, char**argv) { ...@@ -46,7 +46,7 @@ int main(int argc, char**argv) {
exit(1); exit(1);
} }
display_data_from_directory(output_dir); display_data_from_directory(output_dir, DISPLAY_ALL);
exit(0); exit(0);
} }
...@@ -55,7 +55,7 @@ int main(int argc, char**argv) { ...@@ -55,7 +55,7 @@ int main(int argc, char**argv) {
* Displays command line usage * Displays command line usage
*/ */
void _display_usage(void) { 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[-c]\tConfig file to use\n");
fprintf(stderr, "\t[-o]\toutput file directory\n"); fprintf(stderr, "\t[-o]\toutput file directory\n");
fprintf(stderr, "\t[-h]\tDisplay this usage\n"); fprintf(stderr, "\t[-h]\tDisplay this usage\n");
......
...@@ -28,29 +28,49 @@ ...@@ -28,29 +28,49 @@
PRINT_PLMN_DIGIT((plmn).MNCdigit2); \ PRINT_PLMN_DIGIT((plmn).MNCdigit2); \
PRINT_PLMN_DIGIT((plmn).MNCdigit3) PRINT_PLMN_DIGIT((plmn).MNCdigit3)
void display_data_from_directory(const char *directory) { // return number of files displayed
int user_id = 0; int display_data_from_directory(const char *directory, int flags) {
char *filename; int user_id = 0;
char *filename;
filename = get_ue_filename(directory, user_id); bool found = true;
while ( file_exist_and_is_readable(filename) ) { int displayed_count = 0;
display_ue_data(filename); while ( found ) {
free(filename); found = false;
filename = get_emm_filename(directory, user_id); if ( flags & DISPLAY_UEDATA ) {
display_emm_data(filename); filename = get_ue_filename(directory, user_id);
free(filename); if ( file_exist_and_is_readable(filename) ) {
display_ue_data(filename);
displayed_count += 1;
found = true;
}
free(filename);
}
filename = get_usim_filename(directory, user_id); if ( flags & DISPLAY_EMM ) {
display_usim_data(filename); filename = get_emm_filename(directory, user_id);
free(filename); 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; user_id += 1;
filename = get_ue_filename(directory, user_id); }
} return displayed_count;
free(filename);
} }
void display_ue_data(const char *filename) { void display_ue_data(const char *filename) {
......
#ifndef _DISPLAY_H #ifndef _DISPLAY_H
#define _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_ue_data(const char *filename);
void display_emm_data(const char *filename); void display_emm_data(const char *filename);
void display_usim_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