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>
33 #include <libcitadel.h>
36 #include "citserver.h"
45 #include "citadel_dirs.h"
47 #include "ctdl_module.h"
52 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
, "%s%ld",ctdl_bio_dir
,CC
->user
.usernum
);
66 cprintf("%d Cannot create file: %s\n", ERROR
+ INTERNAL_ERROR
,
70 cprintf("%d \n",SEND_LISTING
);
71 while(client_getln(buf
, sizeof buf
) >= 0 && strcmp(buf
,"000")) {
72 if (ftell(fp
) < config
.c_maxmsglen
) {
73 fprintf(fp
,"%s\n",buf
);
82 void cmd_rbio(char *cmdbuf
)
84 struct ctdluser ruser
;
88 extract_token(buf
, cmdbuf
, 0, '|', sizeof buf
);
89 if (getuser(&ruser
, buf
) != 0) {
90 cprintf("%d No such user.\n",ERROR
+ NO_SUCH_USER
);
93 snprintf(buf
, sizeof buf
, "%s%ld",ctdl_bio_dir
,ruser
.usernum
);
95 cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS
,
96 ruser
.fullname
, ruser
.usernum
, ruser
.axlevel
,
97 (long)ruser
.lastcall
, ruser
.timescalled
, ruser
.posted
);
100 cprintf("%s has no bio on file.\n", ruser
.fullname
);
102 while (fgets(buf
, sizeof buf
, fp
) != NULL
) cprintf("%s",buf
);
109 * list of users who have entered bios
111 void cmd_lbio(char *cmdbuf
) {
114 struct ctdluser usbuf
;
117 snprintf(listbios
, sizeof(listbios
),"cd %s; ls",ctdl_bio_dir
);
118 ls
= popen(listbios
, "r");
120 cprintf("%d Cannot open listing.\n", ERROR
+ FILE_NOT_FOUND
);
124 cprintf("%d\n", LISTING_FOLLOWS
);
125 while (fgets(buf
, sizeof buf
, ls
)!=NULL
)
126 if (getuserbynumber(&usbuf
,atol(buf
))==0)
127 cprintf("%s\n", usbuf
.fullname
);
135 CTDL_MODULE_INIT(bio
)
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");
143 /* return our Subversion id for the Log */