@@ -33,6 +33,10 @@ void evil_portal_read_index_html(void *context) {
33
33
}
34
34
storage_file_close (index_html );
35
35
storage_file_free (index_html );
36
+ } else {
37
+ char * html_error = "Something went wrong with reading the html file.\n"
38
+ "Is the SD Card set up correctly?" ;
39
+ app -> index_html = (uint8_t * )html_error ;
36
40
}
37
41
38
42
evil_portal_close_storage ();
@@ -63,48 +67,46 @@ void evil_portal_read_ap_name(void *context) {
63
67
}
64
68
storage_file_close (ap_name );
65
69
storage_file_free (ap_name );
70
+ } else {
71
+ char * app_default = "Evil Portal" ;
72
+ app -> ap_name = (uint8_t * )app_default ;
66
73
}
67
74
evil_portal_close_storage ();
68
75
}
69
76
70
- char * sequential_file_resolve_path (
71
- Storage * storage ,
72
- const char * dir ,
73
- const char * prefix ,
74
- const char * extension ) {
75
- if (storage == NULL || dir == NULL || prefix == NULL || extension == NULL ) {
76
- return NULL ;
77
- }
77
+ char * sequential_file_resolve_path (Storage * storage , const char * dir ,
78
+ const char * prefix , const char * extension ) {
79
+ if (storage == NULL || dir == NULL || prefix == NULL || extension == NULL ) {
80
+ return NULL ;
81
+ }
78
82
79
- char file_path [256 ];
80
- int file_index = 0 ;
83
+ char file_path [256 ];
84
+ int file_index = 0 ;
81
85
82
- do {
83
- if (snprintf (
84
- file_path , sizeof (file_path ), "%s/%s_%d.%s" , dir , prefix , file_index , extension ) <
85
- 0 ) {
86
- return NULL ;
87
- }
88
- file_index ++ ;
89
- } while (storage_file_exists (storage , file_path ));
86
+ do {
87
+ if (snprintf (file_path , sizeof (file_path ), "%s/%s_%d.%s" , dir , prefix ,
88
+ file_index , extension ) < 0 ) {
89
+ return NULL ;
90
+ }
91
+ file_index ++ ;
92
+ } while (storage_file_exists (storage , file_path ));
90
93
91
- return strdup (file_path );
94
+ return strdup (file_path );
92
95
}
93
96
94
-
95
- void write_logs (char * portal_logs ) {
97
+ void write_logs (char * portal_logs ) {
96
98
Storage * storage = evil_portal_open_storage ();
97
99
98
- char * seq_file_path = sequential_file_resolve_path (storage , EVIL_PORTAL_LOG_SAVE_PATH , "log" , "txt" );
99
-
100
- File * file = storage_file_alloc (storage );
100
+ char * seq_file_path = sequential_file_resolve_path (
101
+ storage , EVIL_PORTAL_LOG_SAVE_PATH , "log" , "txt" );
101
102
102
- if (storage_file_open (file , seq_file_path , FSAM_WRITE ,
103
- FSOM_CREATE_ALWAYS )) {
104
- storage_file_write (file , portal_logs , strlen (portal_logs ));
105
- }
106
- storage_file_close (file );
107
- storage_file_free (file );
103
+ File * file = storage_file_alloc (storage );
104
+
105
+ if (storage_file_open (file , seq_file_path , FSAM_WRITE , FSOM_CREATE_ALWAYS )) {
106
+ storage_file_write (file , portal_logs , strlen (portal_logs ));
107
+ }
108
+ storage_file_close (file );
109
+ storage_file_free (file );
108
110
evil_portal_close_storage ();
109
111
110
112
portal_logs = "" ;
0 commit comments