@@ -26,6 +26,15 @@ static char * nick = NULL; /* nickname */
26
26
static char * pass = NULL ; /* server password */
27
27
static char * user = NULL ; /* server user name */
28
28
static char * real = NULL ; /* server user real name */
29
+ static char * olog = NULL ; /* log irc stream parh */
30
+
31
+ /* append string to specified file path */
32
+ static void
33
+ append_to_file (char * str ) {
34
+ FILE * out = fopen (olog , "a" );
35
+ fprintf (out , "%s" , str );
36
+ fclose (out );
37
+ }
29
38
30
39
/* wait for keyboard press to interrupt stream */
31
40
static int
@@ -76,6 +85,7 @@ raw(char *cmd_str, char *fmt, ...) {
76
85
va_end (ap );
77
86
78
87
if (verb ) printf ("<< %s" , cmd_str );
88
+ if (olog ) append_to_file (cmd_str );
79
89
80
90
write (conn , cmd_str , strlen (cmd_str ));
81
91
}
@@ -149,6 +159,7 @@ parser(int sl, char *s) {
149
159
o = -1 ;
150
160
151
161
if (verb ) printf (">> %s" , buf_c );
162
+ if (olog ) append_to_file (buf_c );
152
163
153
164
if (!strncmp (buf_c , "PING" , 4 )) {
154
165
buf_c [1 ] = 'O' ;
@@ -182,7 +193,7 @@ main(int argc, char **argv) {
182
193
183
194
int fd [2 ], cval ;
184
195
185
- while ((cval = getopt (argc , argv , "s:p:n:k:c:u:r:w:W:vV" )) != -1 ) {
196
+ while ((cval = getopt (argc , argv , "s:p:o: n:k:c:u:r:w:W:vV" )) != -1 ) {
186
197
switch (cval ) {
187
198
case 'v' : puts ("kirc 0.0.2" ); break ;
188
199
case 'V' : verb = 1 ; break ;
@@ -192,6 +203,7 @@ main(int argc, char **argv) {
192
203
case 'p' : port = optarg ; break ;
193
204
case 'r' : real = optarg ; break ;
194
205
case 'u' : user = optarg ; break ;
206
+ case 'o' : olog = optarg ; break ;
195
207
case 'n' : nick = optarg ; break ;
196
208
case 'k' : pass = optarg ; break ;
197
209
case 'c' : chan = optarg ; break ;
0 commit comments