diff options
| author | erdgeist <> | 2006-01-26 18:40:30 +0000 |
|---|---|---|
| committer | erdgeist <> | 2006-01-26 18:40:30 +0000 |
| commit | 57689e698230030803c872072a03329fdd4fecc6 (patch) | |
| tree | b4f8671dbe04741be93091e99eb3c6aa81b9bebd /vchat-client.c | |
| parent | 4413fb15bec35744c06ac3cfce2ae2bfa6953ae1 (diff) | |
unsigned char tidy up, query mode
Diffstat (limited to 'vchat-client.c')
| -rwxr-xr-x | vchat-client.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/vchat-client.c b/vchat-client.c index d7d1998..2d50932 100755 --- a/vchat-client.c +++ b/vchat-client.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | #include "vchat.h" | 32 | #include "vchat.h" |
| 33 | 33 | ||
| 34 | /* version of this module */ | 34 | /* version of this module */ |
| 35 | unsigned char *vchat_cl_version = "$Id$"; | 35 | char *vchat_cl_version = "$Id$"; |
| 36 | 36 | ||
| 37 | /* externally used variables */ | 37 | /* externally used variables */ |
| 38 | /* we're logged in */ | 38 | /* we're logged in */ |
| @@ -40,7 +40,7 @@ unsigned int loggedin = 0; | |||
| 40 | /* we run as long as this is true */ | 40 | /* we run as long as this is true */ |
| 41 | unsigned int status = 1; | 41 | unsigned int status = 1; |
| 42 | /* error string to show after exit */ | 42 | /* error string to show after exit */ |
| 43 | unsigned char errstr[ERRSTRSIZE] = "\0"; | 43 | char errstr[ERRSTRSIZE] = "\0"; |
| 44 | 44 | ||
| 45 | /* locally global variables */ | 45 | /* locally global variables */ |
| 46 | /* our list of filedescriptors */ | 46 | /* our list of filedescriptors */ |
| @@ -52,12 +52,12 @@ static fd_set masterfds; | |||
| 52 | /* servers filedescriptor from vchat-protocol.c */ | 52 | /* servers filedescriptor from vchat-protocol.c */ |
| 53 | extern int serverfd; | 53 | extern int serverfd; |
| 54 | 54 | ||
| 55 | void setnoption (unsigned char *, unsigned char *); | 55 | void setnoption (char *, char *); |
| 56 | 56 | ||
| 57 | static void parsecfg(unsigned char *line) { | 57 | static void parsecfg(char *line) { |
| 58 | int bytes; | 58 | int bytes; |
| 59 | unsigned char *param=line; | 59 | char *param=line; |
| 60 | unsigned char *value=NULL; | 60 | char *value=NULL; |
| 61 | 61 | ||
| 62 | /* handle quotes value is empty, so wecan use it */ | 62 | /* handle quotes value is empty, so wecan use it */ |
| 63 | value = strchr(line,'#'); | 63 | value = strchr(line,'#'); |
| @@ -101,9 +101,9 @@ static void parsecfg(unsigned char *line) { | |||
| 101 | setnoption(param,value); | 101 | setnoption(param,value); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | static void parseformats(unsigned char *line) { | 104 | static void parseformats(char *line) { |
| 105 | int i; | 105 | int i; |
| 106 | unsigned char *tmp = NULL; | 106 | char *tmp = NULL; |
| 107 | 107 | ||
| 108 | /* read a format line from file, syntax is | 108 | /* read a format line from file, syntax is |
| 109 | FS_XXX = "formatstring" | 109 | FS_XXX = "formatstring" |
| @@ -117,7 +117,7 @@ static void parseformats(unsigned char *line) { | |||
| 117 | for (i = 0; formatstrings[i].formatstr; i++) | 117 | for (i = 0; formatstrings[i].formatstr; i++) |
| 118 | if (!strncasecmp(formatstrings[i].idstring, line, strlen( formatstrings[i].idstring) )) | 118 | if (!strncasecmp(formatstrings[i].idstring, line, strlen( formatstrings[i].idstring) )) |
| 119 | { | 119 | { |
| 120 | unsigned char *tail = line + strlen( formatstrings[i].idstring); | 120 | char *tail = line + strlen( formatstrings[i].idstring); |
| 121 | while( *tail==' ' || *tail=='\t') tail++; /* and skip whitespaces */ | 121 | while( *tail==' ' || *tail=='\t') tail++; /* and skip whitespaces */ |
| 122 | 122 | ||
| 123 | if( *tail++ == '=' ) | 123 | if( *tail++ == '=' ) |
| @@ -145,7 +145,7 @@ static void parseformats(unsigned char *line) { | |||
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | if ( stringends && ( (tmp = (unsigned char *)malloc( 1 + j )) != NULL ) ) | 148 | if ( stringends && ( (tmp = (char *)malloc( 1 + j )) != NULL ) ) |
| 149 | { | 149 | { |
| 150 | memcpy( tmp, tmpstr, k); | 150 | memcpy( tmp, tmpstr, k); |
| 151 | tmp[k-1]=0; | 151 | tmp[k-1]=0; |
| @@ -158,21 +158,21 @@ static void parseformats(unsigned char *line) { | |||
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | /* UNUSED uncomment if needed | 160 | /* UNUSED uncomment if needed |
| 161 | static void parseknownhosts(unsigned char *line) { | 161 | static void parseknownhosts(char *line) { |
| 162 | } | 162 | } |
| 163 | */ | 163 | */ |
| 164 | 164 | ||
| 165 | /* load config file */ | 165 | /* load config file */ |
| 166 | static void | 166 | static void |
| 167 | loadcfg (unsigned char *file,void (*lineparser) (unsigned char *)) | 167 | loadcfg (char *file,void (*lineparser) (char *)) |
| 168 | { | 168 | { |
| 169 | int fd; | 169 | int fd; |
| 170 | int bytes,bufoff=0; | 170 | int bytes,bufoff=0; |
| 171 | unsigned char *tmp = NULL; | 171 | char *tmp = NULL; |
| 172 | #define BUFSIZE 4096 | 172 | #define BUFSIZE 4096 |
| 173 | unsigned char buf[BUFSIZE]; /* data buffer */ | 173 | char buf[BUFSIZE]; /* data buffer */ |
| 174 | unsigned char *ltmp = buf; | 174 | char *ltmp = buf; |
| 175 | unsigned char *tildex = NULL; | 175 | char *tildex = NULL; |
| 176 | buf[BUFSIZE-1] = '\0'; /* sanity stop */ | 176 | buf[BUFSIZE-1] = '\0'; /* sanity stop */ |
| 177 | 177 | ||
| 178 | if (!file) return; | 178 | if (!file) return; |
| @@ -226,19 +226,19 @@ loadcfg (unsigned char *file,void (*lineparser) (unsigned char *)) | |||
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | void | 228 | void |
| 229 | loadconfig (unsigned char *file) | 229 | loadconfig (char *file) |
| 230 | { | 230 | { |
| 231 | loadcfg(file,parsecfg); | 231 | loadcfg(file,parsecfg); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | void | 234 | void |
| 235 | loadformats (unsigned char *file) | 235 | loadformats (char *file) |
| 236 | { | 236 | { |
| 237 | loadcfg(file,parseformats); | 237 | loadcfg(file,parseformats); |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | /* get-format-string */ | 240 | /* get-format-string */ |
| 241 | unsigned char * | 241 | char * |
| 242 | getformatstr (formtstr id) | 242 | getformatstr (formtstr id) |
| 243 | { | 243 | { |
| 244 | int i; | 244 | int i; |
| @@ -248,7 +248,7 @@ getformatstr (formtstr id) | |||
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | /* get-string-option, fetches *char-value of variable named by option */ | 250 | /* get-string-option, fetches *char-value of variable named by option */ |
| 251 | unsigned char * | 251 | char * |
| 252 | getstroption (confopt option) | 252 | getstroption (confopt option) |
| 253 | { | 253 | { |
| 254 | int i; | 254 | int i; |
| @@ -267,7 +267,7 @@ getstroption (confopt option) | |||
| 267 | 267 | ||
| 268 | /* set-string-option, puts *char-value to variable named by option */ | 268 | /* set-string-option, puts *char-value to variable named by option */ |
| 269 | void | 269 | void |
| 270 | setstroption (confopt option, unsigned char *string) | 270 | setstroption (confopt option, char *string) |
| 271 | { | 271 | { |
| 272 | int i; | 272 | int i; |
| 273 | #ifdef DEBUG | 273 | #ifdef DEBUG |
| @@ -288,7 +288,7 @@ setstroption (confopt option, unsigned char *string) | |||
| 288 | 288 | ||
| 289 | /* set-named-option, puts string to variable named by name */ | 289 | /* set-named-option, puts string to variable named by name */ |
| 290 | void | 290 | void |
| 291 | setnoption (unsigned char *name, unsigned char *string) | 291 | setnoption (char *name, char *string) |
| 292 | { | 292 | { |
| 293 | int i; | 293 | int i; |
| 294 | #ifdef DEBUG | 294 | #ifdef DEBUG |
| @@ -450,8 +450,8 @@ eventloop (void) | |||
| 450 | } | 450 | } |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | void usage(unsigned char *name) { | 453 | void usage( char *name) { |
| 454 | printf ("usage: %s [-C config-file] [-F formats] [-l] [-z] [-s host] [-p port] [-c channel] [-n nickname] [-k] [-K] [-L logfile]\n",name); | 454 | printf ("usage: %s [-C config-file] [-F formats] [-l] [-z] [-s host] [-p port] [-c channel] [-n nickname]\n",name); |
| 455 | puts (" -C load a second config-file, overriding the first one"); | 455 | puts (" -C load a second config-file, overriding the first one"); |
| 456 | puts (" -F load format strings (skins) from this file"); | 456 | puts (" -F load format strings (skins) from this file"); |
| 457 | puts (" -l local connect (no SSL + connects localhost:2323)"); | 457 | puts (" -l local connect (no SSL + connects localhost:2323)"); |
| @@ -464,9 +464,6 @@ void usage(unsigned char *name) { | |||
| 464 | else | 464 | else |
| 465 | puts (" -n set nickname"); | 465 | puts (" -n set nickname"); |
| 466 | printf (" -f set from (default \"%s\")\n",getstroption(CF_FROM)); | 466 | printf (" -f set from (default \"%s\")\n",getstroption(CF_FROM)); |
| 467 | puts (" -k keep autolog"); | ||
| 468 | puts (" -K don't keep autolog"); | ||
| 469 | printf (" -L use this file as logfile (default \"%s\")\n",getstroption(CF_LOGFILE)); | ||
| 470 | puts (" -h gives this help"); | 467 | puts (" -h gives this help"); |
| 471 | } | 468 | } |
| 472 | 469 | ||
| @@ -502,9 +499,6 @@ main (int argc, char **argv) | |||
| 502 | case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break; | 499 | case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break; |
| 503 | case 'n': setstroption(CF_NICK,optarg); break; | 500 | case 'n': setstroption(CF_NICK,optarg); break; |
| 504 | case 'f': setstroption(CF_FROM,optarg); break; | 501 | case 'f': setstroption(CF_FROM,optarg); break; |
| 505 | case 'k': setintoption(CF_KEEPLOG,1); break; | ||
| 506 | case 'K': setintoption(CF_KEEPLOG,0); break; | ||
| 507 | case 'L': setstroption(CF_LOGFILE,optarg); break; | ||
| 508 | case 'h': usage(argv[0]); exit(0); break; | 502 | case 'h': usage(argv[0]); exit(0); break; |
| 509 | default : usage(argv[0]); exit(1); | 503 | default : usage(argv[0]); exit(1); |
| 510 | } | 504 | } |
