]> git.mdlowis.com Git - proto/aos.git/commitdiff
started working on mbusd. Sketched out a threading api based on C11 threads
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 2 Nov 2022 15:58:22 +0000 (11:58 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 2 Nov 2022 15:58:22 +0000 (11:58 -0400)
Makefile
bin/mbusd.c [new file with mode: 0644]
inc/liba.h
lib/a/Options.c
lib/a/defaults/options.c
lib/a/stdlib/smprintf.c

index ca94ebba72c671cc9318b50c3bcfa43c97f9e500..d2c79de9507db61875835c952a9d2933eab72d50 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,11 +7,13 @@ clean:
 
 bins: libs
 
-rules: rules.mk
-
 include config.mk
 
+rules:
+       ./mkrules $(OUTDIR)
+
 rules.mk:
        ./mkrules $(OUTDIR)
+
 include rules.mk
 include bin/rules.mk
diff --git a/bin/mbusd.c b/bin/mbusd.c
new file mode 100644 (file)
index 0000000..b417d74
--- /dev/null
@@ -0,0 +1,37 @@
+#include <liba.h>
+
+#define MAX_CONNS 1024
+
+char* Usage = "mbusd DIALSTR";
+long ConnectionMap[MAX_CONNS / sizeof(long)] = {0};
+
+void OnNewClient(Int cfd)
+{
+    (void)cfd;
+//    int pid = fork();
+//    if (pid < 0)
+//    {
+//        perror("fork");
+//    }
+//    else if (pid == 0)
+//    {
+////        dup2(cfd, 0);
+////        dup2(cfd, 1);
+////        dup2(cfd, 2);
+////        exit(execvp(Command[0], Command));
+//    }
+//    close(cfd);
+}
+
+int main(int argc, char** argv)
+{
+    if (argc != 1)
+    {
+        Options_PrintHelp();
+        return 1;
+    }
+
+    Net_Serve(argv[0], OnNewClient);
+
+    return 0;
+}
index ec96541ef971bd993ee505d07b82d2cfcd79e565..1310d93cd7422cd82cd5163e2506fe153851c722 100644 (file)
@@ -59,15 +59,6 @@ typedef struct {
 Int Options_Parse(Int argc, char** argv);
 void Options_PrintHelp(void);
 
-/*
-    Networking
-*/
-Int Net_Announce(char* dialstr);
-Int Net_Listen(Int fd, Int backlog);
-Int Net_Accept(Int fd);
-Int Net_Dial(char* dialstr);
-void Net_Serve(char* dialstr, void (*on_client)(Int cfd));
-
 /*
     UTF8 Encoding and Decoding
 */
@@ -93,3 +84,24 @@ extern void set_option(Int sname, char* lname, char* arg);
 extern char* ARGV0;
 extern char* Usage;
 extern Option_T Options[];
+
+/*
+    Networking
+*/
+Int Net_Announce(char* dialstr);
+Int Net_Listen(Int fd, Int backlog);
+Int Net_Accept(Int fd);
+Int Net_Dial(char* dialstr);
+void Net_Serve(char* dialstr, void (*on_client)(Int cfd));
+
+/*
+    Concurrency and Multithreading
+*/
+typedef struct Thread Thread_T;
+
+Int Thread_Create(Thread_T* thr, void* (*func)(void*), void *arg );
+Thread_T Thread_Current(void);
+void Thread_Yield(void);
+void Thread_Exit(Int res);
+Int Thread_Detach(Thread_T thread);
+Int Thread_Join(Thread_T thread);
\ No newline at end of file
index 5a54aacedd0a6391ce64821e3b6dcc763a6f4cbe..70b2626b62b1c46398cf6b7330e109ea9ad17e91 100644 (file)
@@ -196,7 +196,7 @@ void Options_PrintHelp(void)
         printf("usage: %s\n\n", Usage);
     }
 
-    /* prInt option help messages */
+    /* print option help messages */
     for (Int i = 0; Options[i].s || Options[i].l; i++)
     {
         int remain = padding;
index 359b4877dd83f218a8484a8c281874be7df8885a..03c70f0f1e80725d73d98c24221d23b498a99100 100644 (file)
@@ -1,6 +1,6 @@
 #include <liba.h>
 
 Option_T Options[] = {
-    { .s = 'h', .l = "help", .a = 0, .d = "prInt this help message" },
+    { .s = 'h', .l = "help", .a = 0, .d = "print this help message" },
     {0}
 };
\ No newline at end of file
index 1045cbebb4f2776794278d4f257f743563bf1ddf..3cf802db26bb1ad71be0636a7709af3c0214db6b 100644 (file)
@@ -1,7 +1,7 @@
 #include <liba.h>
 #include <std.h>
 
-char* smprIntf(const char* fmt, ...)
+char* smprintf(const char* fmt, ...)
 {
     va_list args;
     va_start(args, fmt);