]> code.citadel.org Git - citadel.git/blob - webcit/webcit.c
* Added "edit room info file"
[citadel.git] / webcit / webcit.c
1 /*
2  * webcit.c
3  *
4  * This is the actual program called by the webserver.  It maintains a
5  * persistent session to the Citadel server, handling HTTP WebCit requests as
6  * they arrive and presenting a user interface.
7  *
8  * $Id$
9  */
10
11 #include <stdlib.h>
12 #ifdef HAVE_UNISTD_H
13 #include <unistd.h>
14 #endif
15 #include <stdio.h>
16 #include <ctype.h>
17 #include <string.h>
18 #include <errno.h>
19 #include <sys/stat.h>
20 #include <stdarg.h>
21 #include "webcit.h"
22 #include "child.h"
23
24 int wc_session;
25 char wc_host[256];
26 char wc_port[256];
27 char wc_username[256];
28 char wc_password[256];
29 char wc_roomname[256];
30 int TransactionCount = 0;
31 int connected = 0;
32 int logged_in = 0;
33 int axlevel;
34 char *ExpressMessages = NULL;
35
36 struct webcontent *wlist = NULL;
37 struct webcontent *wlast = NULL;
38
39 struct urlcontent *urlstrings = NULL;
40
41 static const char *defaulthost = DEFAULT_HOST;
42 static const char *defaultport = DEFAULT_PORT;
43
44
45 void unescape_input(char *buf)
46 {
47         int a,b;
48         char hex[3];
49
50         while ((isspace(buf[strlen(buf)-1]))&&(strlen(buf)>0))
51                 buf[strlen(buf)-1] = 0;
52
53         for (a=0; a<strlen(buf); ++a) {
54                 if (buf[a]=='+') buf[a]=' ';    
55                 if (buf[a]=='%') {
56                         hex[0]=buf[a+1];
57                         hex[1]=buf[a+2];
58                         hex[2]=0;
59                         sscanf(hex,"%02x",&b);
60                         buf[a] = (char) b;
61                         strcpy(&buf[a+1],&buf[a+3]);
62                         }
63                 }
64
65         }
66
67
68 void addurls(char *url) {
69         char *up, *ptr;
70         char buf[256];
71         int a,b;
72         struct urlcontent *u;
73
74         up = url;
75         while (strlen(up)>0) {
76                 
77                 /* locate the = sign */
78                 strncpy(buf,up,255);
79                 b = (-1);
80                 for (a=255; a>=0; --a) if (buf[a]=='=') b=a;
81                 if (b<0) return;
82                 buf[b]=0;
83         
84                 u = (struct urlcontent *)malloc(sizeof(struct urlcontent));
85                 u->next = urlstrings;
86                 urlstrings = u;
87                 strcpy(u->url_key, buf);
88         
89                 /* now chop that part off */
90                 for (a=0; a<=b; ++a) ++up;
91         
92                 /* locate the & sign */
93                 ptr = up;
94                 b = strlen(up);
95                 for (a=0; a<strlen(up); ++a) {
96                         if (!strncmp(ptr,"&",1)) {
97                                 b=a;
98                                 break;
99                                 }
100                         ++ptr;
101                         }
102                 ptr = up;
103                 for (a=0; a<b; ++a) ++ptr;
104                 strcpy(ptr,"");
105                 
106                 u->url_data = malloc(strlen(up)+1);
107                 strcpy(u->url_data, up);
108                 u->url_data[b] = 0;
109                 unescape_input(u->url_data);
110                 up = ptr;
111                 ++up;
112                 }
113         }
114
115 void free_urls(void) {
116         struct urlcontent *u;
117
118         while (urlstrings != NULL) {
119                 free(urlstrings->url_data);
120                 u = urlstrings->next;
121                 free(urlstrings);
122                 urlstrings = u;
123                 }
124         }
125
126 /*
127  * Diagnostic function to display the contents of all variables
128  */
129 void dump_vars(void) {
130         struct urlcontent *u;
131
132         for (u = urlstrings; u != NULL; u = u->next) {
133                 wprintf("%38s = %s\n", u->url_key, u->url_data);
134                 }
135         }
136
137 char *bstr(char *key) {
138         struct urlcontent *u;
139
140         for (u = urlstrings; u != NULL; u = u->next) {
141                 if (!strcasecmp(u->url_key, key)) return(u->url_data);
142                 }
143         return("");
144         }
145
146
147 void wprintf(const char *format, ...) {   
148         va_list arg_ptr;   
149         struct webcontent *wptr;
150
151         wptr = (struct webcontent *)malloc(sizeof(struct webcontent));
152         wptr->next = NULL;
153         if (wlist == NULL) {
154                 wlist = wptr;
155                 wlast = wptr;
156                 }
157         else {
158                 wlast->next = wptr;
159                 wlast = wptr;
160                 }
161   
162         va_start(arg_ptr, format);   
163         vsprintf(wptr->w_data, format, arg_ptr);   
164         va_end(arg_ptr);   
165         }
166
167 int wContentLength(void) {
168         struct webcontent *wptr;
169         int len = 0;
170
171         for (wptr = wlist; wptr != NULL; wptr = wptr->next) {
172                 len = len + strlen(wptr->w_data);
173                 }
174
175         return(len);
176         }
177
178 void wDumpContent(void) {
179         struct webcontent *wptr;
180
181         printf("Content-type: text/html\n");
182         printf("Content-length: %d\n", wContentLength());
183         printf("\n");
184
185         while (wlist != NULL) {
186                 fwrite(wlist->w_data, strlen(wlist->w_data), 1, stdout);
187                 wptr = wlist->next;
188                 free(wlist);
189                 wlist = wptr;
190                 }
191         wlast = NULL;
192         }
193
194
195 void escputs1(char *strbuf, int nbsp)
196 {
197         int a;
198
199         for (a=0; a<strlen(strbuf); ++a) {
200                 if (strbuf[a]=='<') wprintf("&lt;");
201                 else if (strbuf[a]=='>') wprintf("&gt;");
202                 else if (strbuf[a]=='&') wprintf("&amp;");
203                 else if (strbuf[a]==34) wprintf("&quot;");
204                 else if (strbuf[a]==LB) wprintf("<");
205                 else if (strbuf[a]==RB) wprintf(">");
206                 else if (strbuf[a]==QU) wprintf("\"");
207                 else if ((strbuf[a]==32)&&(nbsp==1)) {
208                         wprintf("&nbsp;");
209                         }
210                 else {
211                         wprintf("%c", strbuf[a]);
212                         }
213                 }
214         }
215
216 void escputs(char *strbuf)
217 {
218         escputs1(strbuf,0);
219         }
220
221
222
223 char *urlesc(char *strbuf)
224 {
225         int a,b,c;
226         char *ec = " #&;`'|*?-~<>^()[]{}$\\";
227         static char outbuf[512];
228         
229         strcpy(outbuf,"");
230
231         for (a=0; a<strlen(strbuf); ++a) {
232                 c = 0;
233                 for (b=0; b<strlen(ec); ++b) {
234                         if (strbuf[a]==ec[b]) c=1;
235                         }
236                 b = strlen(outbuf);
237                 if (c==1) sprintf(&outbuf[b],"%%%02x",strbuf[a]);
238                 else sprintf(&outbuf[b],"%c",strbuf[a]);
239                 }
240         return(outbuf);
241         }
242
243 void urlescputs(char *strbuf)
244 {
245         wprintf("%s",urlesc(strbuf));
246         }
247
248
249 void getz(char *buf) {
250         bzero(buf, 256);
251         if (fgets(buf, 256, stdin) == NULL) strcpy(buf, "");
252         else {
253                 while ((strlen(buf)>0)&&(!isprint(buf[strlen(buf)-1])))
254                         buf[strlen(buf)-1] = 0;
255                 }
256         }
257
258 /*
259  * Output all that important stuff that the browser will want to see
260  */
261 void output_headers(int print_standard_html_head) {
262
263         static char *unset = "; expires=28-May-1971 18:10:00 GMT";
264
265         printf("Server: %s\n", SERVER);
266         printf("Connection: close\n");
267         printf("Set-cookie: wc_session=%d\n", wc_session);
268
269         if (strlen(wc_host)>0) printf("Set-cookie: wc_host=%s\n", wc_host);
270         else printf("Set-cookie: wc_host=%s\n", unset);
271
272         if (strlen(wc_port)>0) printf("Set-cookie: wc_port=%s\n", wc_port);
273         else printf("Set-cookie: wc_port=%s\n", unset);
274
275         if (strlen(wc_username)>0) printf("Set-cookie: wc_username=%s\n",
276                 wc_username);
277         else printf("Set-cookie: wc_username=%s\n", unset);
278
279         if (strlen(wc_password)>0) printf("Set-cookie: wc_password=%s\n",
280                 wc_password);
281         else printf("Set-cookie: wc_password=%s\n", unset);
282
283         if (strlen(wc_roomname)>0) printf("Set-cookie: wc_roomname=%s\n",
284                 wc_roomname);
285         else printf("Set-cookie: wc_roomname=%s\n", unset);
286
287         if (print_standard_html_head) {
288                 wprintf("<HTML><HEAD><TITLE>");
289                 escputs("WebCit");       /* FIX -- add BBS name here */
290                 wprintf("</TITLE></HEAD>");
291                 if (ExpressMessages != NULL) {
292                         wprintf("<SCRIPT language=\"javascript\">\n");
293                         wprintf("function ExpressMessage() {\n");
294                         wprintf(" alert(\"");
295                         escputs(ExpressMessages);
296                         wprintf("\")\n");
297                         wprintf(" }\n </SCRIPT>\n");
298                         }
299                 wprintf("<BODY ");
300                 if (ExpressMessages != NULL) {
301                         wprintf("onload=\"ExpressMessage()\" ");
302                         free(ExpressMessages);
303                         ExpressMessages = NULL;
304                         }
305                 wprintf("BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
306                 }
307
308         }
309
310
311
312
313 void check_for_express_messages() {
314         char buf[256];
315
316         serv_puts("PEXP");
317         serv_gets(buf);
318         if (buf[0]=='1') {
319                 while (serv_gets(buf), strcmp(buf, "000")) {
320                         if (ExpressMessages == NULL) {
321                                 ExpressMessages = malloc(strlen(buf) + 4);
322                                 strcpy(ExpressMessages, "");
323                                 }
324                         else {
325                                 ExpressMessages = realloc(ExpressMessages,
326                                  (strlen(ExpressMessages) + strlen(buf) + 4) );
327                                 }
328                         strcat(ExpressMessages, buf);
329                         strcat(ExpressMessages, "\\n");
330                         }
331                 }
332         }
333
334
335
336
337 void output_static(char *what) {
338         char buf[256];
339         FILE *fp;
340         struct stat statbuf;
341         off_t bytes;
342
343         sprintf(buf, "static/%s", what);
344         fp = fopen(buf, "rb");
345         if (fp == NULL) {
346                 printf("HTTP/1.0 404 %s\n", strerror(errno));
347                 output_headers(0);
348                 printf("Content-Type: text/plain\n");
349                 sprintf(buf, "%s: %s\n", what, strerror(errno));
350                 printf("Content-length: %d\n", strlen(buf));
351                 printf("\n");
352                 fwrite(buf, strlen(buf), 1, stdout);
353                 }
354         else {
355                 printf("HTTP/1.0 200 OK\n");
356                 output_headers(0);
357
358                 if (!strncasecmp(&what[strlen(what)-4], ".gif", 4))
359                         printf("Content-type: image/gif\n");
360                 else if (!strncasecmp(&what[strlen(what)-4], ".jpg", 4))
361                         printf("Content-type: image/jpeg\n");
362                 else if (!strncasecmp(&what[strlen(what)-5], ".html", 5))
363                         printf("Content-type: text/html\n");
364                 else
365                         printf("Content-type: application/octet-stream\n");
366
367                 fstat(fileno(fp), &statbuf);
368                 bytes = statbuf.st_size;
369                 printf("Content-length: %ld\n", (long)bytes);
370                 printf("\n");
371                 while (bytes--) {
372                         putc(getc(fp), stdout);
373                         }
374                 fflush(stdout);
375                 fclose(fp);
376                 }
377         }
378
379 void output_image() {
380         char buf[256];
381         char xferbuf[4096];
382         off_t bytes;
383         off_t thisblock;
384         off_t accomplished = 0L;
385
386
387         serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
388         serv_gets(buf);
389         if (buf[0]=='2') {
390                 bytes = extract_long(&buf[4], 0);
391                 printf("HTTP/1.0 200 OK\n");
392                 output_headers(0);
393                 printf("Content-type: image/gif\n");
394                 printf("Content-length: %ld\n", bytes);
395                 printf("\n");
396
397                 while (bytes > (off_t)0) {
398                         thisblock = (off_t)sizeof(xferbuf);
399                         if (thisblock > bytes) thisblock = bytes;
400                         serv_printf("READ %ld|%ld", accomplished, thisblock);
401                         serv_gets(buf);
402                         if (buf[0]=='6') thisblock = extract_long(&buf[4],0);
403                         serv_read(xferbuf, (int)thisblock);
404                         fwrite(xferbuf, thisblock, 1, stdout);
405                         bytes = bytes - thisblock;
406                         accomplished = accomplished + thisblock;
407                         }
408                 fflush(stdout);
409                 serv_puts("CLOS");
410                 serv_gets(buf);
411                 }
412         else {
413                 printf("HTTP/1.0 404 %s\n", strerror(errno));
414                 output_headers(0);
415                 printf("Content-Type: text/plain\n");
416                 sprintf(buf, "Error retrieving image\n");
417                 printf("Content-length: %d\n", strlen(buf));
418                 printf("\n");
419                 fwrite(buf, strlen(buf), 1, stdout);
420                 }
421
422         }
423
424
425 /*
426  * Convenience function to display a page containing only an error string
427  */
428 void display_error(char *errormessage) {
429         printf("HTTP/1.0 200 OK\n");
430         output_headers(1);
431         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
432         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
433         wprintf("<B>Error</B>\n");
434         wprintf("</FONT></TD></TR></TABLE><BR>\n");
435         escputs(errormessage);
436         wprintf("</BODY></HTML>\n");
437         wDumpContent();
438         }
439
440
441
442
443 void extract_action(char *actbuf, char *cmdbuf) {
444         int i;
445
446         strcpy(actbuf, cmdbuf);
447         if (!strncasecmp(actbuf, "GET /", 5)) strcpy(actbuf, &actbuf[5]);
448         if (!strncasecmp(actbuf, "PUT /", 5)) strcpy(actbuf, &actbuf[5]);
449         if (!strncasecmp(actbuf, "POST /", 6)) strcpy(actbuf, &actbuf[6]);
450
451         for (i=0; i<strlen(actbuf); ++i) {
452                 if (actbuf[i]==' ') { actbuf[i]=0; i=0; }
453                 if (actbuf[i]=='/') { actbuf[i]=0; i=0; }
454                 if (actbuf[i]=='?') { actbuf[i]=0; i=0; }
455                 if (actbuf[i]=='&') { actbuf[i]=0; i=0; }
456                 }
457         }
458
459
460 void session_loop(void) {
461         char cmd[256];
462         char action[256];
463         char buf[256];
464         int a, b;
465         int ContentLength = 0;
466         char *content;
467 FILE *fp;
468
469         /* We stuff these with the values coming from the client cookies,
470          * so we can use them to reconnect a timed out session if we have to.
471          */
472         char c_host[256];
473         char c_port[256];
474         char c_username[256];
475         char c_password[256];
476         char c_roomname[256];
477
478         strcpy(c_host, defaulthost);
479         strcpy(c_port, defaultport);
480         strcpy(c_username, "");
481         strcpy(c_password, "");
482         strcpy(c_roomname, "");
483
484         getz(cmd);
485         extract_action(action, cmd);
486
487         do {
488                 getz(buf);
489
490                 if (!strncasecmp(buf, "Cookie: wc_host=", 16))
491                         strcpy(c_host, &buf[16]);
492                 if (!strncasecmp(buf, "Cookie: wc_port=", 16))
493                         strcpy(c_port, &buf[16]);
494                 if (!strncasecmp(buf, "Cookie: wc_username=", 20))
495                         strcpy(c_username, &buf[20]);
496                 if (!strncasecmp(buf, "Cookie: wc_password=", 20))
497                         strcpy(c_password, &buf[20]);
498                 if (!strncasecmp(buf, "Cookie: wc_roomname=", 20))
499                         strcpy(c_roomname, &buf[20]);
500
501                 if (!strncasecmp(buf, "Content-length: ", 16)) {
502                         ContentLength = atoi(&buf[16]);
503                         }
504
505                 } while(strlen(buf)>0);
506
507         ++TransactionCount;
508
509         if (ContentLength > 0) {
510                 content = malloc(ContentLength+1);
511                 fread(content, ContentLength, 1, stdin);
512 fp = fopen("content", "wb");
513 fwrite(content, ContentLength, 1, fp);
514 fclose(fp);
515                 content[ContentLength] = 0;
516                 addurls(content);
517                 }
518         else {
519                 content = NULL;
520                 }
521
522         /*
523          * If we're not connected to a Citadel server, try to hook up the
524          * connection now.  Preference is given to the host and port specified
525          * by browser cookies, if cookies have been supplied.
526          */
527         if (!connected) {
528                 serv_sock = connectsock(c_host, c_port, "tcp");
529                 connected = 1;
530                 serv_gets(buf); /* get the server welcome message */
531                 strcpy(wc_host, c_host);
532                 strcpy(wc_port, c_port);
533                 get_serv_info();
534                 }
535
536         check_for_express_messages();
537
538         /*
539          * If we're not logged in, but we have username and password cookies
540          * supplied by the browser, try using them to log in.
541          */
542         if ((!logged_in)&&(strlen(c_username)>0)&&(strlen(c_password)>0)) {
543                 serv_printf("USER %s", c_username);
544                 serv_gets(buf);
545                 if (buf[0]=='3') {
546                         serv_printf("PASS %s", c_password);
547                         serv_gets(buf);
548                         if (buf[0]=='2') {
549                                 become_logged_in(c_username, c_password, buf);
550                                 }
551                         }
552                 }
553
554         /*
555          * If we don't have a current room, but a cookie specifying the
556          * current room is supplied, make an effort to go there.
557          */
558         if ((strlen(wc_roomname)==0) && (strlen(c_roomname)>0) ) {
559                 serv_printf("GOTO %s", c_roomname);
560                 serv_gets(buf);
561                 if (buf[0]=='2') {
562                         strcpy(wc_roomname, c_roomname);
563                         }
564                 }
565
566         /* If there are variables in the URL, we must grab them now */  
567         for (a=0; a<strlen(cmd); ++a) if ((cmd[a]=='?')||(cmd[a]=='&')) {
568                 for (b=a; b<strlen(cmd); ++b) if (isspace(cmd[b])) cmd[b]=0;
569                 addurls(&cmd[a+1]);
570                 cmd[a] = 0;
571                 }
572
573         if (!strcasecmp(action, "static")) {
574                 strcpy(buf, &cmd[12]);
575                 for (a=0; a<strlen(buf); ++a) if (isspace(buf[a])) buf[a]=0;
576                 output_static(buf);
577                 }
578
579         else if (!strcasecmp(action, "image")) {
580                 output_image();
581                 }
582
583         else if ((!logged_in)&&(!strcasecmp(action, "login"))) {
584                 do_login();
585                 }
586
587         else if (!logged_in) {
588                 display_login(NULL);
589                 }
590
591         /* Various commands... */
592         
593         else if (!strcasecmp(action, "do_welcome")) {
594                 do_welcome();
595                 }
596
597         else if (!strcasecmp(action, "display_main_menu")) {
598                 display_main_menu();
599                 }
600
601         else if (!strcasecmp(action, "advanced")) {
602                 display_advanced_menu();
603                 }
604
605         else if (!strcasecmp(action, "whobbs")) {
606                 whobbs();
607                 }
608
609         else if (!strcasecmp(action, "knrooms")) {
610                 list_all_rooms_by_floor();
611                 }
612
613         else if (!strcasecmp(action, "gotonext")) {
614                 slrp_highest();
615                 gotonext();
616                 }
617
618         else if (!strcasecmp(action, "skip")) {
619                 gotonext();
620                 }
621
622         else if (!strcasecmp(action, "ungoto")) {
623                 ungoto();
624                 }
625
626         else if (!strcasecmp(action, "dotgoto")) {
627                 slrp_highest();
628                 dotgoto();
629                 }
630
631         else if (!strcasecmp(action, "termquit")) {
632                 do_logout();
633                 }
634
635         else if (!strcasecmp(action, "readnew")) {
636                 readloop("readnew");
637                 }
638
639         else if (!strcasecmp(action, "readold")) {
640                 readloop("readold");
641                 }
642
643         else if (!strcasecmp(action, "readfwd")) {
644                 readloop("readfwd");
645                 }
646
647         else if (!strcasecmp(action, "display_enter")) {
648                 display_enter();
649                 }
650
651         else if (!strcasecmp(action, "post")) {
652                 post_message();
653                 }
654
655         else if (!strcasecmp(action, "confirm_delete_msg")) {
656                 confirm_delete_msg();
657                 }
658
659         else if (!strcasecmp(action, "delete_msg")) {
660                 delete_msg();
661                 }
662
663         else if (!strcasecmp(action, "confirm_move_msg")) {
664                 confirm_move_msg();
665                 }
666
667         else if (!strcasecmp(action, "move_msg")) {
668                 move_msg();
669                 }
670
671         else if (!strcasecmp(action, "userlist")) {
672                 userlist();
673                 }
674
675         else if (!strcasecmp(action, "showuser")) {
676                 showuser();
677                 }
678
679         else if (!strcasecmp(action, "display_page")) {
680                 display_page();
681                 }
682
683         else if (!strcasecmp(action, "page_user")) {
684                 page_user();
685                 }
686
687         else if (!strcasecmp(action, "chat")) {
688                 do_chat();
689                 }
690
691         else if (!strcasecmp(action, "display_private")) {
692                 display_private("", 0);
693                 }
694
695         else if (!strcasecmp(action, "goto_private")) {
696                 goto_private();
697                 }
698
699         else if (!strcasecmp(action, "zapped_list")) {
700                 zapped_list();
701                 }
702
703         else if (!strcasecmp(action, "display_zap")) {
704                 display_zap();
705                 }
706
707         else if (!strcasecmp(action, "zap")) {
708                 zap();
709                 }
710
711         else if (!strcasecmp(action, "display_entroom")) {
712                 display_entroom();
713                 }
714
715         else if (!strcasecmp(action, "entroom")) {
716                 entroom();
717                 }
718
719         else if (!strcasecmp(action, "display_editroom")) {
720                 display_editroom();
721                 }
722
723         else if (!strcasecmp(action, "editroom")) {
724                 editroom();
725                 }
726
727         else if (!strcasecmp(action, "display_editinfo")) {
728                 display_edit("Room info", "EINF 0", "RINF", "/editinfo");
729                 }
730
731         else if (!strcasecmp(action, "editinfo")) {
732                 save_edit("Room info", "EINF 1", 1);
733                 }
734
735         else if (!strcasecmp(action, "display_editbio")) {
736                 sprintf(buf, "RBIO %s", wc_username);
737                 display_edit("Your bio", "NOOP", buf, "editbio");
738                 }
739
740         else if (!strcasecmp(action, "editbio")) {
741                 save_edit("Your bio", "EBIO", 0);
742                 }
743
744         /* When all else fails... */
745         else {
746                 printf("HTTP/1.0 200 OK\n");
747                 output_headers(1);
748         
749                 wprintf("TransactionCount is %d<BR>\n", TransactionCount);
750                 wprintf("You're in session %d<HR>\n", wc_session);
751                 wprintf("Command: <BR><PRE>\n");
752                 escputs(cmd);
753                 wprintf("</PRE><HR>\n");
754                 wprintf("Variables: <BR><PRE>\n");
755                 dump_vars();
756                 wprintf("</PRE><HR>\n");
757                 wprintf("</BODY></HTML>\n");
758                 wDumpContent();
759                 }
760
761         fflush(stdout);
762         if (content != NULL) {
763                 free(content);
764                 content = NULL;
765                 }
766         free_urls();
767         }
768
769 int main(int argc, char *argv[]) {
770
771         if (argc < 2 || argc > 4) {
772                 fprintf(stderr,
773                         "webcit: usage: webcit <session_id> [host [port]]\n");
774                 return 1;
775                 }
776
777         wc_session = atoi(argv[1]);
778
779         if (argc > 2) {
780                 defaulthost = argv[2];
781                 if (argc > 3)
782                         defaultport = argv[3];
783                 }
784
785         strcpy(wc_host, "");
786         strcpy(wc_port, "");
787         strcpy(wc_username, "");
788         strcpy(wc_password, "");
789         strcpy(wc_roomname, "");
790
791         while (1) {
792                 session_loop();
793                 }
794         }