updated some headercomments and added HACKING
This commit is contained in:
parent
9fa5c9eac9
commit
319b76216b
12 changed files with 172 additions and 129 deletions
94
HACKING
Normal file
94
HACKING
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
|
||||||
|
Coding-style
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Statements
|
||||||
|
----------
|
||||||
|
If only one statement exist in a statement body. Braces should be skipped,
|
||||||
|
but not if the structure is nested or followed by multiple if/else, ex:
|
||||||
|
|
||||||
|
for(i=0; i < 10; i++)
|
||||||
|
for(j=0; i < 10; j++)
|
||||||
|
if (i == j)
|
||||||
|
foo();
|
||||||
|
|
||||||
|
if (a)
|
||||||
|
foo();
|
||||||
|
else if (b) {
|
||||||
|
if (c)
|
||||||
|
bar();
|
||||||
|
} else
|
||||||
|
baz();
|
||||||
|
|
||||||
|
instead you should write the above code as:
|
||||||
|
|
||||||
|
for(i=0; i < 10; i++) {
|
||||||
|
for(j=0; i < 10; j++) {
|
||||||
|
if (i == j)
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a) {
|
||||||
|
foo();
|
||||||
|
} else if (b) {
|
||||||
|
if (c)
|
||||||
|
bar();
|
||||||
|
} else {
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
|
Avoid using assignment in if()
|
||||||
|
|
||||||
|
Functions
|
||||||
|
---------
|
||||||
|
We use an extended K&R style, the extension is for functions that can have both there opening bracer on the same line and
|
||||||
|
directly under it but please don't mix em. We allow both but you should chose one and stick with it.
|
||||||
|
You should mimic the syntax used around your code, don't mix both formats in one c file.
|
||||||
|
If you encounter a file with mixed syntax, change it to whatever style you like (you can't break anything ;)
|
||||||
|
|
||||||
|
void foo() {
|
||||||
|
/* body */
|
||||||
|
}
|
||||||
|
|
||||||
|
void bar()
|
||||||
|
{
|
||||||
|
/* body */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Pointer declaration
|
||||||
|
-------------------
|
||||||
|
this should be done in 2 different ways depending on where it's declared:
|
||||||
|
|
||||||
|
1: variables are declared like `char *str`, not `char * str` or `char* str`.
|
||||||
|
2: function return types are declared like `char* function(...);`
|
||||||
|
|
||||||
|
this syntax forces the most readable code. ex:
|
||||||
|
|
||||||
|
struct list* new_list(char *name);
|
||||||
|
|
||||||
|
this format cleary states that name is a pointer of type char and the function returns
|
||||||
|
a pointer to a struct list
|
||||||
|
|
||||||
|
Naming
|
||||||
|
------
|
||||||
|
|
||||||
|
* Never use CamelCase. UPPERCASE for constants and lowercase for variables,functions,macros. words is separated by underscore.
|
||||||
|
|
||||||
|
* API functions (that have a prototype in a header file) should be prefixed with the header filename.
|
||||||
|
One exception exist and that is when the functionality is realy lowlevel and/or generic enough that it
|
||||||
|
would be redundant to include a prefix. an example of this is a fatal() or die() function that may be prototyped in misc.h.
|
||||||
|
|
||||||
|
* Headerguard defines is written like __PATH_TO_THIS_HEADER_H
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
All API's should be externaly documented in the doc/ directory.
|
||||||
|
|
||||||
|
Things to keep in mind when modify or write code
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
include and change the comment found in TEMPLATE file, at the top of the .c/.h file
|
||||||
|
|
||||||
|
|
@ -1,24 +1,16 @@
|
||||||
|
/* arch/db.h - database API
|
||||||
/*
|
|
||||||
* Copyright (C) 2010 Archived
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* Copyright (C) 2010 Fredric Nilsson <fredric@unknown.org>
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* it under the terms of the GNU General Public License as published by
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* GNU General Public License for more details.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ARCH_DB_H
|
#ifndef __ARCH_DB_H
|
||||||
|
|
||||||
#define _ARCH_DB_H
|
#define __ARCH_DB_H
|
||||||
|
|
||||||
int arch_db_init(char *host, char *username, char *password, char *database, char *table);
|
int arch_db_init(char *host, char *username, char *password, char *database, char *table);
|
||||||
|
|
||||||
|
|
@ -30,4 +22,4 @@ int arch_db_truncate();
|
||||||
|
|
||||||
void arch_db_close();
|
void arch_db_close();
|
||||||
|
|
||||||
#endif /* _DB_DATABASE_H */
|
#endif /* __ARCH_DB_H */
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,11 @@
|
||||||
/*
|
/* arch/mysql.c - Mysql implementation
|
||||||
* arch/mysql.c - Handles database operations
|
|
||||||
*
|
|
||||||
* (C) Copyright 2010 Henrik Hautakoski <henrik@unknown.org>
|
|
||||||
* (C) Copyright 2010 Fredric Nilsson <fredric@unknown.org>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2010 Fredric Nilsson <fredric@unknown.org>
|
||||||
*
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mysql/mysql.h>
|
#include <mysql/mysql.h>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* common/path.c - path string handling routines
|
/* common/path.c - path handling routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Hernrik Hautakoski <henrik.hautakoski@gmail.com>
|
* Copyright (C) 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,12 @@
|
||||||
|
/* common/path.h - path handling routines
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __COMMON_PATH_H
|
#ifndef __COMMON_PATH_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
|
/* fs/notify.h - filesystem notification API
|
||||||
/*
|
|
||||||
* Archived file-system notification
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Archived
|
* (C) Copyright 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
|
* (C) Copyright 2010 Fredric Nilsson <fredric@unknown.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _FS_NOTIFY_H
|
#ifndef _FS_NOTIFY_H
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,13 @@
|
||||||
/*
|
/* fs/notify_event.c - notify event implementation
|
||||||
* Copyright (C) 2010 Archived
|
*
|
||||||
|
* (C) Copyright 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
|
* (C) Copyright 2010 Fredric Nilsson <fredric@unknown.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
/*
|
/* fs/notify_event.h - event data structure and operation's for notify API
|
||||||
* event data-structure and operation's for notify API
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Archived
|
* (C) Copyright 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
|
* (C) Copyright 2010 Fredric Nilsson <fredric@unknown.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _NOTIFY_EVENT_H
|
#ifndef _NOTIFY_EVENT_H
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,12 @@
|
||||||
/*
|
/* fs/notify_inotify.c - inotify implementation
|
||||||
* Copyright (C) 2010 Archived
|
*
|
||||||
|
* (C) Copyright 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
|
* (C) Copyright 2010 Fredric Nilsson <fredric@unknown.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -298,5 +292,3 @@ int notify_is_ready() {
|
||||||
|
|
||||||
return bytes > 512;
|
return bytes > 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,12 @@
|
||||||
|
/* fs/tree.c - Filesystem traversal
|
||||||
/*
|
|
||||||
* -- tree.c
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Archived
|
* (C) Copyright 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -201,6 +190,5 @@ struct entry* tree_next_ent(struct tree *tree) {
|
||||||
tree->ent.base = tree->path;
|
tree->ent.base = tree->path;
|
||||||
tree->ent.name = &ent->d_name[0];
|
tree->ent.name = &ent->d_name[0];
|
||||||
|
|
||||||
|
|
||||||
return &tree->ent;
|
return &tree->ent;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,12 @@
|
||||||
|
/* fs/tree.h - Filesystem traversal
|
||||||
|
*
|
||||||
|
* (C) Copyright 2010 Henrik Hautakoski <henrik.hautakoski@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _FS_TREE_H
|
#ifndef _FS_TREE_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
/*
|
/* indexer.c
|
||||||
* Copyright (C) 2010 Archived
|
*
|
||||||
|
* (C) Copyright 2010 Henrik Hautakoski <henrik@unknown.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
|
|
|
||||||
Reference in a new issue