From fcc7493bb9e574cc9d004205eb874f5838240732 Mon Sep 17 00:00:00 2001 From: Emil Date: Fri, 4 Aug 2023 07:38:39 -0600 Subject: [PATCH] Remove shit --- bootstrap/bootstrap.sh | 2 +- include/parse.h | 1 - src/main.c | 3 --- src/parse.c | 58 ++++---------------------------------------------- 4 files changed, 5 insertions(+), 59 deletions(-) diff --git a/bootstrap/bootstrap.sh b/bootstrap/bootstrap.sh index 7db68f3..27205c2 100755 --- a/bootstrap/bootstrap.sh +++ b/bootstrap/bootstrap.sh @@ -1,5 +1,5 @@ #!/bin/sh DBFILE=probotic_data.sqlite -rm "$DBFILE" +rm -f "$DBFILE" sqlite3 "$DBFILE" -init bootstrap.sql -line '.quit' diff --git a/include/parse.h b/include/parse.h index 0e1213b..e4bf83f 100644 --- a/include/parse.h +++ b/include/parse.h @@ -20,7 +20,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); diff --git a/src/main.c b/src/main.c index 7c992f6..aca5a17 100644 --- a/src/main.c +++ b/src/main.c @@ -82,9 +82,6 @@ main (int argc, { free(creds.username); creds.username = strdup(argv[1]); } else if (strcmp(arg, "password") == 0) { free(creds.password); creds.password = strdup(argv[1]); } - else if (strcmp(arg, "admin") == 0) - /* argv isn't constant :>, this can make even valgrind shutter */ - { free(creds.admins); parse_admins(argv[1]); } else if (strcmp(arg, "auth") == 0) { authfile = argv[1]; diff --git a/src/parse.c b/src/parse.c index 43b0434..91f6eb6 100644 --- a/src/parse.c +++ b/src/parse.c @@ -27,8 +27,7 @@ enum cred_names_map PASSWORD, CHANNEL, SERVER, - PORT, - ADMINS + PORT }; VARDECL char const * cred_names[] = @@ -38,8 +37,7 @@ VARDECL char const * cred_names[] = "password", "channel", "server", - "port", - "admins" + "port" }; VARDECL size_t const cred_names_len[] = @@ -214,7 +212,6 @@ DECL int parse_pair(char const * buf, size_t len) { size_t i, f, x; - char * adm; /* fprintf(stderr, "ENT len:%ld buf:%sEOF\n", len, buf); */ for (i = 0; buf[i] && i < len; ++i) @@ -247,10 +244,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: adm = strndup(buf,x); - parse_admins(adm); - free(adm); - break; } if (x + 2 < len) { buf += x + 1; } @@ -265,54 +258,11 @@ parse_pair(char const * buf, size_t len) return 0; } -/* FIXME MAKE parse_admins constant! */ -/* 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; - - creds.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; - creds.admins = realloc(creds.admins, current_array_size); - } - - creds.admins[i - 1] = strdup(token); - } - - /* set up array end marker for proper clean-up later */ - if (i + 1 > current_array_size) - { - creds.admins = realloc(creds.admins, current_array_size + 1); - } - creds.admins[i] = NULL; -} - DECL int is_admin(char const * user) { - /* No Gods or Kings, Only Man */ - if (creds.admins == NULL) - { return 0; } - - for (size_t i = 0; creds.admins[i]; ++i) - { - if (!strcmp(creds.admins[i], user)) - { return 1; } - } - - return 0; + /* No Gods or Kings, Only size_t */ + return 1; } void