Compare commits

..

No commits in common. "7102569940cc6e7f84aed7aea47ec16ced53cbef" and "c31808e8c405983ca6148d03350ee178ffbce005" have entirely different histories.

2 changed files with 4 additions and 45 deletions

View File

@ -16,7 +16,6 @@ DECL char * raw(char const * const sql);
DECL char * remind(char * who);
DECL char * slurp(char const * fn);
DECL int is_admin(char const * user);
DECL void parse_admins(char * admin_string);
DECL int parse_pair(char const * buf, size_t const len);
DECL void creds_free_password(void);
DECL void creds_free_rest(void);

View File

@ -26,7 +26,7 @@
#include "help.h"
#include "parse.h"
#define PARAMS_COUNT 6
#define PARAMS_COUNT 5
enum cred_param_ids_e
{
@ -34,8 +34,7 @@ enum cred_param_ids_e
PASSWORD,
CHANNEL,
SERVER,
PORT,
ADMINS
PORT
};
char const * cred_names[] =
@ -44,8 +43,7 @@ char const * cred_names[] =
"password",
"channel",
"server",
"port",
"admins"
"port"
};
size_t const cred_names_len[] =
@ -54,8 +52,7 @@ size_t const cred_names_len[] =
8,
7,
6,
4,
6
4
};
creds_t creds = {0};
@ -192,10 +189,6 @@ parse_pair(char const * buf, size_t len)
case CHANNEL: creds.channel = strndup(buf,x); break;
case SERVER: creds.server = strndup(buf,x); break;
case PORT: creds.port = atoi(buf); break;
case ADMINS:
parse_admins(strndup(buf,x));
break;
}
if (x + 2 < len)
{ buf += x + 1; }
@ -210,39 +203,6 @@ parse_pair(char const * buf, size_t len)
return 0;
}
/* WARNING: admin_string WILL be changed */
DECL void
parse_admins(char * admin_string)
{
#define ADMIN_LIST_INIT_SIZE 8
/* prealloc with 8 */
size_t current_array_size = ADMIN_LIST_INIT_SIZE;
size_t i = 0;
char * token = NULL;
admins = calloc(ADMIN_LIST_INIT_SIZE, sizeof(char *));
while ((token = strtok(admin_string, " ")))
{
if (++i > current_array_size)
{
/* double the space */
current_array_size *= 2;
admins = realloc(admins, current_array_size);
}
admins[i - 1] = strdup(token);
}
/* set up array end marker for proper clean-up later */
if (i + 1 > current_array_size)
{
admins = realloc(admins, current_array_size + 1);
}
admins[i] = NULL;
}
DECL int
is_admin(char const * user)
{