projects
/
crypto.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
63ff5ec
)
updates
author
Pekka Riikonen
<priikone@silcnet.org>
Fri, 29 Sep 2006 06:42:55 +0000
(06:42 +0000)
committer
Pekka Riikonen
<priikone@silcnet.org>
Fri, 29 Sep 2006 06:42:55 +0000
(06:42 +0000)
doc/CodingStyle
patch
|
blob
|
history
diff --git
a/doc/CodingStyle
b/doc/CodingStyle
index 6b6b2ff9f572978dd02b41f4c7303611e5d322bc..9160adcc60297fbff4599f0df7fb35c119de51b2 100644
(file)
--- a/
doc/CodingStyle
+++ b/
doc/CodingStyle
@@
-15,7
+15,7
@@
Naming
Generic naming
Generic naming
-All identifiers, whether they defines, functions or something else, with
+All identifiers, whether they
are
defines, functions or something else, with
exception of variables, has a common naming convention. Usually all
identifiers use `silc' prefix to indicate that the identifier is part of
SILC distribution. For example, silc_server_init(), SILC_PACKET_TYPE_ERROR,
exception of variables, has a common naming convention. Usually all
identifiers use `silc' prefix to indicate that the identifier is part of
SILC distribution. For example, silc_server_init(), SILC_PACKET_TYPE_ERROR,
@@
-95,32
+95,40
@@
And used as `struct SilcDummyStruct *dummy'. However, this is quite
rarely used in the SILC, instead structures are typedef'd as following
later. When structure is used as object they are defined as follows,
rarely used in the SILC, instead structures are typedef'd as following
later. When structure is used as object they are defined as follows,
- typedef struct SilcDummy
Stru
ct {
+ typedef struct SilcDummy
Obje
ct {
unsigned char *dummy;
unsigned int flags;
void (*callback)(void *, unsigned int);
unsigned char *dummy;
unsigned int flags;
void (*callback)(void *, unsigned int);
- } SilcDummy
Obje
ct;
+ } SilcDummy
Stru
ct;
-If the SilcDummy
Stru
ct is not needed it may be omitted (which is very
+If the SilcDummy
Obje
ct is not needed it may be omitted (which is very
common in SILC code), leaving,
typedef struct {
unsigned char *dummy;
unsigned int flags;
void (*callback)(void *, unsigned int);
common in SILC code), leaving,
typedef struct {
unsigned char *dummy;
unsigned int flags;
void (*callback)(void *, unsigned int);
- } SilcDummy
Obje
ct;
+ } SilcDummy
Stru
ct;
Finally, it is common that structures are typedef'd pointers as they
are very flexible to use,
Finally, it is common that structures are typedef'd pointers as they
are very flexible to use,
- typedef SilcDummyObject *SilcDummy;
+ typedef SilcDummyStruct *SilcDummy;
+
+or,
+
+ typedef struct {
+ unsigned char *dummy;
+ unsigned int flags;
+ void (*callback)(void *, unsigned int);
+ } SilcDummyStruct, *SilcDummy;
It is common in SILC to typedef structures instead of defining name
for the structure. In this case the structure may be used without
defining `struct' to the code, For example,
It is common in SILC to typedef structures instead of defining name
for the structure. In this case the structure may be used without
defining `struct' to the code, For example,
- SilcDummy
Obje
ct dummy_obj;
- SilcDummy
Obje
ct *dummy;
+ SilcDummy
Stru
ct dummy_obj;
+ SilcDummy
Stru
ct *dummy;
If the structure has a pointer typedef then they are defined as normal
variables but for real they are pointers, For example,
If the structure has a pointer typedef then they are defined as normal
variables but for real they are pointers, For example,
@@
-191,15
+199,11
@@
function. All inline functions in SILC are defined and written into
header files. Inline functions must be defined in following manner
in the header file,
header files. Inline functions must be defined in following manner
in the header file,
-
extern
inline void silc_dummy_inline(unsigned int flags)
+
static
inline void silc_dummy_inline(unsigned int flags)
{
doing_little_dummy_things;
}
{
doing_little_dummy_things;
}
-Because the function is defined as extern they can be included into
-public header files. Do not forget to define inline function as extern.
-There are no explicit prototype definitions for inline functions.
-
Indentation
===========
Indentation
===========
@@
-214,7
+218,7
@@
A tip for those who think that these long function names etc are just
too long to type, consider using dynamic abbreviation found in Emacs.
With this cool feature you only have type some part of the string and
then use the dabbrev to find the rest of the string. I guess, by
too long to type, consider using dynamic abbreviation found in Emacs.
With this cool feature you only have type some part of the string and
then use the dabbrev to find the rest of the string. I guess, by
-default it is M-/ in Emacs but I have b
inde
d it into Shift-TAB so it
+default it is M-/ in Emacs but I have b
oun
d it into Shift-TAB so it
is fast to use when typing.
is fast to use when typing.
@@
-258,6
+262,9
@@
More examples,
something_else;
}
something_else;
}
+ if (condition)
+ oneline_no_braces;
+
Commenting
==========
Commenting
==========
@@
-300,7
+307,7
@@
that looks good. Here are some issues on general appearance.
`==', `+', etc. Also, when setting a value to variable be
sure to set spaces around `='. When writing argument list
to a function, space should follow each of the comma in the
`==', `+', etc. Also, when setting a value to variable be
sure to set spaces around `='. When writing argument list
to a function, space should follow each of the comma in the
- list. However, do not use spaces with parenthesis, for
+ list. However, do not use spaces with
in
parenthesis, for
example, `if ( !k )' is not accepted.
o If you are not sure about how something should be done or
example, `if ( !k )' is not accepted.
o If you are not sure about how something should be done or
@@
-317,9
+324,9
@@
Now, this really isn't that important but some sort of header should be in
all source files.
In the start of the source files should include the #include's that are
all source files.
In the start of the source files should include the #include's that are
-needed. All library source files must include `silc
includes
.h', this is
-a must. Client source file must include at least `
clientincludes
.h' and
-server source file must include `s
erverincludes
.h'. Additional include's
+needed. All library source files must include `silc.h', this is
+a must. Client source file must include at least `
silcclient
.h' and
+server source file must include `s
ilcserver
.h'. Additional include's
may be added as well, however, system specific includes should not be
added directly (unless it is really a special case). Go see any source
file as an example.
may be added as well, however, system specific includes should not be
added directly (unless it is really a special case). Go see any source
file as an example.