7 void attach_to_server(int argc, char **argv);
10 * num_parms() - discover number of parameters...
12 int num_parms(char *source)
17 for (a=0; a<strlen(source); ++a)
18 if (source[a]=='|') ++count;
24 * extract() - extract a parameter from a series of "|" separated...
26 void extract(char *dest, char *source, int parmnum)
32 n = num_parms(source);
39 if ( (parmnum == 0) && (n == 1) ) {
44 while (count++ < parmnum) do {
46 } while( (strlen(buf)>0) && (buf[0]!='|') );
47 if (buf[0]=='|') strcpy(buf,&buf[1]);
48 for (count = 0; count<strlen(buf); ++count)
49 if (buf[count] == '|') buf[count] = 0;
54 * extract_int() - extract an int parm w/o supplying a buffer
56 int extract_int(char *source, int parmnum)
60 extract(buf,source,parmnum);
70 void main(int argc, char **argv)
81 attach_to_server(argc,argv);
83 if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
84 fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
87 strcpy(nodetitle, "this BBS");
92 while (serv_gets(buf), strcmp(buf,"000")) {
93 if (a==0) my_pid = atoi(buf);
94 if (a==2) strcpy(nodetitle, buf);
98 printf(" Users currently logged on to %s\n", nodetitle);
102 fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
106 printf("Session User name Room From host\n");
107 printf("------- ------------------------- -------------------- ------------------------\n");
108 while (serv_gets(buf), strcmp(buf,"000")) {
109 s_pid = extract_int(buf,0);
110 extract(s_user,buf,1);
111 extract(s_room,buf,2);
112 extract(s_host,buf,3);
113 if (s_pid != my_pid) {
114 printf("%-7d%c%-25s %-20s %-24s\n",
116 ((s_pid == my_pid) ? '*' : ' '),
117 s_user,s_room,s_host);
129 * replacement strerror() for systems that don't have it
131 char *strerror(int e)
135 sprintf(buf,"errno = %d",e);