$Log$
+ Revision 571.4 2000/04/24 03:36:43 ajc
+ * Removed references to strucmp() and struncmp(), replaced them with
+ strcasecmp() and strncasecmp() as we did in the server a while ago, and
+ set up the config script to figure out whether they need to be compiled
+ in. Also moved them to tools.h
+ * Wrote a password manager for the client
+
Revision 571.3 2000/04/19 03:17:10 ajc
* Don't ever expire the Local System Configuration> room
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
-
whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c getutline.c \
auth.c chkpwd.c client_icq.c html.c vcard.c serv_upgrade.c \
serv_smtp.c serv_pop3.c internet_addressing.c parsedate.c genstamp.c \
- domain.c clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c
+ domain.c clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c \
+ client_passwords.c
DEP_FILES=$(SOURCES:.c=.d)
citadel$(EXEEXT): ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
routines2$(CX) messages$(CX) client_icq$(CX) \
+ client_passwords$(CX) \
commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) $(LIBOBJS)
$(CC) ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
routines2$(CX) messages$(CX) client_icq$(CX) \
commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) \
+ client_passwords$(CX) \
$(LIBOBJS) $(LDFLAGS) -o citadel $(NETLIBS) $(CLIENT_PTLIBS)
netpoll: netpoll.o config.o ipc_c_tcp.o tools.o $(LIBOBJS)
#include "commands.h"
#include "ipc.h"
#include "client_chat.h"
+#include "client_passwords.h"
#include "client_icq.h"
#include "citadel_decls.h"
#include "tools.h"
char have_xterm = 0; /* are we running on an xterm? */
char rc_username[32];
char rc_password[32];
+char hostbuf[256];
+char portbuf[256];
char rc_floor_mode;
char floor_mode;
char curr_floor = 0; /* number of current floor */
if (march == NULL)
return;
- if ((!strucmp(march->march_name, roomname))
- || ((!strucmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
+ if ((!strcasecmp(march->march_name, roomname))
+ || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
mptr = march->next;
free(march);
march = mptr;
mptr2 = march;
for (mptr = march; mptr != NULL; mptr = mptr->next) {
- if ((!strucmp(mptr->march_name, roomname))
- || ((!strucmp(roomname, "_FLOOR_"))
+ if ((!strcasecmp(mptr->march_name, roomname))
+ || ((!strcasecmp(roomname, "_FLOOR_"))
&& (mptr->march_floor == floornum))) {
mptr2->next = mptr->next;
if (pattern(psearch, towhere) >= 0) {
partial_match = 1;
}
- if (!struncmp(towhere, psearch, strlen(towhere))) {
+ if (!strncasecmp(towhere, psearch, strlen(towhere))) {
partial_match = 2;
}
if (partial_match > best_match) {
curr_floor = extract_int(&aaa[4], 10);
remove_march(room_name, 0);
- if (!strucmp(towhere, "_BASEROOM_"))
+ if (!strcasecmp(towhere, "_BASEROOM_"))
remove_march(towhere, 0);
if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
if (floorlist[(int) curr_floor][0] == 0)
load_floorlist();
tofloor = (-1);
for (a = 0; a < 128; ++a)
- if (!strucmp(&floorlist[a][0], towhere))
+ if (!strcasecmp(&floorlist[a][0], towhere))
tofloor = a;
if (tofloor < 0) {
for (a = 0; a < 128; ++a) {
- if (!struncmp(&floorlist[a][0], towhere, strlen(towhere))) {
+ if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
tofloor = a;
}
}
}
strproc(pass1);
strproc(pass2);
- if (!strucmp(pass1, pass2)) {
+ if (!strcasecmp(pass1, pass2)) {
snprintf(buf, sizeof buf, "SETP %s", pass1);
serv_puts(buf);
serv_gets(buf);
printf("%s\n", &buf[4]);
+ offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
return (0);
} else {
printf("*** They don't match... try again.\n");
int main(int argc, char **argv)
{
int a, b, mcmd;
- char aaa[100], bbb[100], eee[100]; /* general purpose variables */
+ char aaa[100], bbb[100];/* general purpose variables */
char argbuf[32]; /* command line buf */
volatile int termn8 = 0;
-
+ int stored_password = 0;
+ char password[256];
sttybbs(SB_SAVE); /* Store the old terminal parameters */
load_command_set(); /* parse the citadel.rc file */
printf("Attaching to server... \r");
fflush(stdout);
- attach_to_server(argc, argv);
- printf("Establishing session...\r");
- fflush(stdout);
+ attach_to_server(argc, argv, hostbuf, portbuf);
send_ansi_detect();
formout("hello"); /* print the opening greeting */
printf("\n");
-GSTA: termn8 = 0;
+GSTA: /* See if we have a username and password on disk */
+ if (rc_remember_passwords) {
+ get_stored_password(hostbuf, portbuf, fullname, password);
+ if (strlen(fullname) > 0) {
+ sprintf(aaa, "USER %s", fullname);
+ serv_puts(aaa);
+ serv_gets(aaa);
+ sprintf(aaa, "PASS %s", password);
+ serv_puts(aaa);
+ serv_gets(aaa);
+ if (aaa[0] == '2') {
+ load_user_info(&aaa[4]);
+ stored_password = 1;
+ goto PWOK;
+ }
+ else {
+ set_stored_password(hostbuf, portbuf, "", "");
+ }
+ }
+ }
+
+ termn8 = 0;
newnow = 0;
do {
if (strlen(rc_username) > 0) {
newprompt("Enter your name: ", fullname, 29);
}
strproc(fullname);
- if (!strucmp(fullname, "new")) { /* just in case */
+ if (!strcasecmp(fullname, "new")) { /* just in case */
printf("Please enter the name you wish to log in with.\n");
}
} while (
- (!strucmp(fullname, "bbs"))
- || (!strucmp(fullname, "new"))
+ (!strcasecmp(fullname, "bbs"))
+ || (!strcasecmp(fullname, "new"))
|| (strlen(fullname) == 0));
- if (!strucmp(fullname, "off")) {
+ if (!strcasecmp(fullname, "off")) {
mcmd = 29;
goto TERMN8;
}
/* password authentication */
if (strlen(rc_password) > 0) {
- strcpy(eee, rc_password);
+ strcpy(password, rc_password);
} else {
- newprompt("\rPlease enter your password: ", eee, -19);
+ newprompt("\rPlease enter your password: ", password, -19);
}
- strproc(eee);
- snprintf(aaa, sizeof aaa, "PASS %s", eee);
+ strproc(password);
+ snprintf(aaa, sizeof aaa, "PASS %s", password);
serv_puts(aaa);
serv_gets(aaa);
if (aaa[0] == '2') {
load_user_info(&aaa[4]);
+ offer_to_remember_password(hostbuf, portbuf,
+ fullname, password);
goto PWOK;
}
printf("<< wrong password >>\n");
logoff(0);
goto GSTA;
- NEWUSR:if (strlen(rc_password) == 0) {
+NEWUSR: if (strlen(rc_password) == 0) {
printf("No record. Enter as new user? ");
if (yesno() == 0)
goto GSTA;
enter_config(1);
- PWOK:printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
+PWOK: printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
fullname, axlevel, axdefs[(int) axlevel],
usernum, timescalled);
#define tolower(x) ( ((x>='A')&&(x<='Z')) ? (x+'a'-'A') : x )
#define NEW_CONFIG
-#define strucmp(lstr,rstr) struncmp(lstr,rstr,32767)
-
/*
* The only typedef we do is an 8-bit unsigned, for screen dimensions.
* All other defs are done using standard C types. The code assumes that
#
allow_attachments=0
-# If you set the USERNAME variable, the value you set here will automatically
-# be passed to the "Enter your name:" prompt.
+
+# If you set REMEMBER_PASSWORDS to 1, the Citadel client will offer to
+# remember your user name and password for every Citadel server you access,
+# automatically logging in with them on subsequent visits.
+# (DANGER: do NOT enable this for "safe" public clients!)
#
-#username=My User Name
+remember_passwords=0
-# If you set the PASSWORD variable, the value you set here will automatically
-# be passed to all prompts which request a password ... including the prompt
-# which asks for a password when creating a new user.
+# Optionally, you can force the same username and password everywhere. This
+# obviously isn't as robust as the password manager.
#
+#username=My User Name
#password=mypassword
# If URLCMD is defined, users can hit 'U' after reading a message which
printf("Got room %s\n", c_room);
}
- if (strucmp(c_text,"NOOP")) {
+ if (strcasecmp(c_text,"NOOP")) {
if (!strcmp(c_user, fullname)) {
color(BRIGHT_YELLOW);
}
--- /dev/null
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <limits.h>
+#include <stdio.h>
+#include "tools.h"
+#include "commands.h"
+
+#define PWFILENAME "%s/.citadel.passwords"
+
+void determine_pwfilename(char *pwfile) {
+ struct passwd *p;
+
+ p = getpwuid(getuid());
+ if (p == NULL) strcpy(pwfile, "");
+ sprintf(pwfile, PWFILENAME, p->pw_dir);
+}
+
+
+/*
+ * Check the password file for a host/port match; if found, stuff the user
+ * name and password into the user/pass buffers
+ */
+void get_stored_password(
+ char *host,
+ char *port,
+ char *username,
+ char *password) {
+
+ char pwfile[PATH_MAX];
+ FILE *fp;
+ char buf[256];
+ char buf64[256];
+ char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
+
+ strcpy(username, "");
+ strcpy(password, "");
+
+ determine_pwfilename(pwfile);
+ if (strlen(pwfile)==0) return;
+
+ fp = fopen(pwfile, "r");
+ if (fp == NULL) return;
+ while (fgets(buf64, sizeof buf64, fp) != NULL) {
+ decode_base64(buf, buf64);
+ extract(hostbuf, buf, 0);
+ extract(portbuf, buf, 1);
+ extract(ubuf, buf, 2);
+ extract(pbuf, buf, 3);
+
+ if (!strcasecmp(hostbuf, host)) {
+ if (!strcasecmp(portbuf, port)) {
+ strcpy(username, ubuf);
+ strcpy(password, pbuf);
+ }
+ }
+ }
+ fclose(fp);
+}
+
+
+/*
+ * Set (or clear) stored passwords.
+ */
+void set_stored_password(
+ char *host,
+ char *port,
+ char *username,
+ char *password) {
+
+ char pwfile[PATH_MAX];
+ FILE *fp, *oldfp;
+ char buf[256];
+ char buf64[256];
+ char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
+
+ determine_pwfilename(pwfile);
+ if (strlen(pwfile)==0) return;
+
+ oldfp = fopen(pwfile, "r");
+ if (oldfp == NULL) oldfp = fopen("/dev/null", "r");
+ unlink(pwfile);
+ fp = fopen(pwfile, "w");
+ if (fp == NULL) fp = fopen("/dev/null", "w");
+ while (fgets(buf64, sizeof buf64, oldfp) != NULL) {
+ decode_base64(buf, buf64);
+ extract(hostbuf, buf, 0);
+ extract(portbuf, buf, 1);
+ extract(ubuf, buf, 2);
+ extract(pbuf, buf, 3);
+
+ if ( (strcasecmp(hostbuf, host))
+ || (strcasecmp(portbuf, port)) ) {
+ sprintf(buf, "%s|%s|%s|%s|",
+ hostbuf, portbuf, ubuf, pbuf);
+ encode_base64(buf64, buf);
+ fprintf(fp, "%s\n", buf64);
+ }
+ }
+ if (strlen(username) > 0) {
+ sprintf(buf, "%s|%s|%s|%s|",
+ host, port, username, password);
+ encode_base64(buf64, buf);
+ fprintf(fp, "%s\n", buf64);
+ }
+ fclose(oldfp);
+ fclose(fp);
+ chmod(pwfile, 0600);
+}
+
+
+/*
+ * Set the password if the user wants to, clear it otherwise
+ */
+void offer_to_remember_password(
+ char *host,
+ char *port,
+ char *username,
+ char *password) {
+
+ if (rc_remember_passwords) {
+ if (boolprompt("Remember username/password for this site", 0)) {
+ set_stored_password(host, port, username, password);
+ }
+ else {
+ set_stored_password(host, port, "", "");
+ }
+ }
+}
--- /dev/null
+void determine_pwfilename(char *);
+void get_stored_password(
+ char *host,
+ char *port,
+ char *username,
+ char *password);
+void set_stored_password(
+ char *host,
+ char *port,
+ char *username,
+ char *password);
+void offer_to_remember_password(
+ char *host,
+ char *port,
+ char *username,
+ char *password);
int rc_allow_attachments;
int rc_display_message_numbers;
int rc_force_mail_prompts;
+int rc_remember_passwords;
int rc_ansi_color;
int num_urls = 0;
char urls[MAXURLS][256];
rc_floor_mode = 0;
rc_exp_beep = 1;
rc_allow_attachments = 0;
+ rc_remember_passwords = 0;
strcpy(rc_exp_cmd, "");
rc_display_message_numbers = 0;
rc_force_mail_prompts = 0;
while ((strlen(buf) > 0) ? (isspace(buf[strlen(buf) - 1])) : 0)
buf[strlen(buf) - 1] = 0;
- if (!struncmp(buf, "editor=", 7))
+ if (!strncasecmp(buf, "editor=", 7))
strcpy(editor_path, &buf[7]);
- if (!struncmp(buf, "printcmd=", 9))
+ if (!strncasecmp(buf, "printcmd=", 9))
strcpy(printcmd, &buf[9]);
- if (!struncmp(buf, "expcmd=", 7))
+ if (!strncasecmp(buf, "expcmd=", 7))
strcpy(rc_exp_cmd, &buf[7]);
- if (!struncmp(buf, "local_screen_dimensions=", 24))
+ if (!strncasecmp(buf, "local_screen_dimensions=", 24))
have_xterm = (char) atoi(&buf[24]);
- if (!struncmp(buf, "use_floors=", 11)) {
- if (!strucmp(&buf[11], "yes"))
+ if (!strncasecmp(buf, "use_floors=", 11)) {
+ if (!strcasecmp(&buf[11], "yes"))
rc_floor_mode = RC_YES;
- if (!strucmp(&buf[11], "no"))
+ if (!strcasecmp(&buf[11], "no"))
rc_floor_mode = RC_NO;
- if (!strucmp(&buf[11], "default"))
+ if (!strcasecmp(&buf[11], "default"))
rc_floor_mode = RC_DEFAULT;
}
- if (!struncmp(buf, "beep=", 5)) {
+ if (!strncasecmp(buf, "beep=", 5)) {
rc_exp_beep = atoi(&buf[5]);
}
- if (!struncmp(buf, "allow_attachments=", 18)) {
+ if (!strncasecmp(buf, "allow_attachments=", 18)) {
rc_allow_attachments = atoi(&buf[18]);
}
- if (!struncmp(buf, "display_message_numbers=", 24)) {
+ if (!strncasecmp(buf, "remember_passwords=", 19)) {
+ rc_remember_passwords = atoi(&buf[19]);
+ }
+ if (!strncasecmp(buf, "display_message_numbers=", 24)) {
rc_display_message_numbers = atoi(&buf[24]);
}
- if (!struncmp(buf, "force_mail_prompts=", 19)) {
+ if (!strncasecmp(buf, "force_mail_prompts=", 19)) {
rc_force_mail_prompts = atoi(&buf[19]);
}
- if (!struncmp(buf, "ansi_color=", 11)) {
- if (!struncmp(&buf[11], "on", 2))
+ if (!strncasecmp(buf, "ansi_color=", 11)) {
+ if (!strncasecmp(&buf[11], "on", 2))
rc_ansi_color = 1;
- if (!struncmp(&buf[11], "auto", 4))
+ if (!strncasecmp(&buf[11], "auto", 4))
rc_ansi_color = 2; /* autodetect */
- if (!struncmp(&buf[11], "user", 4))
+ if (!strncasecmp(&buf[11], "user", 4))
rc_ansi_color = 3; /* user config */
}
- if (!struncmp(buf, "username=", 9))
+ if (!strncasecmp(buf, "username=", 9))
strcpy(rc_username, &buf[9]);
- if (!struncmp(buf, "password=", 9))
+ if (!strncasecmp(buf, "password=", 9))
strcpy(rc_password, &buf[9]);
- if (!struncmp(buf, "urlcmd=", 7))
+ if (!strncasecmp(buf, "urlcmd=", 7))
strcpy(rc_url_cmd, &buf[7]);
- if (!struncmp(buf, "cmd=", 4)) {
+ if (!strncasecmp(buf, "cmd=", 4)) {
strcpy(buf, &buf[4]);
cptr = (struct citcmd *) malloc(sizeof(struct citcmd));
}
}
- if ( (!struncmp(buffer, "http://", 7))
- || (!struncmp(buffer, "ftp://", 6)) ) {
+ if ( (!strncasecmp(buffer, "http://", 7))
+ || (!strncasecmp(buffer, "ftp://", 6)) ) {
safestrncpy(urls[num_urls], buffer, 255);
for (a=0; a<strlen(urls[num_urls]); ++a) {
b = urls[num_urls][a];
extern char urls[MAXURLS][256];
extern char rc_url_cmd[256];
extern int lines_printed;
+extern int rc_remember_passwords;
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror)
+AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
dnl Now check for pthreads -- set up variables so that the compiler will be run
dnl with proper flags for pthread programs
/* $Id$ */
-void attach_to_server(int argc, char **argv);
+void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf);
extern int server_is_local;
int getsockfd(void);
char serv_getc(void);
*
*/
-#define UDS "citadel unix domain socket type of thing"
+#define UDS "_UDS_"
#define DEFAULT_HOST UDS
#define DEFAULT_PORT "citadel"
/*
* attach to server
*/
-void attach_to_server(int argc, char **argv)
+void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf)
{
int a;
char cithost[256];
if (!strcmp(cithost, UDS)) {
sprintf(sockpath, "%s/citadel.socket", BBSDIR);
serv_sock = uds_connectsock(sockpath);
+ strcpy(hostbuf, cithost);
+ strcpy(portbuf, sockpath);
return;
}
/* if not using a SOCKS proxy server, make the connection directly */
if (strlen(socks4) == 0) {
serv_sock = connectsock(cithost, citport, "tcp");
+ strcpy(hostbuf, cithost);
+ strcpy(portbuf, citport);
return;
}
/* if using SOCKS, connect first to the proxy... */
};
void sttybbs(int cmd);
-int struncmp(char *lstr, char *rstr, int len);
int fmout(int width, FILE *fp, char pagin, int height, int starting_lp, char subst);
int haschar(char *st, int ch);
int checkpagin(int lp, int pagin, int height);
return(0);
}
- while(serv_gets(buf), struncmp(buf,"text",4)) {
- if (!struncmp(buf,"nhdr=yes",8)) nhdr=1;
- if (!struncmp(buf,"from=",5)) {
+ while(serv_gets(buf), strncasecmp(buf,"text",4)) {
+ if (!strncasecmp(buf,"nhdr=yes",8)) nhdr=1;
+ if (!strncasecmp(buf,"from=",5)) {
strcpy(from,&buf[5]);
}
if (nhdr==1) buf[0]='_';
- if (!struncmp(buf,"type=",5))
+ if (!strncasecmp(buf,"type=",5))
format_type=atoi(&buf[5]);
- if ((!struncmp(buf,"msgn=",5))&&(rc_display_message_numbers)) {
+ if ((!strncasecmp(buf,"msgn=",5))&&(rc_display_message_numbers)) {
color(DIM_WHITE);
printf("[");
color(BRIGHT_WHITE);
color(DIM_WHITE);
printf("] ");
}
- if (!struncmp(buf,"from=",5)) {
+ if (!strncasecmp(buf,"from=",5)) {
color(DIM_WHITE);
printf("from ");
color(BRIGHT_CYAN);
printf("%s ",&buf[5]);
}
- if (!struncmp(buf,"subj=",5))
+ if (!strncasecmp(buf,"subj=",5))
strcpy(m_subject,&buf[5]);
- if (!struncmp(buf,"rfca=",5)) {
+ if (!strncasecmp(buf,"rfca=",5)) {
safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
color(DIM_WHITE);
printf("<");
color(DIM_WHITE);
printf("> ");
}
- if ((!struncmp(buf,"hnod=",5))
- && (strucmp(&buf[5],serv_info.serv_humannode))
+ if ((!strncasecmp(buf,"hnod=",5))
+ && (strcasecmp(&buf[5],serv_info.serv_humannode))
&& (strlen(rfca) == 0) ) {
color(DIM_WHITE);
printf("(");
color(DIM_WHITE);
printf(") ");
}
- if ((!struncmp(buf,"room=",5))
- && (strucmp(&buf[5],room_name))
+ if ((!strncasecmp(buf,"room=",5))
+ && (strcasecmp(&buf[5],room_name))
&& (strlen(rfca) == 0)) {
color(DIM_WHITE);
printf("in ");
printf("%s> ",&buf[5]);
}
- if (!struncmp(buf,"node=",5)) {
+ if (!strncasecmp(buf,"node=",5)) {
safestrncpy(node, &buf[5], sizeof(buf) - 5);
if ( (room_flags&QR_NETWORK)
- || ((strucmp(&buf[5],serv_info.serv_nodename)
- &&(strucmp(&buf[5],serv_info.serv_fqdn)))) )
+ || ((strcasecmp(&buf[5],serv_info.serv_nodename)
+ &&(strcasecmp(&buf[5],serv_info.serv_fqdn)))) )
{
if (strlen(rfca) == 0) {
color(DIM_WHITE);
}
}
- if (!struncmp(buf,"rcpt=",5)) {
+ if (!strncasecmp(buf,"rcpt=",5)) {
color(DIM_WHITE);
printf("to ");
color(BRIGHT_CYAN);
printf("%s ",&buf[5]);
}
- if (!struncmp(buf,"time=",5)) {
+ if (!strncasecmp(buf,"time=",5)) {
fmt_date(now, atol(&buf[5]));
printf("%s ", now);
}
buf[strlen(buf)] = a;
if ( strlen(buf) >= strlen(srch_str) ) {
ptr=&buf[strlen(buf)-strlen(srch_str)];
- if (!struncmp(ptr,srch_str,strlen(srch_str))) {
+ if (!strncasecmp(ptr,srch_str,strlen(srch_str))) {
strcpy(ptr,rplc_str);
++substitutions;
}
int yesno(void);
void strprompt(char *prompt, char *str, int len);
void newprompt(char *prompt, char *str, int len);
-int struncmp(char *lstr, char *rstr, int len);
void dotgoto(char *towhere, int display_name);
void serv_read(char *buf, int bytes);
void formout(char *name);
safestrncpy(floorstr,floorlist[rfloor],sizeof floorstr);
strprompt("Which floor",floorstr,256);
for (a=0; a<128; ++a) {
- if (!strucmp(floorstr,&floorlist[a][0]))
+ if (!strcasecmp(floorstr,&floorlist[a][0]))
newfloor = a;
- if ((newfloor<0)&&(!struncmp(floorstr,
+ if ((newfloor<0)&&(!strncasecmp(floorstr,
&floorlist[a][0],strlen(floorstr))))
newfloor = a;
if ((newfloor<0)&&(pattern(&floorlist[a][0],
/* Ask about the room aide */
do {
strprompt("Room aide (or 'none')",raide,29);
- if (!strucmp(raide,"none")) {
+ if (!strcasecmp(raide,"none")) {
strcpy(raide,"");
strcpy(buf,"200");
}
}
} while(buf[0]!='2');
- if (!strucmp(raide,"none")) strcpy(raide,"");
+ if (!strcasecmp(raide,"none")) strcpy(raide,"");
/* Angels and demons dancing in my head... */
newprompt("Delete which floor? ",buf,255);
if (strlen(buf)==0) return;
for (a=0; a<128; ++a)
- if (!strucmp(&floorlist[a][0],buf))
+ if (!strcasecmp(&floorlist[a][0],buf))
floornum_to_delete = a;
if (floornum_to_delete < 0) {
printf("No such floor. Select one of:\n");
extern char rc_floor_mode;
extern int rc_ansi_color;
-int struncmp(char *lstr, char *rstr, int len)
-{
- int pos = 0;
- char lc,rc;
- while (pos<len) {
- lc=tolower(lstr[pos]);
- rc=tolower(rstr[pos]);
- if ((lc==0)&&(rc==0)) return(0);
- if (lc<rc) return(-1);
- if (lc>rc) return(1);
- pos=pos+1;
- }
- return(0);
- }
-
-
-
void back(int spaces) /* Destructive backspace */
{
-int a;
+ int a;
for (a=1; a<=spaces; ++a) {
putc(8,stdout); putc(32,stdout); putc(8,stdout);
}
{
int a,b;
for (a=0; a<strlen(search); ++a)
- { b=struncmp(&search[a],patn,strlen(patn));
+ { b=strncasecmp(&search[a],patn,strlen(patn));
if (b==0) return(b);
}
return(-1);
* Connect sendcommand to the Citadel server running on this computer.
*/
void np_attach_to_server(void) {
+ char hostbuf[256], portbuf[256];
char buf[256];
char portname[8];
- char *args[] = { "sendcommand", "localhost", NULL, NULL } ;
+ char *args[] = { "sendcommand", NULL, NULL, NULL } ;
fprintf(stderr, "Attaching to server...\n");
sprintf(portname, "%d", config.c_port_number);
args[2] = portname;
- attach_to_server(3, args);
+ attach_to_server(3, args, hostbuf, portbuf);
serv_gets(buf);
fprintf(stderr, "%s\n",&buf[4]);
sprintf(buf,"IPGM %d", config.c_ipgm_secret);
int main(int argc, char **argv)
{
+ char hostbuf[256], portbuf[256];
time_t LogTime, now;
unsigned int LogType;
char LogName[256];
fakeargs[2] = malloc(64);
sprintf(fakeargs[2], "%d", config.c_port_number);
fakeargs[3] = NULL;
- attach_to_server(3, fakeargs);
+ attach_to_server(3, fakeargs, hostbuf, portbuf);
free(fakeargs[2]);
serv_gets(buf);
if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
* $Id$
*/
+#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char *safestrncpy(char *dest, const char *src, size_t n)
{
- if (dest == NULL || src == NULL)
- {
- fprintf(stderr, "safestrncpy: NULL argument\n");
- abort();
- }
- strncpy(dest, src, n);
- dest[n - 1] = 0;
- return dest;
+ if (dest == NULL || src == NULL) {
+ fprintf(stderr, "safestrncpy: NULL argument\n");
+ abort();
+ }
+ strncpy(dest, src, n);
+ dest[n - 1] = 0;
+ return dest;
}
+
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(char *lstr, char *rstr, int len)
+{
+ int pos = 0;
+ char lc,rc;
+ while (pos<len) {
+ lc=tolower(lstr[pos]);
+ rc=tolower(rstr[pos]);
+ if ((lc==0)&&(rc==0)) return(0);
+ if (lc<rc) return(-1);
+ if (lc>rc) return(1);
+ pos=pos+1;
+ }
+ return(0);
+}
+#endif
+
+
+
/*
* num_tokens() - discover number of parameters/tokens in a string
*/
void remove_token(char *source, int parmnum, char separator);
void fmt_date(char *buf, time_t thetime);
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(char *, char *, int)
+#endif
+#ifndef HAVE_STRCASECMP
+#define strcasecmp(x,y) strncasecmp(x,y,INT_MAX);
+#endif
+
#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|')
#define num_parms(source) num_tokens(source, '|')
int main(int argc, char **argv)
{
char buf[256];
+ char hostbuf[256], portbuf[256];
- attach_to_server(argc,argv);
+ attach_to_server(argc, argv, hostbuf, portbuf);
serv_gets(buf);
if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
int www = 0;
int s_pid = 0;
int my_pid = 0;
+ char hostbuf[256];
+ char portbuf[256];
char s_user[256];
char s_room[256];
char s_host[256];
*/
if (getenv("REQUEST_METHOD") != NULL) www = 1;
- attach_to_server(argc,argv);
+ attach_to_server(argc,argv, hostbuf, portbuf);
serv_gets(buf);
if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);