From c1e3206968f9878f8b7883cc7c313cd930c86d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 18 Sep 2021 02:10:30 +0200 Subject: Add README, fix C89 compliance --- Makefile | 5 +++++ README | 28 ++++++++++++++++++++++++++++ cforum.c | 2 +- ctl.c | 6 +++++- mktpl/Makefile | 3 ++- mktpl/mktpl | Bin 23988 -> 23988 bytes mktpl/mktpl.c | 1 + mktpl/mktpl.lex | 1 + t/front.t | 3 --- t/front.tc | 3 --- t/post.t | 2 -- t/post.tc | 2 -- 12 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 README diff --git a/Makefile b/Makefile index 5c1e856..fae0385 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +CFLAGS += -std=c89 -Wall -pedantic -Wno-parentheses LDLIBS += -lsqlite3 C = $(shell ls *.c) H = $(shell ls *.h) @@ -8,6 +9,10 @@ TPL = $(shell ls t/*.t | sed 's/$$/c/') cforum: $(C) $(H) $(TPL) $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o cforum $(C) +clean: + rm cforum + rm $(TPL) + .t.tc: mktpl/mktpl <$< mktpl/mktpl >$@ diff --git a/README b/README new file mode 100644 index 0000000..12f83fc --- /dev/null +++ b/README @@ -0,0 +1,28 @@ + README + +`cforum' is a CGI-based web forum software written in C. It uses +SQLite as its database. It is designed to be a simple, fast and +reliable alternative to software like phpBB. Written in portable +C89, it can be run on practically any UNIX system. + +`cforum' is also small: + + $ wc -l *.c *.h t/*.t */*.lex + 96 cforum.c + 96 ctl.c + 121 db.c + 12 err.c + 106 query.c + 3 ctl.h + 34 db.h + 0 err.h + 14 query.h + 2 site.h + 3 t/err.t + 1 t/foot.t + 17 t/front.t + 6 t/head.t + 35 t/post.t + 2 t/user.t + 86 mktpl/mktpl.lex + 634 total diff --git a/cforum.c b/cforum.c index dbf320c..c5cc411 100644 --- a/cforum.c +++ b/cforum.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { - char err[MAXERR], *p, *qs, *v; + char err[MAXERR], *p, *v; int attachmentid, postid, userid; sqlite3_stmt *stmt; diff --git a/ctl.c b/ctl.c index 51809db..6ae9832 100644 --- a/ctl.c +++ b/ctl.c @@ -2,6 +2,7 @@ #include #include #include +#include "err.h" #include "db.h" #include "query.h" #include "site.h" @@ -36,6 +37,8 @@ void showfront() { char *title; + struct post *post; + struct user *user; sqlite3_stmt *stmt; if(sqlite3_prepare(db, @@ -54,6 +57,7 @@ void showpost(int id) { char *title; + struct attachment *attachment; struct post *post; struct user *user; sqlite3_stmt *stmt; @@ -78,7 +82,7 @@ showpost(int id) void showuser(int id) { - char s[128], *title; + char *title; struct user *user; if(!(user = getuser(byid("users", id), 1))){ diff --git a/mktpl/Makefile b/mktpl/Makefile index 0e7363b..f413714 100644 --- a/mktpl/Makefile +++ b/mktpl/Makefile @@ -1,6 +1,7 @@ +CFLAGS += -std=c89 -Wall -pedantic -Wno-parentheses LDLIBS += -lfl mktpl: mktpl.c mktpl.c: mktpl.lex - flex -omktpl.c mktpl.lex + flex -omktpl.c mktpl.lex \ No newline at end of file diff --git a/mktpl/mktpl b/mktpl/mktpl index 415d645..cc26132 100755 Binary files a/mktpl/mktpl and b/mktpl/mktpl differ diff --git a/mktpl/mktpl.c b/mktpl/mktpl.c index e806bef..485d209 100644 --- a/mktpl/mktpl.c +++ b/mktpl/mktpl.c @@ -1568,6 +1568,7 @@ main(int argc, char *argv[]) err(1, "malloc"); yylex(); + return 0; } void diff --git a/mktpl/mktpl.lex b/mktpl/mktpl.lex index 1940f02..f0674b7 100644 --- a/mktpl/mktpl.lex +++ b/mktpl/mktpl.lex @@ -40,6 +40,7 @@ main(int argc, char *argv[]) err(1, "malloc"); yylex(); + return 0; } void diff --git a/t/front.t b/t/front.t index 5f59c1c..5c88166 100644 --- a/t/front.t +++ b/t/front.t @@ -3,9 +3,6 @@

Latest posts

<% - struct post *post; - struct user *user; - while(post = getpost(stmt, 0)){ user = getuser(byid("users", post->user), 1); %> diff --git a/t/front.tc b/t/front.tc index 9bed8a1..4ee561a 100644 --- a/t/front.tc +++ b/t/front.tc @@ -2,9 +2,6 @@ printf("\n

"); printf("%s", site.name ); printf("

\n

Latest posts

\n
\n "); - struct post *post; - struct user *user; - while(post = getpost(stmt, 0)){ user = getuser(byid("users", post->user), 1); diff --git a/t/post.t b/t/post.t index 200e27d..deeb285 100644 --- a/t/post.t +++ b/t/post.t @@ -14,8 +14,6 @@ <%= post->text %> <% -struct attachment *attachment; - if(attachment = getattachment(stmt, 0)){ %>

Attachments

diff --git a/t/post.tc b/t/post.tc index 89298db..4453246 100644 --- a/t/post.tc +++ b/t/post.tc @@ -31,8 +31,6 @@ printf("\n"); printf("\n
\n");
 printf("%s",  post->text );
 printf("\n
\n"); -struct attachment *attachment; - if(attachment = getattachment(stmt, 0)){ printf("\n

Attachments

\n
\n "); -- cgit v1.2.3