[mw-devel] MW3 r1143 - trunk/src
welshbyte at sucs.org
welshbyte at sucs.org
Sun Jan 3 20:41:14 GMT 2010
Author: welshbyte
Date: 2010-01-03 20:41:14 +0000 (Sun, 03 Jan 2010)
New Revision: 1143
Modified:
trunk/src/Parse.c
trunk/src/bb.h
trunk/src/colour.c
trunk/src/main.c
trunk/src/mesg.c
trunk/src/newmain.c
trunk/src/tidyup.c
Log:
- Add COLOURDIR and remove/tweak some snprintf's
- Remove some char defines where they duplicate char* defines and just deref the string ones instead
- More use of compile-time string concatenation
Modified: trunk/src/Parse.c
===================================================================
--- trunk/src/Parse.c 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/Parse.c 2010-01-03 20:41:14 UTC (rev 1143)
@@ -267,11 +267,11 @@
}
printf("Command '%s' not found.",dowhat);
if (backup==chattable)
- printf(" Use %chelp for a list of commands.\n", CMD_TALK_CHAR);
+ printf(" Use "CMD_TALK_STR"help for a list of commands.\n");
else if (!cm_flags(user->chatmode, CM_ONCHAT, CM_MODE_ALL))
printf(" Use help for a list of commands.\n");
else
- printf(" Use %chelp for a list of commands.\n", CMD_BOARD_CHAR);
+ printf(" Use "CMD_BOARD_STR"help for a list of commands.\n");
if (args!=NULL) free(args);
return -1; /* Beats me */
}
Modified: trunk/src/bb.h
===================================================================
--- trunk/src/bb.h 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/bb.h 2010-01-03 20:41:14 UTC (rev 1143)
@@ -24,6 +24,7 @@
#define MSGDIR "/var/run/mw"
#endif
+#define COLOURDIR HOMEPATH"/colour"
#define LOGFILE LOGDIR"/log.bb"
#define LOGIN_BANNER "login.banner"
#define DEVEL_BANNER "login.banner.devel"
@@ -50,11 +51,8 @@
#define TRUE !FALSE
#define SETALLLONG 0xFFFFFFFF
-#define CMD_BOARD_CHAR '!'
#define CMD_BOARD_STR "!"
-#define CMD_TALK_CHAR '.'
#define CMD_TALK_STR "."
-#define CMD_SCRIPT_CHAR ','
#define CMD_SCRIPT_STR ","
#define TIMEOUT 600 /* seconds */
Modified: trunk/src/colour.c
===================================================================
--- trunk/src/colour.c 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/colour.c 2010-01-03 20:41:14 UTC (rev 1143)
@@ -176,13 +176,13 @@
for (i=0;i<COLOUR_LIMIT;i++) colour_chart[i]=NULL;
- snprintf(path, 1023, "%s/colour/%d.col", HOMEPATH, user->colour);
+ snprintf(path, 1023, COLOURDIR"/%d.col", user->colour);
if (access(path, R_OK))
{
printf("Error loading colour scheme %d.\n", user->colour);
printf("Changing to default scheme.\n");
user->colour=0;
- snprintf(path, 1023, "%s/colour/%d.col", HOMEPATH, user->colour);
+ snprintf(path, 1023, COLOURDIR"/%d.col", user->colour);
}
colour_load(path, 1);
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/main.c 2010-01-03 20:41:14 UTC (rev 1143)
@@ -824,18 +824,18 @@
}
if (cm_flags(user->chatmode,CM_ONCHAT,CM_MODE_ANY))
{
- if (comm[0]==CMD_BOARD_CHAR)
+ if (comm[0]==*CMD_BOARD_STR)
{
set_rights();
DoCommand(&comm[1], table);
set_talk_rights();
}else
- if (comm[0]==CMD_TALK_CHAR)
+ if (comm[0]==*CMD_TALK_STR)
{
set_talk_rights();
DoCommand(&comm[1], chattable);
}else
- if (comm[0]==CMD_SCRIPT_CHAR && cp_flags(user->chatprivs,CP_SCRIPT,CM_MODE_ANY))
+ if (comm[0]==*CMD_SCRIPT_STR && cp_flags(user->chatprivs,CP_SCRIPT,CM_MODE_ANY))
{
set_talk_rights();
DoScript(&comm[1]);
@@ -857,7 +857,7 @@
}else
{
set_rights();
- if (comm[0]==CMD_BOARD_CHAR)
+ if (comm[0]==*CMD_BOARD_STR)
DoCommand(&comm[1], table);
else
DoCommand(comm, table);
@@ -1545,21 +1545,21 @@
oldrights=rights;
if (cm_flags(user->chatmode,CM_ONCHAT,CM_MODE_ANY))
{
- if (rl_line_buffer[0]==CMD_BOARD_CHAR)
+ if (rl_line_buffer[0]==*CMD_BOARD_STR)
{
strcpy(line,&rl_line_buffer[1]);
mode=0;
tct = table;
set_rights();
}else
- if (rl_line_buffer[0]==CMD_TALK_CHAR)
+ if (rl_line_buffer[0]==*CMD_TALK_STR)
{
strcpy(line,&rl_line_buffer[1]);
mode=1;
tct = chattable;
set_talk_rights();
}else
- if (rl_line_buffer[0]==CMD_SCRIPT_CHAR && cp_flags(user->chatprivs,CP_SCRIPT,CM_MODE_ANY))
+ if (rl_line_buffer[0]==*CMD_SCRIPT_STR && cp_flags(user->chatprivs,CP_SCRIPT,CM_MODE_ANY))
{
strcpy(line, &rl_line_buffer[1]);
mode=2;
Modified: trunk/src/mesg.c
===================================================================
--- trunk/src/mesg.c 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/mesg.c 2010-01-03 20:41:14 UTC (rev 1143)
@@ -14,7 +14,7 @@
char *get_pipe_name(int pid)
{
static char fullpath[MAXTEXTLENGTH];
- snprintf(fullpath,MAXTEXTLENGTH-1,"%s/bbs.%d",MSGDIR,pid);
+ snprintf(fullpath,MAXTEXTLENGTH-1,MSGDIR"/bbs.%d",pid);
return(fullpath);
}
Modified: trunk/src/newmain.c
===================================================================
--- trunk/src/newmain.c 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/newmain.c 2010-01-03 20:41:14 UTC (rev 1143)
@@ -204,13 +204,11 @@
if (!strcasecmp(argv[1], "list"))
{
- char path[1024];
DIR *d;
struct dirent *dd;
int count;
- snprintf(path, 1023, "%s/colour", HOMEPATH);
- if ((d=opendir(path))==NULL)
+ if ((d=opendir(COLOURDIR))==NULL)
{
printf(_("Error opening colour scheme list - %s\n"),strerror(errno));
return;
@@ -221,13 +219,14 @@
{
char *c, *fn;
FILE *ff;
+ char path[1024];
fn=strdup(dd->d_name);
c=strrchr(fn,'.');
if (c==NULL || strcmp(c,".col")) { free(fn); continue; }
*c=0;
- snprintf(path, 1023, "%s/colour/%s",HOMEPATH, dd->d_name);
+ snprintf(path, 1023, COLOURDIR"/%s", dd->d_name);
if ((ff=fopen(path,"r"))==NULL)
{
printf("%-3s: Error: %s\n", fn, strerror(errno));
@@ -254,7 +253,7 @@
char path[1024];
i=atoi(argv[1]);
- snprintf(path, 1023, "%s/colour/%d.col", HOMEPATH, i);
+ snprintf(path, 1023, COLOURDIR"/%d.col", i);
if (access(path, R_OK))
{
printf(_("ERROR: Cannot open colour scheme '%d'\n"),i);
Modified: trunk/src/tidyup.c
===================================================================
--- trunk/src/tidyup.c 2010-01-02 14:14:30 UTC (rev 1142)
+++ trunk/src/tidyup.c 2010-01-03 20:41:14 UTC (rev 1143)
@@ -61,7 +61,7 @@
}
/* open relevant folder index */
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,INDEX_END);
+ snprintf(fullpath,PATHSIZE-1,STATEDIR"/%s"INDEX_END,info.name);
if (access(fullpath,00))
{
printf("Folder %s not found.\n",info.name);
@@ -75,7 +75,7 @@
Lock_File(indexin);
/* open relevant folder text */
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,TEXT_END);
+ snprintf(fullpath,PATHSIZE-1,STATEDIR"/%s"TEXT_END,info.name);
if (access(fullpath,00))
{
printf("Folder %s text file not found.\n",info.name);
@@ -88,7 +88,7 @@
}
Lock_File(textin);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,INDEX_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,STATEDIR"/%s"INDEX_END NEW_END,info.name);
if ((indexout=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
{
perror(fullpath);
@@ -96,7 +96,7 @@
}
Lock_File(indexout);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,TEXT_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,STATEDIR"/%s"TEXT_END NEW_END,info.name);
if ((textout=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
{
perror(fullpath);
@@ -126,15 +126,15 @@
printf("Updating Real Folder...\n");
close(indexout);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,INDEX_END);
- snprintf(fullpath2,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,INDEX_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,STATEDIR"/%s"INDEX_END,info.name);
+ snprintf(fullpath2,PATHSIZE-1,STATEDIR"/%s"INDEX_END NEW_END,info.name);
if (rename(fullpath2,fullpath)) perror("rename");
Unlock_File(indexin);
close(indexin);
close(textout);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,TEXT_END);
- snprintf(fullpath2,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,TEXT_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,STATEDIR"/%s"TEXT_END,info.name);
+ snprintf(fullpath2,PATHSIZE-1,STATEDIR"/%s"TEXT_END NEW_END,info.name);
if (rename(fullpath2,fullpath)) perror("rename");
Unlock_File(textin);
close(textin);
More information about the mw-devel
mailing list