param: correctly use param_table.c as a regular C file
authorGarming Sam <garming@catalyst.net.nz>
Sun, 23 Feb 2014 23:31:43 +0000 (12:31 +1300)
committerJeremy Allison <jra@samba.org>
Wed, 7 May 2014 17:49:16 +0000 (19:49 +0200)
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/param/loadparm.c
lib/param/loadparm.h
lib/param/param_table.c
lib/param/wscript_build
python/samba/tests/docs.py
source3/param/loadparm.c

index 811d802779da5a01800ae41516f9c5246bbb9eff..d503534eac8c092e632d9a220968832340352e39 100644 (file)
@@ -75,13 +75,7 @@ static bool defaults_saved = false;
 
 #include "lib/param/param_global.h"
 
-#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
-
-#ifndef N_
-#define N_(x) x
-#endif
-
-#include "lib/param/param_table.c"
+#define NUMPARAMETERS (num_parameters())
 
 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
 {
index 9be01ef7b969b88d2be0f2bb6254bec8f8b3530f..4b3e68e2f6628b772f3fb9ef42b08b893ea7e055 100644 (file)
@@ -84,6 +84,8 @@ struct parm_struct {
        } def;
 };
 
+extern struct parm_struct parm_table[];
+
 struct file_lists {
        struct file_lists *next;
        char *name;
@@ -282,6 +284,8 @@ int getservicebyname(const char *, struct loadparm_service *);
 bool lp_include(struct loadparm_context *, int, const char *, char **);
 void init_printer_values(TALLOC_CTX *, struct loadparm_service *);
 
+int num_parameters(void);
+
 /**
  * Check if two parameters are equal.
  */
index 8df7d1b5fa17ef3642ae5236baa0263e943cfb99..578b154e4b7e70a6bc26f0cdba8c467441dc0dca 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "includes.h"
+#include "lib/param/param.h"
+#include "lib/param/loadparm.h"
+#include "lib/param/param_global.h"
+#include "libcli/smb/smb_constants.h"
+
+#ifndef N_
+#define N_(x) x
+#endif
+
 static const struct enum_list enum_protocol[] = {
        {PROTOCOL_SMB2_10, "SMB2"}, /* for now keep PROTOCOL_SMB2_10 */
        {PROTOCOL_SMB3_00, "SMB3"}, /* for now keep PROTOCOL_SMB3_00 */
@@ -276,7 +286,7 @@ static const struct enum_list enum_case[] = {
 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
 
 
-static struct parm_struct parm_table[] = {
+struct parm_struct parm_table[] = {
        {N_("Base Options"), P_SEP, P_SEPARATOR},
 
        {
@@ -4398,3 +4408,7 @@ static struct parm_struct parm_table[] = {
        {NULL,  P_BOOL,  P_NONE,  0,  NULL,  NULL,  0}
 };
 
+int num_parameters(void)
+{
+       return (sizeof(parm_table) / sizeof(struct parm_struct));
+}
index 3c72a73dffb2472dd8f4c06bca0aa14cb2992552..69746bc83eee1092081a4cd38fe0bdc71b3b1708 100644 (file)
@@ -30,7 +30,7 @@ bld.SAMBA_LIBRARY('server-role',
                   private_library=True)
 
 bld.SAMBA_LIBRARY('samba-hostconfig',
-       source='loadparm.c generic.c util.c',
+       source='loadparm.c generic.c util.c param_table.c',
        pc_files='samba-hostconfig.pc',
        vnum='0.0.1',
        deps='DYNCONFIG server-role tdb',
index 31c66a61a7d950ddc85f7e9b7279d0e40aa54e39..b11e4f197223fd4b1083d03714632a00fcd6f707 100644 (file)
@@ -66,7 +66,7 @@ def get_implementation_parameters(sourcedir):
         # burn through the preceding lines
         while True:
             l = f.readline()
-            if l.startswith("static struct parm_struct parm_table"):
+            if l.startswith("struct parm_struct parm_table"):
                 break
 
         for l in f.readlines():
index d5f7bacf1b05f6f512513e5c1cd09791f2997f20..100ef8d2e94cb4753efc24e6226666ed5de0779a 100644 (file)
@@ -258,15 +258,13 @@ static bool bInGlobalSection = true;
 static bool bGlobalOnly = false;
 static struct file_lists *file_lists = NULL;
 
-#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
+#define NUMPARAMETERS (num_parameters())
 
 static void set_allowed_client_auth(void);
 
 static bool lp_set_cmdline_helper(const char *pszParmName, const char *pszParmValue, bool store_values);
 static void free_param_opts(struct parmlist_entry **popts);
 
-#include "lib/param/param_table.c"
-
 /* this is used to prevent lots of mallocs of size 1 */
 static const char null_string[] = "";