diff options
Diffstat (limited to 'docs/htmldocs/Samba3-Developers-Guide/CodingSuggestions.html')
-rw-r--r-- | docs/htmldocs/Samba3-Developers-Guide/CodingSuggestions.html | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/docs/htmldocs/Samba3-Developers-Guide/CodingSuggestions.html b/docs/htmldocs/Samba3-Developers-Guide/CodingSuggestions.html index 44a01f28ba..f4c5744e3a 100644 --- a/docs/htmldocs/Samba3-Developers-Guide/CodingSuggestions.html +++ b/docs/htmldocs/Samba3-Developers-Guide/CodingSuggestions.html @@ -1,4 +1,4 @@ -<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 6. Coding Suggestions</title><link rel="stylesheet" href="../samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="SAMBA Developers Guide"><link rel="up" href="pt02.html" title="Part II. Samba Basics"><link rel="prev" href="internals.html" title="Chapter 5. Samba Internals"><link rel="next" href="contributing.html" title="Chapter 7. Contributing code"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 6. Coding Suggestions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="internals.html">Prev</a> </td><th width="60%" align="center">Part II. Samba Basics</th><td width="20%" align="right"> <a accesskey="n" href="contributing.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="CodingSuggestions"></a>Chapter 6. Coding Suggestions</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Steve</span> <span class="surname">French</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Simo</span> <span class="surname">Sorce</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Andrew</span> <span class="surname">Bartlett</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Tim</span> <span class="surname">Potter</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Martin</span> <span class="surname">Pool</span></h3></div></div></div></div><p> +<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 6. Coding Suggestions</title><link rel="stylesheet" href="../samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="SAMBA Developers Guide"><link rel="up" href="pt02.html" title="Part II. Samba Basics"><link rel="prev" href="internals.html" title="Chapter 5. Samba Internals"><link rel="next" href="contributing.html" title="Chapter 7. Contributing code"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 6. Coding Suggestions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="internals.html">Prev</a> </td><th width="60%" align="center">Part II. Samba Basics</th><td width="20%" align="right"> <a accesskey="n" href="contributing.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 6. Coding Suggestions"><div class="titlepage"><div><div><h2 class="title"><a name="CodingSuggestions"></a>Chapter 6. Coding Suggestions</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Steve</span> <span class="surname">French</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Simo</span> <span class="surname">Sorce</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Andrew</span> <span class="surname">Bartlett</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Tim</span> <span class="surname">Potter</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Martin</span> <span class="surname">Pool</span></h3></div></div></div></div><p> So you want to add code to Samba ... </p><p> One of the daunting tasks facing a programmer attempting to write code for @@ -39,91 +39,91 @@ tries to support, not all of which follow the SNIA CIFS Technical Reference Standard) perfectly. </p><p> Here are some other suggestions: -</p><div class="orderedlist"><ol type="1"><li><p> +</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p> use d_printf instead of printf for display text reason: enable auto-substitution of translated language text -</p></li><li><p> +</p></li><li class="listitem"><p> use SAFE_FREE instead of free reason: reduce traps due to null pointers -</p></li><li><p> +</p></li><li class="listitem"><p> don't use bzero use memset, or ZERO_STRUCT and ZERO_STRUCTP macros reason: not POSIX -</p></li><li><p> +</p></li><li class="listitem"><p> don't use strcpy and strlen (use safe_* equivalents) reason: to avoid traps due to buffer overruns -</p></li><li><p> +</p></li><li class="listitem"><p> don't use getopt_long, use popt functions instead reason: portability -</p></li><li><p> +</p></li><li class="listitem"><p> explicitly add const qualifiers on parm passing in functions where parm is input only (somewhat controversial but const can be #defined away) -</p></li><li><p> +</p></li><li class="listitem"><p> when passing a va_list as an arg, or assigning one to another please use the VA_COPY() macro reason: on some platforms, va_list is a struct that must be initialized in each function...can SEGV if you don't. -</p></li><li><p> +</p></li><li class="listitem"><p> discourage use of threads reason: portability (also see architecture.doc) -</p></li><li><p> +</p></li><li class="listitem"><p> don't explicitly include new header files in C files - new h files should be included by adding them once to includes.h reason: consistency -</p></li><li><p> +</p></li><li class="listitem"><p> don't explicitly extern functions (they are autogenerated by "make proto" into proto.h) reason: consistency -</p></li><li><p> +</p></li><li class="listitem"><p> use endian safe macros when unpacking SMBs (see byteorder.h and internals.doc) reason: not everyone uses Intel -</p></li><li><p> +</p></li><li class="listitem"><p> Note Unicode implications of charset handling (see internals.doc). See pull_* and push_* and convert_string functions. reason: Internationalization -</p></li><li><p> +</p></li><li class="listitem"><p> Don't assume English only reason: See above -</p></li><li><p> +</p></li><li class="listitem"><p> Try to avoid using in/out parameters (functions that return data which overwrites input parameters) reason: Can cause stability problems -</p></li><li><p> +</p></li><li class="listitem"><p> Ensure copyright notices are correct, don't append Tridge's name to code that he didn't write. If you did not write the code, make sure that it can coexist with the rest of the Samba GPLed code. -</p></li><li><p> +</p></li><li class="listitem"><p> Consider usage of DATA_BLOBs for length specified byte-data. reason: stability -</p></li><li><p> +</p></li><li class="listitem"><p> Take advantage of tdbs for database like function reason: consistency -</p></li><li><p> +</p></li><li class="listitem"><p> Don't access the SAM_ACCOUNT structure directly, they should be accessed via pdb_get...() and pdb_set...() functions. reason: stability, consistency -</p></li><li><p> +</p></li><li class="listitem"><p> Don't check a password directly against the passdb, always use the check_password() interface. reason: long term pluggability -</p></li><li><p> +</p></li><li class="listitem"><p> Try to use asprintf rather than pstrings and fstrings where possible -</p></li><li><p> +</p></li><li class="listitem"><p> Use normal C comments / * instead of C++ comments // like this. Although the C++ comment format is part of the C99 standard, some older vendor C compilers do not accept it. -</p></li><li><p> +</p></li><li class="listitem"><p> Try to write documentation for API functions and structures explaining the point of the code, the way it should be used, and any special conditions or results. Mark these with a double-star comment start / ** so that they can be picked up by Doxygen, as in this file. -</p></li><li><p> +</p></li><li class="listitem"><p> Keep the scope narrow. This means making functions/variables static whenever possible. We don't want our namespace polluted. Each module should have a minimal number of externally visible functions or variables. -</p></li><li><p> +</p></li><li class="listitem"><p> Use function pointers to keep knowledge about particular pieces of code isolated in one place. We don't want a particular piece of functionality to be spread out across lots of places - that makes @@ -131,7 +131,7 @@ Here are some other suggestions: and use tables containing function pointers to implement specific functionality. This is particularly important for command interpreters. -</p></li><li><p> +</p></li><li class="listitem"><p> Think carefully about what it will be like for someone else to add to and maintain your code. If it would be hard for someone else to maintain then do it another way. |