4 * This module implementsserver commands related to the display and
5 * manipulation of user "bio" files.
8 * Copyright (c) 1987-2009 by the citadel.org team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include <sys/types.h>
35 #if TIME_WITH_SYS_TIME
36 # include <sys/time.h>
40 # include <sys/time.h>
49 #include <libcitadel.h>
52 #include "citserver.h"
61 #include "citadel_dirs.h"
63 #include "ctdl_module.h"
68 void cmd_ebio(char *cmdbuf) {
74 if (!(CC->logged_in)) {
75 cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
79 snprintf(buf, sizeof buf, "%s%ld",ctdl_bio_dir,CC->user.usernum);
82 cprintf("%d Cannot create file: %s\n", ERROR + INTERNAL_ERROR,
86 cprintf("%d \n",SEND_LISTING);
87 while(client_getln(buf, sizeof buf) >= 0 && strcmp(buf,"000")) {
88 if (ftell(fp) < config.c_maxmsglen) {
89 fprintf(fp,"%s\n",buf);
98 void cmd_rbio(char *cmdbuf)
100 struct ctdluser ruser;
104 extract_token(buf, cmdbuf, 0, '|', sizeof buf);
105 if (getuser(&ruser, buf) != 0) {
106 cprintf("%d No such user.\n",ERROR + NO_SUCH_USER);
109 snprintf(buf, sizeof buf, "%s%ld",ctdl_bio_dir,ruser.usernum);
111 cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS,
112 ruser.fullname, ruser.usernum, ruser.axlevel,
113 (long)ruser.lastcall, ruser.timescalled, ruser.posted);
116 cprintf("%s has no bio on file.\n", ruser.fullname);
118 while (fgets(buf, sizeof buf, fp) != NULL) cprintf("%s",buf);
125 * list of users who have entered bios
127 void cmd_lbio(char *cmdbuf) {
130 struct ctdluser usbuf;
133 snprintf(listbios, sizeof(listbios),"cd %s; ls",ctdl_bio_dir);
134 ls = popen(listbios, "r");
136 cprintf("%d Cannot open listing.\n", ERROR + FILE_NOT_FOUND);
140 cprintf("%d\n", LISTING_FOLLOWS);
141 while (fgets(buf, sizeof buf, ls)!=NULL)
142 if (getuserbynumber(&usbuf,atol(buf))==0)
143 cprintf("%s\n", usbuf.fullname);
151 CTDL_MODULE_INIT(bio)
155 CtdlRegisterProtoHook(cmd_ebio, "EBIO", "Enter your bio");
156 CtdlRegisterProtoHook(cmd_rbio, "RBIO", "Read a user's bio");
157 CtdlRegisterProtoHook(cmd_lbio, "LBIO", "List users with bios");
159 /* return our Subversion id for the Log */