File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ int main(int argc, const char **argv)
13
13
return 1 ;
14
14
}
15
15
16
- if (argc != 3 ) {
16
+ if (argc < 3 ) {
17
17
nlprint ("vanilla-pipe - brokers a connection between Vanilla and the Wii U" );
18
18
nlprint ("--------------------------------------------------------------------------------" );
19
19
nlprint ("" );
@@ -37,19 +37,31 @@ int main(int argc, const char **argv)
37
37
nlprint ("sockets by a compatible frontend. By choosing '-local' or '-udp', you can" );
38
38
nlprint ("choose what type of socket to use to best suit the environment." );
39
39
nlprint ("" );
40
+ nlprint ("External logging can be enabled with '-log <log-file>'." );
41
+ nlprint ("" );
40
42
41
43
return 1 ;
42
44
}
43
45
44
46
int udp_mode = 0 ;
45
47
int local_mode = 0 ;
46
48
const char * wireless_interface = 0 ;
49
+ const char * log_file = 0 ;
47
50
48
51
for (int i = 1 ; i < argc ; i ++ ) {
49
52
if (!strcmp (argv [i ], "-udp" )) {
50
53
udp_mode = 1 ;
51
54
} else if (!strcmp (argv [i ], "-local" )) {
52
55
local_mode = 1 ;
56
+ } else if (!strcmp (argv [i ], "-log" )) {
57
+ // Increment index
58
+ i ++ ;
59
+ if (i < argc ) {
60
+ log_file = argv [i ];
61
+ } else {
62
+ nlprint ("-log requires an argument" );
63
+ return 1 ;
64
+ }
53
65
} else {
54
66
wireless_interface = argv [i ];
55
67
}
@@ -65,7 +77,7 @@ int main(int argc, const char **argv)
65
77
return 1 ;
66
78
}
67
79
68
- pipe_listen (local_mode , wireless_interface );
80
+ pipe_listen (local_mode , wireless_interface , log_file );
69
81
70
82
return 0 ;
71
83
}
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ struct relay_info {
79
79
80
80
#define THREADRESULT (x ) ((void *) (uintptr_t) (x))
81
81
82
+ static const char * ext_logfile = 0 ;
82
83
void nlprint (const char * fmt , ...)
83
84
{
84
85
va_list args ;
@@ -87,6 +88,15 @@ void nlprint(const char *fmt, ...)
87
88
vfprintf (stderr , fmt , args );
88
89
fprintf (stderr , "\n" );
89
90
91
+ if (ext_logfile ) {
92
+ FILE * f = fopen (ext_logfile , "a" );
93
+ if (f ) {
94
+ vfprintf (f , fmt , args );
95
+ fprintf (f , "\n" );
96
+ fclose (f );
97
+ }
98
+ }
99
+
90
100
va_end (args );
91
101
}
92
102
@@ -944,8 +954,11 @@ void *vanilla_connect_to_console(void *data)
944
954
return wpa_setup_environment (args );
945
955
}
946
956
947
- void pipe_listen (int local , const char * wireless_interface )
957
+ void pipe_listen (int local , const char * wireless_interface , const char * log_file )
948
958
{
959
+ // Store reference to log file
960
+ ext_logfile = log_file ;
961
+
949
962
// Ensure local domain sockets can be written to by everyone
950
963
umask (0000 );
951
964
Original file line number Diff line number Diff line change @@ -17,6 +17,6 @@ int enable_networkmanager_on_device(const char *wireless_interface);
17
17
18
18
void nlprint (const char * fmt , ...);
19
19
20
- void pipe_listen (int local , const char * wireless_interface );
20
+ void pipe_listen (int local , const char * wireless_interface , const char * log_file );
21
21
22
22
#endif // VANILLA_WPA_H
You can’t perform that action at this time.
0 commit comments