]> Git repositories of Nishi - repoview.git/commitdiff
format
authorNishi <nishi@nishi.boats>
Tue, 20 Aug 2024 21:05:24 +0000 (21:05 +0000)
committerNishi <nishi@nishi.boats>
Tue, 20 Aug 2024 21:05:24 +0000 (21:05 +0000)
git-svn-id: file:///raid/svn-personal/repoview/trunk@3 7e8b2a19-8934-dd40-8cb3-db22cdd5a80f

21 files changed:
.clang-format [new file with mode: 0644]
CGI/Makefile
CGI/auth/cookie.c
CGI/db/sqlite.c
CGI/logo.png [new file with mode: 0644]
CGI/main.c
CGI/page.c
CGI/query.c
CGI/rv_auth.h [new file with mode: 0644]
CGI/rv_sha512.h [new file with mode: 0644]
CGI/sanity.c
CGI/sha512.c [new file with mode: 0644]
CGI/theme/modern.c
CGI/theme/optimized.c
CGI/util.c
CGI/version.c
Makefile
Platform/generic.mk
check.c
libs.c
objs.c

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..f09c9d2
--- /dev/null
@@ -0,0 +1,15 @@
+---
+# $Id$
+Language: Cpp
+UseTab: Always
+TabWidth: 8
+IndentWidth: 8
+PointerAlignment: Left
+ColumnLimit: 1024
+AllowShortIfStatementsOnASingleLine: Always
+AllowShortBlocksOnASingleLine: Never
+AllowShortLoopsOnASingleLine: true
+SpaceBeforeParens: Never
+AlignEscapedNewlines: DontAlign
+SortIncludes: false
+AllowShortEnumsOnASingleLine: false
index 33e4761dd03b05fe1315efd127c7e389c7a9dbd8..f64fc555839c472c0f4e4136c0388f773f1e1569 100644 (file)
@@ -5,7 +5,7 @@ include $(PWD)/Platform/$(PLATFORM).mk
 .PHONY: all clean
 .SUFFIXES: .c .o
 
-OBJS = main.o sanity.o version.o util.o query.o page.o $(EXTOBJS)
+OBJS = main.o sanity.o version.o util.o query.o page.o sha512.o $(EXTOBJS)
 
 all: repoview.cgi
 
index a0749a0c2c0c92aeb7c5f5fa6ace589ef08aceeb..a2924f9cb13e7d0c6e52f41947b8e6a0008f5bf7 100644 (file)
@@ -1 +1,83 @@
 /* $Id$ */
+
+#include "rv_auth.h"
+
+#include "rv_util.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+extern char** environ;
+
+struct cookie_entry {
+       char* key;
+       char* value;
+};
+
+struct cookie_entry** cookie_entries;
+
+void parse_cookie(void) {
+       cookie_entries = malloc(sizeof(*cookie_entries));
+       cookie_entries[0] = NULL;
+       char* cookie = getenv("HTTP_COOKIE");
+       if(cookie != NULL) {
+               cookie = rv_strdup(cookie);
+               int i;
+               int incr = 0;
+               for(i = 0;; i++) {
+                       if(cookie[i] == 0 || cookie[i] == ';') {
+                               char oldc = cookie[i];
+                               cookie[i] = 0;
+
+                               char* key = cookie + incr;
+                               char* value = "";
+
+                               int j;
+                               for(j = 0; key[j] != 0; j++) {
+                                       if(key[j] == '=') {
+                                               key[j] = 0;
+                                               value = key + j + 1;
+                                               break;
+                                       }
+                               }
+                               struct cookie_entry* entry = malloc(sizeof(*entry));
+                               entry->key = rv_strdup(key);
+                               entry->value = rv_strdup(value);
+
+                               struct cookie_entry** old_entries = cookie_entries;
+                               for(j = 0; old_entries[j] != NULL; j++)
+                                       ;
+                               cookie_entries = malloc(sizeof(*cookie_entries) * (j + 2));
+                               for(j = 0; old_entries[j] != NULL; j++) {
+                                       cookie_entries[j] = old_entries[j];
+                               }
+                               cookie_entries[j] = entry;
+                               cookie_entries[j + 1] = NULL;
+
+                               int oldi = i;
+                               i++;
+                               for(; cookie[i] != 0 && (cookie[i] == ' ' || cookie[i] == '\t'); i++)
+                                       ;
+                               i--;
+                               incr = i + 1;
+                               if(oldc == 0) break;
+                       }
+               }
+               free(cookie);
+       }
+}
+
+char* rv_logged_in(void) {
+       parse_cookie();
+       return NULL;
+}
+
+void rv_free_auth(void) {
+       int i;
+       for(i = 0; cookie_entries[i] != NULL; i++) {
+               free(cookie_entries[i]->key);
+               free(cookie_entries[i]->value);
+               free(cookie_entries[i]);
+       }
+       free(cookie_entries);
+}
index b513e6f2904956da3c7af3555e04df864fb1d9c2..e2b1e2a8f8269e829e2cd11e4b205a184e47c783 100644 (file)
 
 sqlite3* sql;
 
-void rv_init_db(void){
+void rv_init_db(void) {
        int ret;
        ret = sqlite3_open(DB_ROOT "/db.sqlite3", &sql);
-       if(ret != SQLITE_OK){
+       if(ret != SQLITE_OK) {
                rv_error_http();
                printf("SQLite3 database error\n");
                exit(1);
        }
        char* err;
-       ret = sqlite3_exec(
-               sql,
-               "create table if not exists users(user text, password text)",
-               NULL,
-               NULL,
-               &err
-       );
-       if(ret != SQLITE_OK){
+       ret = sqlite3_exec(sql, "create table if not exists users(user text, password text)", NULL, NULL, &err);
+       if(ret != SQLITE_OK) {
                sqlite3_free(err);
                rv_error_http();
                printf("SQLite3 database error\n");
                exit(1);
        }
-       ret = sqlite3_exec(
-               sql,
-               "create table if not exists tokens(user text, token text)",
-               NULL,
-               NULL,
-               &err
-       );
-       if(ret != SQLITE_OK){
+       ret = sqlite3_exec(sql, "create table if not exists tokens(user text, token text)", NULL, NULL, &err);
+       if(ret != SQLITE_OK) {
                sqlite3_free(err);
                rv_error_http();
                printf("SQLite3 database error\n");
@@ -51,26 +39,24 @@ void rv_init_db(void){
        }
 }
 
-void rv_close_db(void){
-       sqlite3_close(sql);
-}
+void rv_close_db(void) { sqlite3_close(sql); }
 
 int count = 0;
 
-int sqlcount(void* param, int ncol, char** row, char** col){
+int sqlcount(void* param, int ncol, char** row, char** col) {
        count = ncol;
        fprintf(stderr, "%d\n", ncol);
        return 0;
 }
 
-bool rv_has_user(const char* username){
+bool rv_has_user(const char* username) {
        char* err;
        char cbuf[2];
        cbuf[1] = 0;
        char* query = rv_strdup("select * from users where user = '");
        int i;
-       for(i = 0; username[i] != 0; i++){
-               if(username[i] == '\''){
+       for(i = 0; username[i] != 0; i++) {
+               if(username[i] == '\'') {
                        cbuf[0] = username[i];
                        char* tmp = query;
                        tmp = rv_strcat(tmp, cbuf);
@@ -79,7 +65,7 @@ bool rv_has_user(const char* username){
                        tmp = query;
                        query = rv_strcat(tmp, cbuf);
                        free(tmp);
-               }else{
+               } else {
                        cbuf[0] = username[i];
                        char* tmp = query;
                        query = rv_strcat(tmp, cbuf);
@@ -91,15 +77,9 @@ bool rv_has_user(const char* username){
        free(tmp);
        int ret;
        fprintf(stderr, "%s\n", query);
-       ret = sqlite3_exec(
-               sql,
-               query,
-               sqlcount,
-               NULL,
-               &err
-       );
+       ret = sqlite3_exec(sql, query, sqlcount, NULL, &err);
        free(query);
-       if(ret != SQLITE_OK){
+       if(ret != SQLITE_OK) {
                sqlite3_free(err);
        }
        return count > 0;
diff --git a/CGI/logo.png b/CGI/logo.png
new file mode 100644 (file)
index 0000000..9aac683
Binary files /dev/null and b/CGI/logo.png differ
index a3dd2bc81d764c019f10b2303754e7c27118d400..2170c13f15d285fa234f69445c66ad61ecfb9248 100644 (file)
@@ -9,12 +9,13 @@
 #include "rv_page.h"
 #include "rv_util.h"
 #include "rv_db.h"
+#include "rv_auth.h"
 
 #include <stdlib.h>
 
 char* postdata;
 
-int main(){
+int main() {
        rv_check_sanity();
        rv_init_db();
        rv_parse_query(getenv("QUERY_STRING"));
@@ -23,7 +24,7 @@ int main(){
        postdata[0] = 0;
        char cbuf[2];
        cbuf[1] = 0;
-       while(1){
+       while(1) {
                fread(cbuf, 1, 1, stdin);
                if(feof(stdin)) break;
                char* tmp = postdata;
@@ -36,6 +37,11 @@ int main(){
        printf("Content-Type: text/html\r\n");
        printf("\r\n");
        rv_print_page();
+       rv_logged_in();
+       rv_load_query('Q');
+       rv_free_query();
+       rv_load_query('P');
        rv_free_query();
        rv_close_db();
+       rv_free_auth();
 }
index 1f73d11cf2b5e1a9ff803b24e59af864ba0bc687..c938e751f9d3fb763e716b2b7d093567ab48a438 100644 (file)
@@ -14,18 +14,16 @@ char* buffer;
 
 void render_page(void);
 
-void add_data(char** data, const char* txt){
+void add_data(char** data, const char* txt) {
        char* tmp = *data;
        *data = rv_strcat(tmp, txt);
        free(tmp);
 }
 
-void rv_process_page(void){
+void rv_process_page(void) {
        buffer = malloc(1);
        buffer[0] = 0;
        render_page();
 }
 
-void rv_print_page(void){
-       printf("%s\n", buffer);
-}
+void rv_print_page(void) { printf("%s\n", buffer); }
index 61a91b3111ab147398029ac14e406208ea32d8dd..7f3b7548b4b9c9e003b7af785ce286ec3f1a2b57 100644 (file)
@@ -18,30 +18,30 @@ struct query_entry** qentries;
 struct query_entry** query;
 struct query_entry** postquery;
 
-void rv_save_query(char c){
-       if(c == 'Q'){
+void rv_save_query(char c) {
+       if(c == 'Q') {
                query = qentries;
-       }else if(c == 'P'){
+       } else if(c == 'P') {
                postquery = qentries;
        }
 }
 
-void rv_load_query(char c){
-       if(c == 'Q'){
+void rv_load_query(char c) {
+       if(c == 'Q') {
                qentries = query;
-       }else if(c == 'P'){
+       } else if(c == 'P') {
                qentries = postquery;
        }
 }
 
-void rv_parse_query(const char* oldquery){
+void rv_parse_query(const char* oldquery) {
        char* query = rv_strdup(oldquery);
        int i;
        int incr = 0;
        qentries = malloc(sizeof(*qentries));
        qentries[0] = NULL;
-       for(i = 0;; i++){
-               if(query[i] == '&' || query[i] == 0){
+       for(i = 0;; i++) {
+               if(query[i] == '&' || query[i] == 0) {
                        char oldc = query[i];
                        query[i] = 0;
 
@@ -49,8 +49,8 @@ void rv_parse_query(const char* oldquery){
                        char* value = "";
 
                        int j;
-                       for(j = 0; key[j] != 0; j++){
-                               if(key[j] == '='){
+                       for(j = 0; key[j] != 0; j++) {
+                               if(key[j] == '=') {
                                        key[j] = 0;
                                        value = key + j + 1;
                                        break;
@@ -62,9 +62,10 @@ void rv_parse_query(const char* oldquery){
                        entry->value = rv_url_decode(value);
 
                        struct query_entry** old_entries = qentries;
-                       for(j = 0; old_entries[j] != NULL; j++);
+                       for(j = 0; old_entries[j] != NULL; j++)
+                               ;
                        qentries = malloc(sizeof(*qentries) * (j + 2));
-                       for(j = 0; old_entries[j] != NULL; j++){
+                       for(j = 0; old_entries[j] != NULL; j++) {
                                qentries[j] = old_entries[j];
                        }
                        qentries[j] = entry;
@@ -78,9 +79,9 @@ void rv_parse_query(const char* oldquery){
        free(query);
 }
 
-void rv_free_query(void){
+void rv_free_query(void) {
        int i;
-       for(i = 0; qentries[i] != NULL; i++){
+       for(i = 0; qentries[i] != NULL; i++) {
                free(qentries[i]->key);
                free(qentries[i]->value);
                free(qentries[i]);
@@ -88,10 +89,10 @@ void rv_free_query(void){
        free(qentries);
 }
 
-char* rv_get_query(const char* key){
+char* rv_get_query(const char* key) {
        int i;
-       for(i = 0; qentries[i] != NULL; i++){
-               if(strcmp(qentries[i]->key, key) == 0){
+       for(i = 0; qentries[i] != NULL; i++) {
+               if(strcmp(qentries[i]->key, key) == 0) {
                        return qentries[i]->value;
                }
        }
diff --git a/CGI/rv_auth.h b/CGI/rv_auth.h
new file mode 100644 (file)
index 0000000..c9595aa
--- /dev/null
@@ -0,0 +1,11 @@
+/* $Id$ */
+
+#ifndef __RV_AUTH_H__
+#define __RV_AUTH_H__
+
+#include <stdbool.h>
+
+char* rv_logged_in(void);
+void rv_free_auth(void);
+
+#endif
diff --git a/CGI/rv_sha512.h b/CGI/rv_sha512.h
new file mode 100644 (file)
index 0000000..8628fe8
--- /dev/null
@@ -0,0 +1,8 @@
+/* $Id$ */
+
+#ifndef __RV_SHA512_H__
+#define __RV_SHA512_H__
+
+unsigned char* rv_sha512(const char* string);
+
+#endif
index b7fe418f74d13a6a2f31dfd1bd4289a0132e42ef..2be7a4bbf98a52704c2b32d86f001b25524b49a9 100644 (file)
@@ -11,7 +11,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-bool rv_find_executable(const char* name){
+bool rv_find_executable(const char* name) {
 #ifdef USE_PATH
        char* path = rv_strcat(USE_PATH, "");
 #else
@@ -19,8 +19,8 @@ bool rv_find_executable(const char* name){
 #endif
        int i;
        int incr = 0;
-       for(i = 0;; i++){
-               if(path[i] == 0 || path[i] == PATH_DELIM){
+       for(i = 0;; i++) {
+               if(path[i] == 0 || path[i] == PATH_DELIM) {
                        char oldc = path[i];
                        path[i] = 0;
                        char* exec = rv_strcat3(path + incr, "/", name);
@@ -29,7 +29,7 @@ bool rv_find_executable(const char* name){
                        exec = rv_strcat(exec, ".exe");
                        free(tmp);
 #endif
-                       if(access(exec, F_OK) == 0){
+                       if(access(exec, F_OK) == 0) {
                                free(exec);
                                free(path);
                                return true;
@@ -43,7 +43,7 @@ bool rv_find_executable(const char* name){
        return false;
 }
 
-void rv_check_sanity(void){
+void rv_check_sanity(void) {
        bool sane = true;
 
        bool svnlook = rv_find_executable("svnlook");
@@ -54,7 +54,7 @@ void rv_check_sanity(void){
        if(!svnadmin) sane = false;
        if(!htpasswd) sane = false;
 
-       if(!sane){
+       if(!sane) {
                rv_error_http();
                if(!svnlook) printf("svnlook not found\n");
                if(!svnadmin) printf("svnadmin not found\n");
diff --git a/CGI/sha512.c b/CGI/sha512.c
new file mode 100644 (file)
index 0000000..83d0214
--- /dev/null
@@ -0,0 +1,14 @@
+/* $Id$ */
+
+#include "rv_sha512.h"
+
+#include <openssl/sha.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+unsigned char* rv_sha512(const char* string) {
+       unsigned char* hash = malloc(SHA512_DIGEST_LENGTH);
+       SHA512((const unsigned char*)string, strlen(string), hash);
+       return hash;
+}
index 56016a6a5ed789925f7f96ebdafef22387078bca..2e8e730dc7bae6bf202c3451a1ca69b0770a9ee1 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "rv_util.h"
 #include "rv_version.h"
+#include "rv_auth.h"
 #include "rv_db.h"
 
 #include "../../config.h"
@@ -19,16 +20,16 @@ char* title = NULL;
 char* desc = NULL;
 char* page = NULL;
 
-void render_page(void){
+void render_page(void) {
        rv_load_query('Q');
        char* query = rv_get_query("page");
        if(query == NULL) query = "welcome";
 
-       if(strcmp(query, "welcome") == 0){
+       if(strcmp(query, "welcome") == 0) {
                title = rv_strdup("Welcome");
                desc = rv_strdup("Welcome to " INSTANCE_NAME ".");
                page = rv_strcat3("Welcome to " INSTANCE_NAME ".<br>This instance is running RepoView version ", rv_get_version(), ".");
-       }else if(strcmp(query, "login") == 0){
+       } else if(strcmp(query, "login") == 0) {
                title = rv_strdup("Login");
                desc = rv_strdup("You can log in to your account here.");
                page = rv_strdup("");
@@ -52,16 +53,16 @@ void render_page(void){
                add_data(&page, "       </table>\n");
                add_data(&page, "       <input type=\"submit\" value=\"Login\">\n");
                add_data(&page, "</form>\n");
-       }else if(strcmp(query, "sendlogin") == 0){
+       } else if(strcmp(query, "sendlogin") == 0) {
                title = rv_strdup("Login Result");
                page = rv_strdup("");
 
                rv_load_query('P');
-               if(rv_get_query("username") == NULL || rv_get_query("password") == NULL){
+               if(rv_get_query("username") == NULL || rv_get_query("password") == NULL) {
                        add_data(&page, "Invalid form\n");
-               }else{
-                       if(rv_has_user(rv_get_query("username"))){
-                       }else{
+               } else {
+                       if(rv_has_user(rv_get_query("username"))) {
+                       } else {
                                add_data(&page, "User does not exist");
                        }
                }
@@ -76,22 +77,22 @@ void render_page(void){
        free(title);
 }
 
-char* escape(const char* str){
+char* escape(const char* str) {
        char* r = malloc(1);
        r[0] = 0;
        char cbuf[2];
        cbuf[1] = 0;
        int i;
-       for(i = 0; str[i] != 0; i++){
-               if(str[i] == '<'){
+       for(i = 0; str[i] != 0; i++) {
+               if(str[i] == '<') {
                        char* tmp = r;
                        r = rv_strcat(tmp, "&lt;");
                        free(tmp);
-               }else if(str[i] == '>'){
+               } else if(str[i] == '>') {
                        char* tmp = r;
                        r = rv_strcat(tmp, "&gt;");
                        free(tmp);
-               }else{
+               } else {
                        cbuf[0] = str[i];
                        char* tmp = r;
                        r = rv_strcat(tmp, cbuf);
@@ -101,7 +102,7 @@ char* escape(const char* str){
        return r;
 }
 
-void render_stuff(void){
+void render_stuff(void) {
        char* escaped;
        add_data(&buffer, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
        add_data(&buffer, "<html>\n");
index c39e650615402be16d158e2c7e34f4dbcae5045d..51622dc9a5a0e9ae7105166ab8b21eb9bc6150ec 100644 (file)
@@ -3,5 +3,4 @@
 extern char* buffer;
 void add_data(char** data, const char* txt);
 
-void render_page(void){
-}
+void render_page(void) {}
index 7e8d1b34a405ad209b1603b70234860ee8bd3686..7efe5580c42b1885423a5042b66de7a0c73b6eaf 100644 (file)
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-char* rv_strcat(const char* a, const char* b){
+char* rv_strcat(const char* a, const char* b) {
        char* str = malloc(strlen(a) + strlen(b) + 1);
        memcpy(str, a, strlen(a));
        memcpy(str + strlen(a), b, strlen(b));
@@ -18,18 +18,16 @@ char* rv_strcat(const char* a, const char* b){
        return str;
 }
 
-char* rv_strcat3(const char* a, const char* b, const char* c){
+char* rv_strcat3(const char* a, const char* b, const char* c) {
        char* tmp = rv_strcat(a, b);
        char* str = rv_strcat(tmp, c);
        free(tmp);
        return str;
 }
 
-char* rv_strdup(const char* str){
-       return rv_strcat(str, "");
-}
+char* rv_strdup(const char* str) { return rv_strcat(str, ""); }
 
-void rv_error_http(void){
+void rv_error_http(void) {
        printf("Content-Type: text/plain\r\n");
        printf("Status: 500 Internal Server Error\r\n");
        printf("\r\n");
@@ -40,25 +38,25 @@ void rv_error_http(void){
        printf("-----\n");
 }
 
-int hex_to_num(char c){
-       if('0' <= c && c <= '9'){
+int hex_to_num(char c) {
+       if('0' <= c && c <= '9') {
                return c - '0';
-       }else if('a' <= c && c <= 'f'){
+       } else if('a' <= c && c <= 'f') {
                return c - 'a' + 10;
-       }else if('A' <= c && c <= 'F'){
+       } else if('A' <= c && c <= 'F') {
                return c - 'A' + 10;
        }
        return 0;
 }
 
-char* rv_url_decode(const char* str){
+char* rv_url_decode(const char* str) {
        char* r = malloc(1);
        r[0] = 0;
        int i;
        char cbuf[2];
        cbuf[1] = 0;
-       for(i = 0; str[i] != 0; i++){
-               if(str[i] == '%'){
+       for(i = 0; str[i] != 0; i++) {
+               if(str[i] == '%') {
                        if(str[i + 1] == 0) break;
                        if(str[i + 2] == 0) break;
                        cbuf[0] = (hex_to_num(str[i + 1]) << 4) | hex_to_num(str[i + 2]);
@@ -66,7 +64,7 @@ char* rv_url_decode(const char* str){
                        r = rv_strcat(tmp, cbuf);
                        free(tmp);
                        i += 2;
-               }else{
+               } else {
                        cbuf[0] = str[i];
                        char* tmp = r;
                        r = rv_strcat(tmp, cbuf);
index 6359256caa30c34ac13b2edc7d06b3b43890da3c..08fae8cbef1887809267f5adefbbb5a92ecddd65 100644 (file)
@@ -4,6 +4,4 @@
 
 const char* rv_version = "1.00";
 
-const char* rv_get_version(void){
-       return rv_version;
-}
+const char* rv_get_version(void) { return rv_version; }
index c3488195ccc48918d55d472b4f7bbeb7ebb2394c..1078ee95652484696e100e88ac200c83af437381 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ PLATFORM = generic
 
 FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) EXTOBJS="`./objs`" EXTLIBS="`./libs`"
 
-.PHONY: all clean ./CGI
+.PHONY: all clean format ./CGI
 
 all: ./CGI
 
@@ -25,3 +25,6 @@ check:: check.c config.h
 clean:
        $(MAKE) -C ./CGI clean $(FLAGS)
        rm -f objs libs check
+
+format:
+       clang-format --verbose -i `find . -name "*.c" -or -name "*.h"`
index c26df9cca643806ef0cedc55f1db8587f54c1267..f8f14afdd2dae1ede04cbf0e04ab7b4aa34164d8 100644 (file)
@@ -3,4 +3,4 @@
 CC = cc
 CFLAGS = -std=c99
 LDFLAGS =
-LIBS =
+LIBS = -lcrypto
diff --git a/check.c b/check.c
index d20cf23b5248c1839916e5bbedc767dc96ff8989..e838a3f6f2be5b3c10878b5e8cedd365845afa6e 100644 (file)
--- a/check.c
+++ b/check.c
@@ -4,7 +4,7 @@
 
 #include <stdio.h>
 
-int check_db(void){
+int check_db(void) {
        int counter = 0;
        const char* db = "";
 #ifdef USE_SQLITE
@@ -19,19 +19,19 @@ int check_db(void){
        counter++;
        db = "NDBM";
 #endif
-       if(counter > 1){
+       if(counter > 1) {
                fprintf(stderr, "You cannot use multiple database types at once.\n");
                return 1;
-       }else if(counter == 0){
+       } else if(counter == 0) {
                fprintf(stderr, "You must select a database type.\n");
                return 1;
-       }else{
+       } else {
                printf("Database type is %s\n", db);
        }
        return 0;
 }
 
-int check_theme(void){
+int check_theme(void) {
        int counter = 0;
        const char* theme = "";
 #ifdef USE_MODERN
@@ -42,38 +42,38 @@ int check_theme(void){
        counter++;
        theme = "Optimized";
 #endif
-       if(counter > 1){
+       if(counter > 1) {
                fprintf(stderr, "You cannot use multiple themes at once.\n");
                return 1;
-       }else if(counter == 0){
+       } else if(counter == 0) {
                fprintf(stderr, "You must select a theme.\n");
                return 1;
-       }else{
+       } else {
                printf("Theme is %s\n", theme);
        }
        return 0;
 }
 
-int check_auth(void){
+int check_auth(void) {
        int counter = 0;
        const char* method = "";
 #ifdef USE_COOKIE
        counter++;
        method = "Cookie";
 #endif
-       if(counter > 1){
+       if(counter > 1) {
                fprintf(stderr, "You cannot use multiple authentication methods at once.\n");
                return 1;
-       }else if(counter == 0){
+       } else if(counter == 0) {
                fprintf(stderr, "You must select an authentication method.\n");
                return 1;
-       }else{
+       } else {
                printf("Authentication method is %s\n", method);
        }
        return 0;
 }
 
-int main(){
+int main() {
        int st;
        st = check_db();
        if(st != 0) goto fail;
diff --git a/libs.c b/libs.c
index e3ff25a5b2dcba732d0b8086c46c5229bf680384..57db5794fa25344935c35c143c8f79ddcca18983 100644 (file)
--- a/libs.c
+++ b/libs.c
@@ -4,7 +4,7 @@
 
 #include <stdio.h>
 
-int main(){
+int main() {
 #if defined(USE_SQLITE)
        printf("-lsqlite3");
 #elif defined(USE_GDBM)
diff --git a/objs.c b/objs.c
index 1ac24ab947208be41e2ee0164506684b73246c9a..afeb2f301bcf71b370cd43d6095c5afa009eff35 100644 (file)
--- a/objs.c
+++ b/objs.c
@@ -2,7 +2,7 @@
 
 #include <stdio.h>
 
-int main(){
+int main() {
 #if defined(USE_SQLITE)
        printf("db/sqlite.o");
 #elif defined(USE_GDBM) || defined(USE_NDBM)