-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
10,334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,7 @@ modules.order | |
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
|
||
include | ||
bin | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
all: | ||
make -C src refresh | ||
make -C src | ||
make -C test | ||
|
||
clean: | ||
make -C src clean | ||
make -C test clean | ||
rm -rf include lib | ||
|
||
test: all | ||
make -C test test | ||
|
||
agoo: all | ||
make -C src agoo | ||
|
||
|
||
VERSION=$(shell bin/opod --version | cut -d ' ' -f 3) | ||
OS=$(shell if [ `uname` = "Darwin" ]; then echo "osx-`sw_vers -productVersion`"; elif [ `uname` = "Linux" ]; then echo "ubuntu-`lsb_release -rs`"; fi;) | ||
|
||
pull: | ||
cd ../agoo && git pull | ||
git pull | ||
|
||
release: | ||
make clean | ||
make src refresh | ||
make build=release | ||
|
||
dev: | ||
make clean | ||
make agoo | ||
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CC=cc | ||
CV=$(shell if [ `uname` = "Darwin" ]; then echo "c11"; elif [ `uname` = "Linux" ]; then echo "gnu11"; fi;) | ||
OS=$(shell echo `uname`) | ||
CFLAGS=-c -Wall -O3 -std=$(CV) -pedantic -D$(OS) | ||
|
||
SRC_DIR=. | ||
LIB_DIRS=-L../../lib | ||
INC_DIRS=-I../../include | ||
SRCS=$(shell find $(SRC_DIR) -type f -name "*.c" -print) | ||
LIBS=-lagoo -lpthread -lm | ||
OBJS=$(SRCS:.c=.o) | ||
TARGET=simple | ||
|
||
all: $(TARGET) | ||
|
||
clean: | ||
$(RM) *.o | ||
$(RM) *~ | ||
$(RM) .#* | ||
$(RM) $(TARGET) | ||
|
||
$(TARGET): $(OBJS) | ||
$(CC) -g -o $@ $(OBJS) $(LIB_DIRS) $(LIBS) | ||
|
||
%.o : %.c | ||
$(CC) -I. $(INC_DIRS) $(CFLAGS) -o $@ $< | ||
|
||
test: $(TARGET) | ||
$(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2018 by Peter Ohler, All Rights Reserved | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include <agoo.h> | ||
#include <agoo/log.h> | ||
#include <agoo/page.h> | ||
#include <agoo/server.h> | ||
|
||
static void | ||
empty_handler(Req req) { | ||
agoo_respond(req, 200, NULL, 0, NULL); | ||
} | ||
|
||
static int user_off = 6; | ||
|
||
static void | ||
user_handler(Req req) { | ||
agoo_respond(req, 200, req->path.start + user_off, req->path.len - user_off, NULL); | ||
} | ||
|
||
int | ||
main(int argc, char **argv) { | ||
struct _Err err = ERR_INIT; | ||
|
||
agoo_init("simple"); | ||
|
||
// Set the number of eval threads. | ||
the_server.thread_cnt = 1; | ||
|
||
pages_set_root("."); | ||
|
||
// bind to port 6464 | ||
if (ERR_OK != agoo_bind_port(&err, 6464)) { | ||
printf("Failed to bind to port. %s\n", err.msg); | ||
return err.code; | ||
} | ||
// set up hooks or routes | ||
if (ERR_OK != agoo_add_func_hook(&err, GET, "/", empty_handler, true) || | ||
ERR_OK != agoo_add_func_hook(&err, GET, "/user/*", user_handler, true) || | ||
ERR_OK != agoo_add_func_hook(&err, POST, "/user", empty_handler, true)) { | ||
return err.code; | ||
} | ||
// start the server and wait for it to be shutdown | ||
if (ERR_OK != agoo_start(&err, "0.1")) { | ||
printf("%s\n", err.msg); | ||
return err.code; | ||
} | ||
return 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
CC=cc | ||
CV=$(shell if [ `uname` = "Darwin" ]; then echo "c11"; elif [ `uname` = "Linux" ]; then echo "gnu11"; fi;) | ||
OS=$(shell echo `uname`) | ||
ifeq ($(build),release) | ||
CFLAGS=-c -Wall -O3 -std=$(CV) -pedantic -D$(OS) -DOPO_TS | ||
else | ||
CFLAGS=-c -Wall -g -Og -std=$(CV) -pedantic -D$(OS) -DOPO_TS | ||
endif | ||
|
||
# Create first so SRCS get setup with the agoo files. | ||
AGOO=agoo | ||
AGOO_SRC=../../agoo/ext/agoo | ||
ifeq "$(wildcard $(AGOO))" "" | ||
DUMMY=$(shell mkdir -p $(AGOO) && \ | ||
cp $(AGOO_SRC)/base64.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/bind.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/con.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/debug.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/doc.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/dtime.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/err.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/graphql.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/gqlintro.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/gqlvalue.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/hook.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/http.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/kinds.h $(AGOO) &&\ | ||
cp $(AGOO_SRC)/log.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/method.h $(AGOO) &&\ | ||
cp $(AGOO_SRC)/page.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/pub.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/queue.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/req.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/res.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/respponse.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/sha1.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/seg.h $(AGOO) &&\ | ||
cp $(AGOO_SRC)/server.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/sdl.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/sse.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/subject.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/text.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/upgraded.[ch] $(AGOO) &&\ | ||
cp $(AGOO_SRC)/websocket.[ch] $(AGOO)\ | ||
) | ||
endif | ||
|
||
SRC_DIR=. | ||
INC_DIR=../include | ||
LIB_DIR=../lib | ||
LIB_DIRS= | ||
INC_DIRS=-Iagoo | ||
|
||
SRCS=$(wildcard agoo/*.c) $(wildcard *.c) | ||
HEADERS=$(wildcard agoo/*.h) $(wildcard *.h) | ||
|
||
OBJS=$(SRCS:.c=.o) | ||
LIBS=-lm -lpthread | ||
TARGET=$(LIB_DIR)/libagoo.a | ||
|
||
all: $(INC_DIR) $(LIB_DIR) $(TARGET) | ||
rsync -tupRE $(HEADERS) $(INC_DIR) | ||
|
||
clean: | ||
$(RM) *.o | ||
$(RM) *~ | ||
$(RM) .#* | ||
$(RM) $(TARGET) | ||
$(RM) -rf $(AGOO) | ||
|
||
refresh: | ||
mkdir -p $(AGOO) | ||
echo "all:\n make -C ..\n" > agoo/Makefile | ||
cp ../../agoo/ext/agoo/base64.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/bind.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/con.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/debug.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/doc.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/dtime.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/err.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/graphql.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/gqlintro.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/gqlvalue.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/hook.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/http.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/kinds.h $(AGOO) | ||
cp ../../agoo/ext/agoo/log.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/method.h $(AGOO) | ||
cp ../../agoo/ext/agoo/page.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/pub.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/queue.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/req.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/res.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/response.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/sha1.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/seg.h $(AGOO) | ||
cp ../../agoo/ext/agoo/server.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/sdl.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/sse.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/subject.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/text.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/upgraded.[ch] $(AGOO) | ||
cp ../../agoo/ext/agoo/websocket.[ch] $(AGOO) | ||
|
||
$(INC_DIR): | ||
mkdir -p $@ | ||
|
||
$(LIB_DIR): | ||
mkdir -p $@ | ||
|
||
$(TARGET): $(OBJS) | ||
ar -rcs $@ $(OBJS) | ||
|
||
%.o : %.c $(HEADERS) | ||
$(DUMMY) | ||
$(CC) -I. $(INC_DIRS) $(CFLAGS) -o $@ $< |
Oops, something went wrong.