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"
47 #include "citadel_dirs.h"
54 void cmd_ebio(char *cmdbuf) {
60 if (!(CC->logged_in)) {
61 cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
65 snprintf(buf, sizeof buf, "%s%ld",ctdl_bio_dir,CC->user.usernum);
68 cprintf("%d Cannot create file: %s\n", ERROR + INTERNAL_ERROR,
72 cprintf("%d \n",SEND_LISTING);
73 while(client_getln(buf, sizeof buf), strcmp(buf,"000")) {
74 if (ftell(fp) < config.c_maxmsglen) {
75 fprintf(fp,"%s\n",buf);
84 void cmd_rbio(char *cmdbuf)
86 struct ctdluser ruser;
90 extract_token(buf, cmdbuf, 0, '|', sizeof buf);
91 if (getuser(&ruser, buf) != 0) {
92 cprintf("%d No such user.\n",ERROR + NO_SUCH_USER);
95 snprintf(buf, sizeof buf, "%s%ld",ctdl_bio_dir,ruser.usernum);
97 cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS,
98 ruser.fullname, ruser.usernum, ruser.axlevel,
99 (long)ruser.lastcall, ruser.timescalled, ruser.posted);
102 cprintf("%s has no bio on file.\n", ruser.fullname);
104 while (fgets(buf, sizeof buf, fp) != NULL) cprintf("%s",buf);
111 * list of users who have entered bios
113 void cmd_lbio(char *cmdbuf) {
116 struct ctdluser usbuf;
119 snprintf(listbios, sizeof(listbios),"cd %s; ls",ctdl_bio_dir);
120 ls = popen(listbios, "r");
122 cprintf("%d Cannot open listing.\n", ERROR + FILE_NOT_FOUND);
126 cprintf("%d\n", LISTING_FOLLOWS);
127 while (fgets(buf, sizeof buf, ls)!=NULL)
128 if (getuserbynumber(&usbuf,atol(buf))==0)
129 cprintf("%s\n", usbuf.fullname);
137 char *serv_bio_init(void)
139 CtdlRegisterProtoHook(cmd_ebio, "EBIO", "Enter your bio");
140 CtdlRegisterProtoHook(cmd_rbio, "RBIO", "Read a user's bio");
141 CtdlRegisterProtoHook(cmd_lbio, "LBIO", "List users with bios");