From: Art Cancro Date: Tue, 28 Sep 1999 03:27:38 +0000 (+0000) Subject: * Fully migrated cmd_greg() and cmd_regi() into serv_vcard (still has bugs) X-Git-Tag: v7.86~7520 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=e3ade51919b47b688f526a94043192a0fd1032c8;p=citadel.git * Fully migrated cmd_greg() and cmd_regi() into serv_vcard (still has bugs) --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index d66c0aef9..2f5e7bd8f 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 1.373 1999/09/28 03:27:37 ajc +* Fully migrated cmd_greg() and cmd_regi() into serv_vcard (still has bugs) + Revision 1.372 1999/09/27 03:33:40 ajc * cmd_regi() is now in serv_vcard and writes to the vcard instead of to the usersupp file. Still needs tweaking. @@ -1275,4 +1278,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citserver.c b/citadel/citserver.c index 2459af8c5..ef7cb29ed 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -1062,10 +1062,6 @@ void *context_loop(struct CitContext *con) cmd_gnur(); } - else if (!strncasecmp(cmdbuf,"GREG",4)) { - cmd_greg(&cmdbuf[5]); - } - else if (!strncasecmp(cmdbuf,"VALI",4)) { cmd_vali(&cmdbuf[5]); } diff --git a/citadel/routines2.c b/citadel/routines2.c index a6345b31e..e3ea56860 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -34,7 +34,6 @@ void newprompt(char *prompt, char *str, int len); void sttybbs(int cmd); int inkey(void); void serv_write(char *buf, int nbytes); -void extract(char *dest, char *source, int parmnum); int haschar(char *st, int ch); void progress(long int curr, long int cmax); void citedit(FILE *fp, long int base_pos); diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 545245119..1301d54d0 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -30,6 +30,7 @@ #include "policy.h" #include "database.h" #include "msgbase.h" +#include "tools.h" #include "vcard.h" struct vcard_internal_info { @@ -60,7 +61,6 @@ int vcard_personal_upload(struct CtdlMessage *msg) { while (ptr != NULL) { linelen = strcspn(ptr, "\n"); - lprintf(9, "linelen == %d\n", linelen); if (linelen == 0) return(0); /* end of headers */ if (!strncasecmp(ptr, "Content-type: text/x-vcard", 26)) { @@ -82,7 +82,7 @@ int vcard_personal_upload(struct CtdlMessage *msg) { /* - * back end function used by vcard_get_my() + * back end function used by vcard_get_user() */ void vcard_gm_backend(long msgnum) { VC->msgnum = msgnum; @@ -93,14 +93,14 @@ void vcard_gm_backend(long msgnum) { * If this user has a vcard on disk, read it into memory, otherwise allocate * and return an empty vCard. */ -struct vCard *vcard_get_my(void) { +struct vCard *vcard_get_user(struct usersupp *u) { char hold_rm[ROOMNAMELEN]; char config_rm[ROOMNAMELEN]; struct CtdlMessage *msg; struct vCard *v; strcpy(hold_rm, CC->quickroom.QRname); /* save current room */ - MailboxName(config_rm, &CC->usersupp, CONFIGROOM); + MailboxName(config_rm, u, CONFIGROOM); if (getroom(&CC->quickroom, config_rm) != 0) { getroom(&CC->quickroom, hold_rm); @@ -129,10 +129,11 @@ struct vCard *vcard_get_my(void) { /* * Write our config to disk */ -void vcard_write_my(struct vCard *v) { +void vcard_write_user(struct usersupp *u, struct vCard *v) { char temp[PATH_MAX]; FILE *fp; char *ser; + char config_rm[ROOMNAMELEN]; strcpy(temp, tmpnam(NULL)); ser = vcard_serialize(v); @@ -148,8 +149,9 @@ void vcard_write_my(struct vCard *v) { } fclose(fp); - /* this handy API function does all the work for us */ - CtdlWriteObject(CONFIGROOM, "text/x-vcard", temp, 1, 0, 1); + /* these handy API functions do all the work for us */ + MailboxName(config_rm, u, CONFIGROOM); + CtdlWriteObject(config_rm, "text/x-vcard", temp, 1, 0, 1); unlink(temp); } @@ -176,7 +178,7 @@ void cmd_regi(char *argbuf) { return; } - my_vcard = vcard_get_my(); + my_vcard = vcard_get_user(&CC->usersupp); strcpy(tmpaddr, ""); strcpy(tmpcity, ""); strcpy(tmpstate, ""); @@ -214,20 +216,15 @@ void cmd_regi(char *argbuf) { } sprintf(tmpaddress, ";;%s;%s;%s;%s;USA", tmpaddr, tmpcity, tmpstate, tmpzip); - lprintf(9, "setting address\n"); vcard_set_prop(my_vcard, "adr", tmpaddress); - lprintf(9, "writing my vcard\n"); - vcard_write_my(my_vcard); - lprintf(9, "freeing my vcard\n"); + vcard_write_user(&CC->usersupp, my_vcard); vcard_free(my_vcard); - lprintf(9, "marking account as needing validation\n"); - lgetuser(&CC->usersupp,CC->curr_user); + lgetuser(&CC->usersupp, CC->curr_user); CC->usersupp.flags=(CC->usersupp.flags|US_REGIS|US_NEEDVALID); lputuser(&CC->usersupp); /* set global flag calling for validation */ - lprintf(9, "setting global flag\n"); begin_critical_section(S_CONTROL); get_control(); CitControl.MMflags = CitControl.MMflags | MM_VALID ; @@ -236,16 +233,86 @@ void cmd_regi(char *argbuf) { } + +/* + * get registration info for a user + */ +void cmd_greg(char *argbuf) +{ + struct usersupp usbuf; + struct vCard *v; + char *tel; + char who[256]; + char adr[256]; + char buf[256]; + + extract(who, argbuf, 0); + + if (!(CC->logged_in)) { + cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN); + return; + } + + if (!strcasecmp(who,"_SELF_")) strcpy(who,CC->curr_user); + + if ((CC->usersupp.axlevel < 6) && (strcasecmp(who,CC->curr_user))) { + cprintf("%d Higher access required.\n", + ERROR+HIGHER_ACCESS_REQUIRED); + return; + } + + if (getuser(&usbuf, who) != 0) { + cprintf("%d '%s' not found.\n", ERROR+NO_SUCH_USER, who); + return; + } + + v = vcard_get_user(&usbuf); + + cprintf("%d %s\n", LISTING_FOLLOWS, usbuf.fullname); + cprintf("%ld\n", usbuf.usernum); + cprintf("%s\n", usbuf.password); + cprintf("%s\n", vcard_get_prop(v, "n", 0)); /* name */ + + strcpy(adr, vcard_get_prop(v, "adr", 0)); /* address... */ + + extract_token(buf, adr, 2, ';'); + cprintf("%s\n", buf); /* street */ + extract_token(buf, adr, 2, ';'); + cprintf("%s\n", buf); /* city */ + extract_token(buf, adr, 2, ';'); + cprintf("%s\n", buf); /* state */ + extract_token(buf, adr, 2, ';'); + cprintf("%s\n", buf); /* zip */ + + tel = vcard_get_prop(v, "tel;home", 0); + if (tel == NULL) tel = vcard_get_prop(v, "tel", 1); + if (tel != NULL) { + cprintf("%s\n", tel); + } + else { + cprintf(" \n"); + } + + cprintf("%d\n", usbuf.axlevel); + + cprintf("%s\n", vcard_get_prop(v, "email;internet", 0)); + cprintf("000\n"); + } + + + void vcard_session_startup_hook(void) { CtdlAllocUserData(SYM_VCARD, sizeof(struct vcard_internal_info)); } + char *Dynamic_Module_Init(void) { SYM_VCARD = CtdlGetDynamicSymbol(); CtdlRegisterSessionHook(vcard_session_startup_hook, EVT_START); CtdlRegisterMessageHook(vcard_personal_upload, EVT_BEFORESAVE); CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info"); + CtdlRegisterProtoHook(cmd_greg, "GREG", "Get registration info"); return "$Id$"; } diff --git a/citadel/tools.c b/citadel/tools.c index 9335cbe98..189f922cd 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -37,7 +37,7 @@ int num_parms(char *source) /* * extract() - extract a parameter from a series of "|" separated... */ -void extract(char *dest, char *source, int parmnum) +void extract_token(char *dest, char *source, int parmnum, char separator) { char buf[256]; int count = 0; @@ -58,16 +58,16 @@ void extract(char *dest, char *source, int parmnum) if ( (parmnum == 0) && (n == 1) ) { strcpy(dest,buf); for (n=0; n0) && (buf[0]!='|') ); - if (buf[0]=='|') strcpy(buf,&buf[1]); + } while( (strlen(buf)>0) && (buf[0]!=separator) ); + if (buf[0]==separator) strcpy(buf,&buf[1]); for (count = 0; countlogged_in)) { - cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN); - return; - } - - if (!strcasecmp(who,"_SELF_")) strcpy(who,CC->curr_user); - - if ((CC->usersupp.axlevel < 6) && (strcasecmp(who,CC->curr_user))) { - cprintf("%d Higher access required.\n", - ERROR+HIGHER_ACCESS_REQUIRED); - return; - } - - if (getuser(&usbuf,who) != 0) { - cprintf("%d '%s' not found.\n",ERROR+NO_SUCH_USER,who); - return; - } - - cprintf("%d %s\n",LISTING_FOLLOWS,usbuf.fullname); - cprintf("%ld\n",usbuf.usernum); - cprintf("%s\n",usbuf.password); - cprintf("%s\n",usbuf.USname); - cprintf("%s\n",usbuf.USaddr); - cprintf("%s\n%s\n%s\n", - usbuf.UScity,usbuf.USstate,usbuf.USzip); - strcpy(pbuf,usbuf.USphone); - usbuf.USphone[0]=0; - for (a=0; a='0')&&(pbuf[a]<='9')) { - b=strlen(usbuf.USphone); - usbuf.USphone[b]=pbuf[a]; - usbuf.USphone[b+1]=0; - } - } - while(strlen(usbuf.USphone)<10) { - strcpy(pbuf,usbuf.USphone); - strcpy(usbuf.USphone," "); - strcat(usbuf.USphone,pbuf); - } - - cprintf("(%c%c%c) %c%c%c-%c%c%c%c\n", - usbuf.USphone[0],usbuf.USphone[1], - usbuf.USphone[2],usbuf.USphone[3], - usbuf.USphone[4],usbuf.USphone[5], - usbuf.USphone[6],usbuf.USphone[7], - usbuf.USphone[8],usbuf.USphone[9]); - - cprintf("%d\n",usbuf.axlevel); - cprintf("%s\n",usbuf.USemail); - cprintf("000\n"); - } - /* * validate a user */ diff --git a/citadel/user_ops.h b/citadel/user_ops.h index 568d09a80..553e185b3 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -21,7 +21,6 @@ void cmd_slrp (char *new_ptr); void cmd_invt_kick (char *iuser, int op); void cmd_forg (void); void cmd_gnur (void); -void cmd_greg (char *who); void cmd_vali (char *v_args); void ForEachUser(void (*CallBack)(struct usersupp *EachUser)); void ListThisUser(struct usersupp *usbuf); diff --git a/citadel/vcard.c b/citadel/vcard.c index 3755848cc..a34a466b0 100644 --- a/citadel/vcard.c +++ b/citadel/vcard.c @@ -93,18 +93,18 @@ struct vCard *vcard_load(char *vtext) { strncpy(valuebuf, &ptr[colonpos+1], nlpos-colonpos-1); valuebuf[nlpos-colonpos-1] = 0; - if ( (!strcasecmp(namebuf, "begin")) - && (!strcasecmp(valuebuf, "vcard")) ) valid = 1; if ( (!strcasecmp(namebuf, "end")) && (!strcasecmp(valuebuf, "vcard")) ) valid = 0; + if ( (!strcasecmp(namebuf, "begin")) + && (!strcasecmp(valuebuf, "vcard")) ) valid = 1; - if (valid) { + if ( (valid) && (strcasecmp(namebuf, "begin")) ) { ++v->numprops; v->prop = reallok(v->prop, (v->numprops * sizeof(char *) * 2) ); v->prop[v->numprops-1].name = namebuf; v->prop[v->numprops-1].value = valuebuf; - } + } else { phree(namebuf); phree(valuebuf); @@ -152,7 +152,7 @@ char *vcard_get_prop(struct vCard *v, char *propname, int is_partial) { */ void vcard_free(struct vCard *v) { int i; - + if (v->magic != CTDL_VCARD_MAGIC) return; /* Self-check */ if (v->numprops) for (i=0; i<(v->numprops); ++i) { @@ -163,6 +163,7 @@ void vcard_free(struct vCard *v) { if (v->prop != NULL) phree(v->prop); memset(v, 0, sizeof(struct vCard)); + phree(v); } @@ -190,7 +191,7 @@ void vcard_set_prop(struct vCard *v, char *name, char *value) { v->prop = reallok(v->prop, (v->numprops * sizeof(char *) * 2) ); v->prop[v->numprops-1].name = strdoop(name); - v->prop[v->numprops-1].value = (value); + v->prop[v->numprops-1].value = strdoop(value); }