From 935243d8b4ea992c50315f0c8fcb300365a5762d Mon Sep 17 00:00:00 2001 From: Emil Date: Fri, 4 Aug 2023 09:13:47 -0600 Subject: Initial commit --- include/api.h | 13 +++++++++++++ include/error.h | 22 ++++++++++++++++++++++ include/free.h | 22 ++++++++++++++++++++++ include/help.h | 9 +++++++++ include/irc.h | 14 ++++++++++++++ include/irccolors.h | 27 +++++++++++++++++++++++++++ include/parse.h | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 139 insertions(+) create mode 100644 include/api.h create mode 100644 include/error.h create mode 100644 include/free.h create mode 100644 include/help.h create mode 100644 include/irc.h create mode 100644 include/irccolors.h create mode 100644 include/parse.h (limited to 'include') diff --git a/include/api.h b/include/api.h new file mode 100644 index 0000000..3258311 --- /dev/null +++ b/include/api.h @@ -0,0 +1,13 @@ +#ifndef API_H_ + +VARDECL char const * db; + +DECL int api_init(void); +DECL void api_rope(void); +DECL void rope(void); +DECL char * remind(char * who); +DECL char * raw(char const * const sql); +DECL int is_no_assignment(char const * const who); + +#define API_H_ +#endif diff --git a/include/error.h b/include/error.h new file mode 100644 index 0000000..8595431 --- /dev/null +++ b/include/error.h @@ -0,0 +1,22 @@ +#ifndef ERROR_H_ + +#include + +#define ERR(ret,msg) \ + do { fputs(PROGN ": " msg "\n", stderr); return (ret); } while (0) + +#define ERRFMT(ret,fmt,...) \ + do { fprintf(stderr, PROGN ": " fmt "\n", __VA_ARGS__); return (ret); } while (0) + +#define PERROR(ret) \ + do { perror(PROGN); return (ret); } while (0) + +#define ERRMSG(msg) \ + fputs(msg "\n", stderr) + +#define DB_ERROR 100 +#define IRC_ERROR 200 +#define CREDS_ERROR 300 + +#define ERROR_H_ +#endif diff --git a/include/free.h b/include/free.h new file mode 100644 index 0000000..dba7441 --- /dev/null +++ b/include/free.h @@ -0,0 +1,22 @@ +#ifndef FREE_H_ + +#define FREE(obj) \ + do \ + { \ + free(obj); \ + (obj) = NULL; \ + } while (0) + +#define FULL_FREE(obj) \ + do \ + { \ + if ((obj)) \ + { \ + memset((obj), '\0', strlen((obj))); \ + FREE((obj)); \ + } \ + } while (0) + + +#define FREE_H_ +#endif diff --git a/include/help.h b/include/help.h new file mode 100644 index 0000000..a1cdac6 --- /dev/null +++ b/include/help.h @@ -0,0 +1,9 @@ +#ifndef HELP_H_ + +/* (((git))) */ + +VARDECL char const * help_msg; +VARDECL char const * fmsg; + +#define HELP_H_ +#endif diff --git a/include/irc.h b/include/irc.h new file mode 100644 index 0000000..7175220 --- /dev/null +++ b/include/irc.h @@ -0,0 +1,14 @@ +#ifndef IRC_H_ + +#include + +#include "parse.h" + +VARDECL irc_session_t * session; +VARDECL irc_callbacks_t callbacks; +VARDECL char * current_username; + +DECL int init(void); + +#define IRC_H_ +#endif diff --git a/include/irccolors.h b/include/irccolors.h new file mode 100644 index 0000000..f446a92 --- /dev/null +++ b/include/irccolors.h @@ -0,0 +1,27 @@ +#ifndef IRCCOLOR_H_ + +// Formatting macros +#define IRC_BOLD "[B]" +#define IRC_ITALIC "[I]" +#define IRC_UNDERLINE "[U]" + +// Color macros +#define IRC_BLACK "[COLOR=BLACK]" +#define IRC_DARKBLUE "[COLOR=DARKBLUE]" +#define IRC_DARKGREEN "[COLOR=DARKGREEN]" +#define IRC_RED "[COLOR=RED]" +#define IRC_BROWN "[COLOR=BROWN]" +#define IRC_PURPLE "[COLOR=PURPLE]" +#define IRC_OLIVE "[COLOR=OLIVE]" +#define IRC_YELLOW "[COLOR=YELLOW]" +#define IRC_GREEN "[COLOR=GREEN]" +#define IRC_TEAL "[COLOR=TEAL]" +#define IRC_CYAN "[COLOR=CYAN]" +#define IRC_BLUE "[COLOR=BLUE]" +#define IRC_MAGENTA "[COLOR=MAGENTA]" +#define IRC_DARKGRAY "[COLOR=DARKGRAY]" +#define IRC_LIGHTGRAY "[COLOR=LIGHTGRAY]" +#define IRC_STOP "[/COLOR]" + +#define IRCCOLOR_H_ +#endif diff --git a/include/parse.h b/include/parse.h new file mode 100644 index 0000000..e4bf83f --- /dev/null +++ b/include/parse.h @@ -0,0 +1,32 @@ +#ifndef CREDS_PARSER_H + +typedef struct +{ + size_t admin_count; + char * username; + char * password; + char * channel; + char * server; + char ** admins; + int port; +} creds_t; + +VARDECL creds_t creds; + +DECL char ** str_split(char const * s, char c); +DECL void split_clean(char ** split); +DECL char * dump(void); +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 int parse_pair(char const * buf, size_t const len); +DECL void creds_free_password(void); +DECL void creds_free_rest(void); +DECL void parse_command(char const * const cmd); +DECL void purge_assignments(char const * const who); +DECL void random_assign(char const * const sql); +DECL void set_repo(char const * const who, char const * const link); + +#define CREDS_PARSER_H +#endif -- cgit v1.2.3