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;
|
extern creds_t creds;
|
||||||
|
|
||||||
DECL char * slurp(const char * fn);
|
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 parse_command(char * cmd);
|
||||||
DECL void clean_creds(void);
|
DECL void clean_creds(void);
|
||||||
|
|
||||||
|
@ -84,9 +84,13 @@ main (int argc,
|
|||||||
{ creds.password = argv[1]; }
|
{ creds.password = argv[1]; }
|
||||||
else if (strcmp(arg, "auth") == 0)
|
else if (strcmp(arg, "auth") == 0)
|
||||||
{
|
{
|
||||||
|
authfile = argv[1];
|
||||||
buf = slurp(authfile);
|
buf = slurp(authfile);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{ PERROR(1); }
|
{
|
||||||
|
fprintf(stderr, "file: %s\n", authfile);
|
||||||
|
PERROR(1);
|
||||||
|
}
|
||||||
|
|
||||||
authfile = argv[1];
|
authfile = argv[1];
|
||||||
if (parse_pair(buf, strlen(buf)))
|
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 */
|
/* X macro for handling this data may be better */
|
||||||
for (f = 0; f < ARRAY_SIZE(cred_names[i]); ++i)
|
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)
|
if (strncmp(buf, cred_names[i], ARRAY_SIZE(cred_names[i])) == 0)
|
||||||
{
|
{
|
||||||
|
buf += i;
|
||||||
x = i;
|
x = i;
|
||||||
while (i != '\0' ||
|
while (i != '\0' ||
|
||||||
i != '\n')
|
i != '\n')
|
||||||
@ -124,15 +127,14 @@ parse_pair(char const * buf, size_t const len)
|
|||||||
x = i - x;
|
x = i - x;
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case USERNAME: creds.username = strndup(buf+x); break;
|
case USERNAME: creds.username = strndup(buf,x); break;
|
||||||
case PASSWORD: creds.password = strndup(buf+x); break;
|
case PASSWORD: creds.password = strndup(buf,x); break;
|
||||||
case CHANNEL: creds.channel = strndup(buf+x); break;
|
case CHANNEL: creds.channel = strndup(buf,x); break;
|
||||||
case SERVER: creds.server = strndup(buf+x); break;
|
case SERVER: creds.server = strndup(buf,x); break;
|
||||||
case PORT: creds.port = atoi(buf+x); break;
|
case PORT: creds.port = atoi(buf); break;
|
||||||
}
|
}
|
||||||
while (i != '\0' ||
|
while (i != '\0' ||
|
||||||
i != '\n')
|
i != '\n');
|
||||||
buf[i] = '\0';
|
|
||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user