usersupp file. Still needs tweaking.
$Log$
+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.
+
Revision 1.371 1999/09/24 03:32:19 ajc
* "read my vCard" and "write my vCard" are written and tested.
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
SERV_OBJS = citserver.ro user_ops.ro support.ro room_ops.ro file_ops.ro \
msgbase.ro config.ro sysdep.ro locate_host.ro housekeeping.ro \
database.ro control.ro logging.ro policy.ro dynloader.ro tools.ro \
- mime_parser.ro html.ro vcard.ro $(AUTH) $(LIBOBJS:.o=.ro)
+ mime_parser.ro html.ro $(AUTH) $(LIBOBJS:.o=.ro)
citserver: $(SERV_OBJS)
$(CC) $(SERV_OBJS) $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) $(NETLIBS) $(GDBM) -o citserver
modules/serv_icq.mo: serv_icq.mo
ln -f serv_icq.mo modules
-modules/serv_vcard.so: serv_vcard.mo
- $(LINK_SHARED) -o modules/serv_vcard.so serv_vcard.mo
+modules/serv_vcard.so: serv_vcard.mo vcard.mo
+ $(LINK_SHARED) -o modules/serv_vcard.so serv_vcard.mo vcard.mo
modules/serv_vcard.mo: serv_vcard.mo
ln -f serv_vcard.mo modules
+modules/vcard.mo: vcard.mo
+ ln -f vcard.mo modules
+
aidepost: aidepost.o config.o $(LIBOBJS)
$(CC) aidepost.o config.o $(LIBOBJS) $(LDFLAGS) -o aidepost
cmd_list();
}
- else if (!strncasecmp(cmdbuf,"REGI",4)) {
- cmd_regi();
- }
-
else if (!strncasecmp(cmdbuf,"CHEK",4)) {
cmd_chek();
}
#include "citserver.h"
#include "support.h"
#include "config.h"
+#include "control.h"
#include "dynloader.h"
#include "room_ops.h"
#include "user_ops.h"
if (getroom(&CC->quickroom, config_rm) != 0) {
getroom(&CC->quickroom, hold_rm);
- return new_vcard();
+ return vcard_new();
}
/* We want the last (and probably only) vcard in this room */
CtdlForEachMessage(MSGS_LAST, 1, "text/x-vcard", vcard_gm_backend);
getroom(&CC->quickroom, hold_rm); /* return to saved room */
- if (VC->msgnum < 0L) return new_vcard();
+ if (VC->msgnum < 0L) return vcard_new();
msg = CtdlFetchMessage(VC->msgnum);
- if (msg == NULL) return new_vcard();
+ if (msg == NULL) return vcard_new();
- v = load_vcard(msg->cm_fields['M']);
+ v = vcard_load(msg->cm_fields['M']);
CtdlFreeMessage(msg);
return v;
}
char *ser;
strcpy(temp, tmpnam(NULL));
- ser = serialize_vcard(v);
+ ser = vcard_serialize(v);
fp = fopen(temp, "w");
if (fp == NULL) return;
+/*
+ * old style "enter registration info" command
+ */
+void cmd_regi(char *argbuf) {
+ int a,b,c;
+ char buf[256];
+ struct vCard *my_vcard;
+
+ char tmpaddr[256];
+ char tmpcity[256];
+ char tmpstate[256];
+ char tmpzip[256];
+ char tmpphone[256];
+ char tmpaddress[512];
+
+ if (!(CC->logged_in)) {
+ cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
+ return;
+ }
+
+ my_vcard = vcard_get_my();
+ strcpy(tmpaddr, "");
+ strcpy(tmpcity, "");
+ strcpy(tmpstate, "");
+ strcpy(tmpzip, "");
+
+ cprintf("%d Send registration...\n", SEND_LISTING);
+ a=0;
+ while (client_gets(buf), strcmp(buf,"000")) {
+ if (a==0) vcard_set_prop(my_vcard, "n", buf);
+ if (a==1) strcpy(tmpaddr,buf);
+ if (a==2) strcpy(tmpcity,buf);
+ if (a==3) strcpy(tmpstate,buf);
+ if (a==4) {
+ for (c=0; c<strlen(buf); ++c) {
+ if ((buf[c]>='0')&&(buf[c]<='9')) {
+ b=strlen(tmpzip);
+ tmpzip[b]=buf[c];
+ tmpzip[b+1]=0;
+ }
+ }
+ }
+ if (a==5) {
+ strcpy(tmpphone, "");
+ for (c=0; c<strlen(buf); ++c) {
+ if ((buf[c]>='0')&&(buf[c]<='9')) {
+ b=strlen(tmpphone);
+ tmpphone[b]=buf[c];
+ tmpphone[b+1]=0;
+ }
+ }
+ vcard_set_prop(my_vcard, "tel;home", tmpphone);
+ }
+ if (a==6) vcard_set_prop(my_vcard, "email;internet", buf);
+ ++a;
+ }
+ 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_free(my_vcard);
+
+ lprintf(9, "marking account as needing validation\n");
+ 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 ;
+ put_control();
+ end_critical_section(S_CONTROL);
+ }
+
+
+void vcard_session_startup_hook(void) {
+ CtdlAllocUserData(SYM_VCARD, sizeof(struct vcard_internal_info));
+}
+
char *Dynamic_Module_Init(void)
{
- CtdlAllocUserData(SYM_VCARD, sizeof(struct vcard_internal_info));
+ SYM_VCARD = CtdlGetDynamicSymbol();
+ CtdlRegisterSessionHook(vcard_session_startup_hook, EVT_START);
CtdlRegisterMessageHook(vcard_personal_upload, EVT_BEFORESAVE);
+ CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info");
return "$Id$";
}
}
-/*
- * enter registration info
- */
-void cmd_regi(void) {
- int a,b,c;
- char buf[256];
-
- char tmpname[256];
- char tmpaddr[256];
- char tmpcity[256];
- char tmpstate[256];
- char tmpzip[256];
- char tmpphone[256];
- char tmpemail[256];
-
- if (!(CC->logged_in)) {
- cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
- return;
- }
-
- strcpy(tmpname,"");
- strcpy(tmpaddr,"");
- strcpy(tmpcity,"");
- strcpy(tmpstate,"");
- strcpy(tmpzip,"");
- strcpy(tmpphone,"");
- strcpy(tmpemail,"");
-
- cprintf("%d Send registration...\n",SEND_LISTING);
- a=0;
- while (client_gets(buf), strcmp(buf,"000")) {
- if (a==0) strcpy(tmpname,buf);
- if (a==1) strcpy(tmpaddr,buf);
- if (a==2) strcpy(tmpcity,buf);
- if (a==3) strcpy(tmpstate,buf);
- if (a==4) {
- for (c=0; c<strlen(buf); ++c) {
- if ((buf[c]>='0')&&(buf[c]<='9')) {
- b=strlen(tmpzip);
- tmpzip[b]=buf[c];
- tmpzip[b+1]=0;
- }
- }
- }
- if (a==5) {
- for (c=0; c<strlen(buf); ++c) {
- if ((buf[c]>='0')&&(buf[c]<='9')) {
- b=strlen(tmpphone);
- tmpphone[b]=buf[c];
- tmpphone[b+1]=0;
- }
- }
- }
- if (a==6) strncpy(tmpemail,buf,31);
- ++a;
- }
-
- tmpname[29]=0;
- tmpaddr[24]=0;
- tmpcity[14]=0;
- tmpstate[2]=0;
- tmpzip[9]=0;
- tmpphone[10]=0;
- tmpemail[31]=0;
-
- lgetuser(&CC->usersupp,CC->curr_user);
- strcpy(CC->usersupp.USname,tmpname);
- strcpy(CC->usersupp.USaddr,tmpaddr);
- strcpy(CC->usersupp.UScity,tmpcity);
- strcpy(CC->usersupp.USstate,tmpstate);
- strcpy(CC->usersupp.USzip,tmpzip);
- strcpy(CC->usersupp.USphone,tmpphone);
- strcpy(CC->usersupp.USemail,tmpemail);
- CC->usersupp.flags=(CC->usersupp.flags|US_REGIS|US_NEEDVALID);
- lputuser(&CC->usersupp);
-
- /* set global flag calling for validation */
- begin_critical_section(S_CONTROL);
- get_control();
- CitControl.MMflags = CitControl.MMflags | MM_VALID ;
- put_control();
- end_critical_section(S_CONTROL);
- }
/*
void ForEachUser(void (*CallBack)(struct usersupp *EachUser));
void ListThisUser(struct usersupp *usbuf);
void cmd_list (void);
-void cmd_regi (void);
void cmd_chek (void);
void cmd_qusr (char *who);
void cmd_ebio (void);
/*
* Constructor (empty vCard)
*/
-struct vCard *new_vcard() {
+struct vCard *vcard_new() {
struct vCard *v;
v = (struct vCard *) mallok(sizeof(struct vCard));
/*
* Constructor (supply serialized vCard)
*/
-struct vCard *load_vcard(char *vtext) {
+struct vCard *vcard_load(char *vtext) {
struct vCard *v;
int valid = 0;
char *mycopy, *ptr;
}
}
- v = new_vcard();
+ v = vcard_new();
if (v == NULL) return v;
ptr = mycopy;
}
+/*
+ * Fetch the value of a particular key
+ * If is_partial is set to 1, a partial match is ok (for example,
+ * a key of "tel;home" will satisfy a search for "tel")
+ */
+char *vcard_get_prop(struct vCard *v, char *propname, int is_partial) {
+ int i;
+
+ if (v->numprops) for (i=0; i<(v->numprops); ++i) {
+ if ( (!strcasecmp(v->prop[i].name, propname))
+ || ( (!strncasecmp(v->prop[i].name,
+ propname, strlen(propname)))
+ && (v->prop[i].name[strlen(propname)] == ';')
+ && (is_partial) ) ) {
+ return(v->prop[i].value);
+ }
+ }
+
+ return NULL;
+}
+
+
+
/*
* Destructor
*/
-void free_vcard(struct vCard *v) {
+void vcard_free(struct vCard *v) {
int i;
if (v->magic != CTDL_VCARD_MAGIC) return; /* Self-check */
/*
* Set a name/value pair in the card
*/
-void set_prop(struct vCard *v, char *name, char *value) {
+void vcard_set_prop(struct vCard *v, char *name, char *value) {
int i;
if (v->magic != CTDL_VCARD_MAGIC) return; /* Self-check */
* Serialize a struct vcard into a standard text/x-vcard MIME type.
*
*/
-char *serialize_vcard(struct vCard *v)
+char *vcard_serialize(struct vCard *v)
{
char *ser;
int i;
if (v->numprops) for (i=0; i<(v->numprops); ++i) {
strcat(ser, v->prop[i].name);
strcat(ser, ":");
- strcat(ser, v->prop[i].name);
+ strcat(ser, v->prop[i].value);
strcat(ser, "\r\n");
}
strcat(ser, "end:vcard\r\n");
};
-struct vCard *new_vcard(void);
-struct vCard *load_vcard(char *);
-void free_vcard(struct vCard *);
-void set_prop(struct vCard *v, char *name, char *value);
-char *serialize_vcard(struct vCard *);
+struct vCard *vcard_new(void);
+struct vCard *vcard_load(char *);
+void vcard_free(struct vCard *);
+void vcard_set_prop(struct vCard *v, char *name, char *value);
+char *vcard_get_prop(struct vCard *v, char *propname, int is_partial);
+char *vcard_serialize(struct vCard *);