9 * num_parms() - discover number of parameters...
11 int num_parms(char *source)
16 for (a=0; a<strlen(source); ++a)
17 if (source[a]=='|') ++count;
23 * extract() - extract a parameter from a series of "|" separated...
25 void extract(char *dest, char *source, int parmnum)
31 n = num_parms(source);
38 if ( (parmnum == 0) && (n == 1) ) {
43 while (count++ < parmnum) do {
45 } while( (strlen(buf)>0) && (buf[0]!='|') );
46 if (buf[0]=='|') strcpy(buf,&buf[1]);
47 for (count = 0; count<strlen(buf); ++count)
48 if (buf[count] == '|') buf[count] = 0;
53 * extract_int() - extract an int parm w/o supplying a buffer
55 int extract_int(char *source, int parmnum)
59 extract(buf,source,parmnum);
69 void main(int argc, char **argv)
80 attach_to_server(argc,argv);
82 if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
83 fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
86 strcpy(nodetitle, "this BBS");
91 while (serv_gets(buf), strcmp(buf,"000")) {
92 if (a==0) my_pid = atoi(buf);
93 if (a==2) strcpy(nodetitle, buf);
97 printf(" Users currently logged on to %s\n", nodetitle);
101 fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
105 printf("Session User name Room From host\n");
106 printf("------- ------------------------- -------------------- ------------------------\n");
107 while (serv_gets(buf), strcmp(buf,"000")) {
108 s_pid = extract_int(buf,0);
109 extract(s_user,buf,1);
110 extract(s_room,buf,2);
111 extract(s_host,buf,3);
112 if (s_pid != my_pid) {
113 printf("%-7d%c%-25s %-20s %-24s\n",
115 ((s_pid == my_pid) ? '*' : ' '),
116 s_user,s_room,s_host);
128 * replacement strerror() for systems that don't have it
130 char *strerror(int e)
134 sprintf(buf,"errno = %d",e);