breaking more things
This commit is contained in:
parent
aed06c9dec
commit
8f5db62a49
4
creds.txt
Normal file
4
creds.txt
Normal file
@ -0,0 +1,4 @@
|
||||
username=probotic
|
||||
server=irc.rizon.net
|
||||
port=6667
|
||||
channel=#/g/chad
|
@ -12,7 +12,7 @@ typedef struct
|
||||
extern creds_t creds;
|
||||
|
||||
DECL char * slurp(const char * fn);
|
||||
DECL int parse_pair(char * const buf, size_t const len);
|
||||
DECL int parse_pair(char const * buf, size_t const len);
|
||||
DECL void parse_command(char * cmd);
|
||||
DECL void clean_creds(void);
|
||||
|
||||
|
@ -84,9 +84,13 @@ main (int argc,
|
||||
{ creds.password = argv[1]; }
|
||||
else if (strcmp(arg, "auth") == 0)
|
||||
{
|
||||
authfile = argv[1];
|
||||
buf = slurp(authfile);
|
||||
if (!buf)
|
||||
{ PERROR(1); }
|
||||
{
|
||||
fprintf(stderr, "file: %s\n", authfile);
|
||||
PERROR(1);
|
||||
}
|
||||
|
||||
authfile = argv[1];
|
||||
if (parse_pair(buf, strlen(buf)))
|
||||
|
16
src/parse.c
16
src/parse.c
@ -115,8 +115,11 @@ parse_pair(char const * buf, size_t const len)
|
||||
/* X macro for handling this data may be better */
|
||||
for (f = 0; f < ARRAY_SIZE(cred_names[i]); ++i)
|
||||
{
|
||||
fprintf(stderr, "ARRAY_SIZE(cred_names[i]) = %d\n",
|
||||
ARRAY_SIZE(cred_names[i]));
|
||||
if (strncmp(buf, cred_names[i], ARRAY_SIZE(cred_names[i])) == 0)
|
||||
{
|
||||
buf += i;
|
||||
x = i;
|
||||
while (i != '\0' ||
|
||||
i != '\n')
|
||||
@ -124,15 +127,14 @@ parse_pair(char const * buf, size_t const len)
|
||||
x = i - x;
|
||||
switch (i)
|
||||
{
|
||||
case USERNAME: creds.username = strndup(buf+x); break;
|
||||
case PASSWORD: creds.password = strndup(buf+x); break;
|
||||
case CHANNEL: creds.channel = strndup(buf+x); break;
|
||||
case SERVER: creds.server = strndup(buf+x); break;
|
||||
case PORT: creds.port = atoi(buf+x); break;
|
||||
case USERNAME: creds.username = strndup(buf,x); break;
|
||||
case PASSWORD: creds.password = strndup(buf,x); break;
|
||||
case CHANNEL: creds.channel = strndup(buf,x); break;
|
||||
case SERVER: creds.server = strndup(buf,x); break;
|
||||
case PORT: creds.port = atoi(buf); break;
|
||||
}
|
||||
while (i != '\0' ||
|
||||
i != '\n')
|
||||
buf[i] = '\0';
|
||||
i != '\n');
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else
|
||||
|
Reference in New Issue
Block a user