2 * This module implementsserver commands related to the display and
3 * manipulation of user "bio" files.
6 * Copyright (c) 1987-2009 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "ctdl_module.h"
30 void cmd_ebio(char *cmdbuf) {
36 if (!(CC->logged_in)) {
37 cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
41 snprintf(buf, sizeof buf, "%s%ld",ctdl_bio_dir,CC->user.usernum);
44 cprintf("%d Cannot create file: %s\n", ERROR + INTERNAL_ERROR,
48 cprintf("%d \n",SEND_LISTING);
49 while(client_getln(buf, sizeof buf) >= 0 && strcmp(buf,"000")) {
50 if (ftell(fp) < config.c_maxmsglen) {
51 fprintf(fp,"%s\n",buf);
60 void cmd_rbio(char *cmdbuf)
62 struct ctdluser ruser;
66 extract_token(buf, cmdbuf, 0, '|', sizeof buf);
67 if (CtdlGetUser(&ruser, buf) != 0) {
68 cprintf("%d No such user.\n",ERROR + NO_SUCH_USER);
71 snprintf(buf, sizeof buf, "%s%ld",ctdl_bio_dir,ruser.usernum);
73 cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS,
74 ruser.fullname, ruser.usernum, ruser.axlevel,
75 (long)ruser.lastcall, ruser.timescalled, ruser.posted);
78 cprintf("%s has no bio on file.\n", ruser.fullname);
80 while (fgets(buf, sizeof buf, fp) != NULL) cprintf("%s",buf);
87 * list of users who have entered bios
89 void cmd_lbio(char *cmdbuf) {
92 struct ctdluser usbuf;
95 snprintf(listbios, sizeof(listbios),"cd %s; ls",ctdl_bio_dir);
96 ls = popen(listbios, "r");
98 cprintf("%d Cannot open listing.\n", ERROR + FILE_NOT_FOUND);
102 cprintf("%d\n", LISTING_FOLLOWS);
103 while (fgets(buf, sizeof buf, ls)!=NULL)
104 if (CtdlGetUserByNumber(&usbuf,atol(buf))==0)
105 cprintf("%s\n", usbuf.fullname);
113 CTDL_MODULE_INIT(bio)
117 CtdlRegisterProtoHook(cmd_ebio, "EBIO", "Enter your bio");
118 CtdlRegisterProtoHook(cmd_rbio, "RBIO", "Read a user's bio");
119 CtdlRegisterProtoHook(cmd_lbio, "LBIO", "List users with bios");
121 /* return our Subversion id for the Log */