aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-18 02:10:30 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-18 02:10:30 +0200
commitc1e3206968f9878f8b7883cc7c313cd930c86d04 (patch)
treef279f343bd27b6fd5d338636138f17c071290016
parent24bf14f6653ebf1c1ba79b9f212d35417bb6acbf (diff)
downloadcforum-c1e3206968f9878f8b7883cc7c313cd930c86d04.tar.gz
Add README, fix C89 compliance
-rw-r--r--Makefile5
-rw-r--r--README28
-rw-r--r--cforum.c2
-rw-r--r--ctl.c6
-rw-r--r--mktpl/Makefile3
-rwxr-xr-xmktpl/mktplbin23988 -> 23988 bytes
-rw-r--r--mktpl/mktpl.c1
-rw-r--r--mktpl/mktpl.lex1
-rw-r--r--t/front.t3
-rw-r--r--t/front.tc3
-rw-r--r--t/post.t2
-rw-r--r--t/post.tc2
12 files changed, 43 insertions, 13 deletions
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 <stdlib.h>
#include <string.h>
#include <time.h>
+#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
--- a/mktpl/mktpl
+++ b/mktpl/mktpl
Binary files 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 @@
<h3>Latest posts</h3>
<table border="1">
<%
- 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<h1>");
printf("%s", site.name );
printf("</h1>\n<h3>Latest posts</h3>\n<table border=\"1\">\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 %>
</pre>
<%
-struct attachment *attachment;
-
if(attachment = getattachment(stmt, 0)){
%>
<h3>Attachments</h3>
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("</a>\n");
printf("\n<pre>\n");
printf("%s", post->text );
printf("\n</pre>\n");
-struct attachment *attachment;
-
if(attachment = getattachment(stmt, 0)){
printf("\n<h3>Attachments</h3>\n<table border=\"1\">\n ");