* converted to autoconf and began port to Digital UNIX
[citadel.git] / webcit / serv_func.c
1 /* $Id$ */
2
3 #include <ctype.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <stdio.h>
8 #include "webcit.h"
9 #include "child.h"
10
11 struct serv_info serv_info;
12
13 /*
14  * get info about the server we've connected to
15  */
16 void get_serv_info(void) {
17         char buf[256];
18         int a;
19
20         serv_printf("IDEN %d|%d|%d|%s|%s",
21                 DEVELOPER_ID,
22                 CLIENT_ID,
23                 CLIENT_VERSION,
24                 SERVER,
25                 ""              /* FIX find out where the user is */
26                 );
27         serv_gets(buf);
28
29         serv_puts("INFO");
30         serv_gets(buf);
31         if (buf[0]!='1') return;
32
33         a = 0;
34         while(serv_gets(buf), strcmp(buf,"000")) {
35             switch(a) {
36                 case 0:         serv_info.serv_pid = atoi(buf);
37                                 break;
38                 case 1:         strcpy(serv_info.serv_nodename,buf);
39                                 break;
40                 case 2:         strcpy(serv_info.serv_humannode,buf);
41                                 break;
42                 case 3:         strcpy(serv_info.serv_fqdn,buf);
43                                 break;
44                 case 4:         strcpy(serv_info.serv_software,buf);
45                                 break;
46                 case 5:         serv_info.serv_rev_level = atoi(buf);
47                                 break;
48                 case 6:         strcpy(serv_info.serv_bbs_city,buf);
49                                 break;
50                 case 7:         strcpy(serv_info.serv_sysadm,buf);
51                                 break;
52                 case 9:         strcpy(serv_info.serv_moreprompt,buf);
53                                 break;
54                 }
55             ++a;
56             }
57         }
58
59
60
61 /* 
62  * Function to spit out Citadel variformat text in HTML
63  * If fp is non-null, it is considered to be the file handle to read the
64  * text from.  Otherwise, text is read from the server.
65  */
66 void fmout(FILE *fp)
67 {
68
69         int intext = 0;
70         int bq = 0;
71         char buf[256];
72
73         while(1) {
74                 if (fp==NULL) serv_gets(buf);
75                 if (fp!=NULL) {
76                         if (fgets(buf,256,fp)==NULL) strcpy(buf,"000");
77                         buf[strlen(buf)-1] = 0;
78                         }
79                 if (!strcmp(buf,"000")) {
80                         if (bq==1) wprintf("</I>");
81                         wprintf("<P>\n");
82                         return;
83                         }
84                 if ( (intext==1) && (isspace(buf[0])) ) {
85                         wprintf("<BR>");
86                         }
87                 intext = 1;
88
89                 /* Quoted text should be displayed in italics and in a
90                  * different colour.  This code understands both Citadel/UX
91                  * style " >" quotes and FordBoard-style " :-)" quotes.
92                  */
93                 if ((bq==0)&&
94                    ((!strncmp(buf," >",2))||(!strncmp(buf," :-)",4)))) {
95                         wprintf("<FONT COLOR=\"000044\"><I>");
96                         bq = 1;
97                         }
98                 else if ((bq==1)&&
99                      (strncmp(buf," >",2))&&(strncmp(buf," :-)",4))) {
100                         wprintf("</FONT></I>");
101                         bq = 0;
102                         }
103
104                 /* Activate embedded URL's */
105                 url(buf);
106
107                 escputs(buf);
108                 wprintf("\n");
109                 }
110         }
111