4 * This module implementsserver commands related to the display and
5 * manipulation of user "bio" files.
17 #include <sys/types.h>
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
24 # include <sys/time.h>
35 #include "sysdep_decls.h"
36 #include "citserver.h"
40 #include "serv_extensions.h"
54 void cmd_ebio(char *cmdbuf) {
58 if (!(CC->logged_in)) {
59 cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
63 snprintf(buf, sizeof buf, "./bio/%ld",CC->user.usernum);
66 cprintf("%d Cannot create file: %s\n", ERROR + INTERNAL_ERROR,
70 cprintf("%d \n",SEND_LISTING);
72 while(client_gets(buf), strcmp(buf,"000")) {
73 if (ftell(fp) < config.c_maxmsglen) {
74 fprintf(fp,"%s\n",buf);
83 void cmd_rbio(char *cmdbuf)
85 struct ctdluser ruser;
89 extract(buf,cmdbuf,0);
90 if (getuser(&ruser,buf)!=0) {
91 cprintf("%d No such user.\n",ERROR + NO_SUCH_USER);
94 snprintf(buf, sizeof buf, "./bio/%ld",ruser.usernum);
96 cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS,
97 ruser.fullname, ruser.usernum, ruser.axlevel,
98 (long)ruser.lastcall, ruser.timescalled, ruser.posted);
101 cprintf("%s has no bio on file.\n", ruser.fullname);
103 while (fgets(buf,256,fp)!=NULL) cprintf("%s",buf);
110 * list of users who have entered bios
112 void cmd_lbio(char *cmdbuf) {
115 struct ctdluser usbuf;
117 ls=popen("cd ./bio; ls","r");
119 cprintf("%d Cannot open listing.\n",ERROR + FILE_NOT_FOUND);
123 cprintf("%d\n",LISTING_FOLLOWS);
124 while (fgets(buf,sizeof buf,ls)!=NULL)
125 if (getuserbynumber(&usbuf,atol(buf))==0)
126 cprintf("%s\n",usbuf.fullname);
134 char *serv_bio_init(void)
136 CtdlRegisterProtoHook(cmd_ebio, "EBIO", "Enter your bio");
137 CtdlRegisterProtoHook(cmd_rbio, "RBIO", "Read a user's bio");
138 CtdlRegisterProtoHook(cmd_lbio, "LBIO", "List users with bios");