lib*/*
Makefile~
dist/*
+*.*~
$(if $(MAKECMDGOALS),
$(eval BUILDGOALS := $(filter-out clean scrub purge uninstall,$(MAKECMDGOALS))),
$(eval BUILDGOALS := all))
-$(if $(or $(MISSING_TRG), $(and $(BUILDGOALS),$(filter $(OLDER_TIME),$(NEWEST_TRG_TIME)))),
+$(if $(and $(BUILDGOALS),$(or $(MISSING_TRG), $(filter $(OLDER_TIME),$(NEWEST_TRG_TIME)))),
$(if $(findstring n,$(MAKEFLAGS)),
$(SLANG_TRG):
$(SHELL_CMD)
# any internal modules, the developer may instead create a file with the same
# basename as the driver, but with the '.ld' suffix, which contains a space
# separated list of internal modules to link together during compilation
-$(eval DRIVER_MODULES += $(file <$(1:%.$2=%.ld)))
+$(eval DRIVER_LDVALS := $(file <$(1:%.$2=%.ld)))
+$(eval DRIVER_LFLAGS := $(filter -l%,$(DRIVER_LDVALS)))
+$(eval DRIVER_MODULES += $(filter-out -l%,$(DRIVER_LDVALS)))
# List of module archives to link together during compilation
$(eval DRIVER_ARCHIVES := $(DRIVER_MODULES:%=%.$($2_AROBJ)))
# '_start'). This driver object is then simply linked to its libraries and
# module archives to create an executable binary in the output folder.
# ORDER MATTERS HERE, this is for the linker:
-$(eval DRIVER_SRC := $(DRIVER_DEPS))
-$(eval DRIVER_DBGSRC := $(DRIVER_DBGDEPS))
+$(eval DRIVER_SRC := $(DRIVER_LFLAGS) $(DRIVER_DEPS))
+$(eval DRIVER_DBGSRC := $(DRIVER_LFLAGS) $(DRIVER_DBGDEPS))
# Iterate through the list of libraries in our language and stack commands from
# left to right in the "sources" section of the LD command (or LD section of the
# commandline for the compiler), to preserve ordering and also ensure that it is
--- /dev/null
+/*!@file
+ \brief Mail router for OCKoreanMartialArts.com
+ \details This mail routing system is intended to run as a daemon for fastcgi
+ and stores usage information in a database before sending mail to the
+ administrator
+ \author Ken
+ \date Sept 2016
+ ----------------------------------------------------------------------------*/
+/* Standard */
+#include <stdlib.h> //atoi
+#include <string.h> //mem
+/* Third Party */
+#include <fcgi_stdio.h>
+/* Internal */
+#include <ock/ock.h>
+
+int get_body(void);
+
+int
+main
+()
+{ if (db_init())
+ return -1;
+
+ while(FCGI_Accept() >= 0)
+ { printf("Content-type: application/json\r\n\r\n");
+ printf("{ \"submission\" : ");
+ if (!get_body())
+ printf("\"fail\"");
+ printf("\"pass\"");
+ printf(" }");
+ }
+ return 0;
+}
+
+int
+get_body
+()
+{ char *lencp;
+ int len, i;
+
+ if ((lencp = getenv("CONTENT_LENGTH")) == NULL
+ || (len = atoi(lencp)) < 1)
+ return -1;
+ for (i = 0; i < len; i++)
+ putchar(getchar());
+
+ return 0;
+}
+
--- /dev/null
+-lfcgi -lmysqlclient
----------------------------------------------------------------------------*/
/* Standard */
#include <stdio.h> //print
+#include <stdlib.h> //itoa
+#include <errno.h> //lib errors
/* Internal */
-#include <apc/ir.h> //link to IR
+#include <apc/ir.h>
+extern //irmem.c
+void ir_quit(void);
+extern
+int ir_init(void);
+
+struct irmem;
/* Ansi Term Colors */
#define RED "\x1b[31m"
#define BLUE "\x1b[34m"
#define MAGENTA "\x1b[35m"
#define CYAN "\x1b[36m"
-#define CLRX "\x1b[0m" //clear current color
-
-extern //ir.c
-void ir_quit(void);
-extern
-int ir_init(void);
-extern
-
+#define CLRC "\x1b[0m" //clear current color
int main(void);
int test_init(void);
+int test_mem(void);
+int test_ir(void);
+int test_ir_densedir(void);
int
main
()
-{ test_init();
+#define $($)#$
+#define PRINTFAIL(U) printf(RED $(U) "FAILED\n" CLRC)
+#define PRINTPASS(U) printf(GREEN $(U) "PASS\n" CLRC)
+#define PRINTINFO(S) printf(YELLOW S CLRC)
+#define RUN_UNIT(U,T) \
+ do { \
+ PRINTINFO(T); \
+ if (U()) \
+ PRINTFAIL(U); \
+ PRINTPASS(U); \
+ } while (0)
+{ RUN_UNIT(test_init,"Initializing\n");
+ RUN_UNIT(test_mem,"Memtest\n");
+ RUN_UNIT(test_ir,"Testing IR API\n");
return 0;
}
int
test_init
()
-{ /* Test Init */
- printf("YELLOW Initializing\n");
+#define TESTS 50
+{ static int n = 0;
+ printf("Init Run %-2i\n",n+1);
if (ir_init())
- { printf("RED FAILED CLRX");
- perror("ir init");
- return 1;
+ { perror("ir init");
+ return -1;
}
- printf("Quitting CLRX\n");
ir_quit();
- printf("GREEN PASS");
+ return (++n < TESTS) ? test_init() : ir_init();
+}
+
+int
+test_mem
+()
+{ return 0;
+}
+
+int
+test_ir
+()
+{
+}
+
+/* Test for 64*64 dense directories */
+int
+test_ir_densedir
+()
+#define DISTANCE 64
+#define SSTRLEN(S) (sizeof(S)/sizeof(S[0]))
+#define PUSHDIR() \
+ do {\
+
+ } while (0)
+{ static char dbuf[256] = "DEEP";
+ static char wbuf[256] = "WIDE";
+ static int depth = -1;
+ static int width = -1;
+ static char *dnum = dbuf + SSTRLEN(dbuf) - 1;
+ static char *wnum = wbuf + SSTRLEN(wbuf) - 1;
+
+ while (++depth < DISTANCE)
+ { itoa(depth,dnum,10);
+ push_cdat(dbuf);
+ while (++width < DISTANCE)
+ { itoa(width,wnum,10);
+ push_cdat(wbuf);
+ pop_cdat();
+ }
+ pop_cdat();
+ width = -1;
+ }
return 0;
}
+
+
--- /dev/null
+/*!@file
+ \brief Mail router for OCKoreanMartialArts.com
+ \details This mail routing system is intended to run as a daemon for fastcgi
+ and stores usage information in a database before sending mail to the
+ administrator
+ \author Ken
+ \date Sept 2016
+ ----------------------------------------------------------------------------*/
+/* Standard */
+#include <stdlib.h>
+#include <string.h> //mem
+/* Third Party */
+#include <curl/curl.h>
+/* Internal */
+#include <ock/ock.h>
+
+int send_mail(void);
+
+int
+send_mail
+()
+{ return 0;
+}
--- /dev/null
+/*!@file
+ \brief Database storage for OCK's promo handler
+ \details
+ \author Ken
+ \date Sept 2016
+ ----------------------------------------------------------------------------*/
+/* Standard */
+#include <stdio.h> //print
+#include <string.h> //mem
+/* Third Party */
+#include <mysql/mysql.h>
+/* Internal */
+#include <ock/ock.h>
+
+int db_init(void);
+int db_insert(char*,char*,char*,char*);
+
+MYSQL *mysql;
+
+int
+db_init
+()
+#define HOST "localhost"
+#define USER "ock"
+#define PASS "#0CK0r34!"
+#define DATABASE "ock_db"
+#define PORT 3306
+#define SOCKET NULL
+#define FLAGS 0
+#define DATTABLE "promo_submissions"
+#define DTABFMT \
+ "id not null auto_increment," \
+ "firstname varchar (32) not null," \
+ "lastname varchar (32) not null," \
+ "email varchar (64) not null," \
+ "phone varchar (16) not null," \
+ "primary key (id)"
+{ mysql = mysql_init(NULL);
+ if ((mysql = mysql_real_connect(mysql, HOST, USER, PASS, DATABASE, PORT, SOCKET, FLAGS)) == NULL)
+ { fprintf(stderr,"Failed to establish connection to db.\n");
+ return -1;
+ }
+ if (mysql_query(mysql, "SHOW TABLES LIKE '" DATTABLE "';"))
+ { fprintf(stderr,"Initial query failed\n");
+ return -1;
+ }
+ if (mysql_num_rows(mysql_use_result(mysql)) < 1)
+ if (mysql_query(mysql, "create table " DATTABLE " (" DTABFMT ");"))
+ { fprintf(stderr,"Failed to create table.\n");
+ return -1;
+ }
+ return 0;
+}
+
+int
+db_insert
+( char *fname,
+ char *lname,
+ char *email,
+ char *phone
+)
+#define INSERT_FMT \
+ "INSERT INTO " DATTABLE \
+ " VALUES ('%s','%s','%s','%s')" \
+ , fname, lname, email, phone
+#define INSERT_ERR "SQL Insertion Failed for %s %s - %s %s\n" \
+ , fname, lname, email, phone
+{ char sqlinsert[256];
+ sprintf(sqlinsert, INSERT_FMT);
+ if (mysql_query(mysql, sqlinsert))
+ { fprintf(stderr, INSERT_ERR);
+ return -1;
+ }
+ return 0;
+}
--- /dev/null
+#ifndef _OCK_H
+#define _OCK_H
+
+int db_init(void);
+int db_insert(char*,char*,char*,char*);
+
+#endif //_OCK_H