summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-05-30 18:39:27 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-05-31 01:43:37 +0200
commitcaf0df2dde2f39c3b271a79fab9358475de6a6e4 (patch)
treeda4b3b2e529f06097ea921c4bd736994f76483b2 /source3
parent3aa9eead2702880b1f645793b48f4e7d9e0fc17c (diff)
downloadsamba-caf0df2dde2f39c3b271a79fab9358475de6a6e4.tar.gz
samba-caf0df2dde2f39c3b271a79fab9358475de6a6e4.tar.bz2
samba-caf0df2dde2f39c3b271a79fab9358475de6a6e4.zip
s3-build Specify more of the smbconf dependencies
This brings more functions into util_names.c, and util_names.c into PARAM_WITHOUT_REG_SRC. This is not yet a full list, that would formalise the implicit dependency loop. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Tue May 31 01:43:37 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util.c162
-rw-r--r--source3/lib/util_names.c163
-rwxr-xr-xsource3/wscript_build6
3 files changed, 165 insertions, 166 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index e8a360fd3a..f86f51790f 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -72,87 +72,6 @@ void set_Protocol(enum protocol_types p)
static enum remote_arch_types ra_type = RA_UNKNOWN;
-/***********************************************************************
- Definitions for all names.
-***********************************************************************/
-
-static char *smb_scope;
-static int smb_num_netbios_names;
-static char **smb_my_netbios_names;
-
-/***********************************************************************
- Allocate and set scope. Ensure upper case.
-***********************************************************************/
-
-bool set_global_scope(const char *scope)
-{
- SAFE_FREE(smb_scope);
- smb_scope = SMB_STRDUP(scope);
- if (!smb_scope)
- return False;
- strupper_m(smb_scope);
- return True;
-}
-
-/*********************************************************************
- Ensure scope is never null string.
-*********************************************************************/
-
-const char *global_scope(void)
-{
- if (!smb_scope)
- set_global_scope("");
- return smb_scope;
-}
-
-static void free_netbios_names_array(void)
-{
- int i;
-
- for (i = 0; i < smb_num_netbios_names; i++)
- SAFE_FREE(smb_my_netbios_names[i]);
-
- SAFE_FREE(smb_my_netbios_names);
- smb_num_netbios_names = 0;
-}
-
-static bool allocate_my_netbios_names_array(size_t number)
-{
- free_netbios_names_array();
-
- smb_num_netbios_names = number + 1;
- smb_my_netbios_names = SMB_MALLOC_ARRAY( char *, smb_num_netbios_names );
-
- if (!smb_my_netbios_names)
- return False;
-
- memset(smb_my_netbios_names, '\0', sizeof(char *) * smb_num_netbios_names);
- return True;
-}
-
-static bool set_my_netbios_names(const char *name, int i)
-{
- SAFE_FREE(smb_my_netbios_names[i]);
-
- smb_my_netbios_names[i] = SMB_STRDUP(name);
- if (!smb_my_netbios_names[i])
- return False;
- strupper_m(smb_my_netbios_names[i]);
- return True;
-}
-
-/***********************************************************************
- Free memory allocated to global objects
-***********************************************************************/
-
-void gfree_names(void)
-{
- gfree_netbios_names();
- SAFE_FREE( smb_scope );
- free_netbios_names_array();
- free_local_machine_name();
-}
-
void gfree_all( void )
{
gfree_names();
@@ -162,87 +81,6 @@ void gfree_all( void )
gfree_debugsyms();
}
-const char *my_netbios_names(int i)
-{
- return smb_my_netbios_names[i];
-}
-
-bool set_netbios_aliases(const char **str_array)
-{
- size_t namecount;
-
- /* Work out the max number of netbios aliases that we have */
- for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ )
- ;
-
- if ( global_myname() && *global_myname())
- namecount++;
-
- /* Allocate space for the netbios aliases */
- if (!allocate_my_netbios_names_array(namecount))
- return False;
-
- /* Use the global_myname string first */
- namecount=0;
- if ( global_myname() && *global_myname()) {
- set_my_netbios_names( global_myname(), namecount );
- namecount++;
- }
-
- if (str_array) {
- size_t i;
- for ( i = 0; str_array[i] != NULL; i++) {
- size_t n;
- bool duplicate = False;
-
- /* Look for duplicates */
- for( n=0; n<namecount; n++ ) {
- if( strequal( str_array[i], my_netbios_names(n) ) ) {
- duplicate = True;
- break;
- }
- }
- if (!duplicate) {
- if (!set_my_netbios_names(str_array[i], namecount))
- return False;
- namecount++;
- }
- }
- }
- return True;
-}
-
-/****************************************************************************
- Common name initialization code.
-****************************************************************************/
-
-bool init_names(void)
-{
- int n;
-
- if (global_myname() == NULL || *global_myname() == '\0') {
- if (!set_global_myname(myhostname())) {
- DEBUG( 0, ( "init_names: malloc fail.\n" ) );
- return False;
- }
- }
-
- if (!set_netbios_aliases(lp_netbios_aliases())) {
- DEBUG( 0, ( "init_names: malloc fail.\n" ) );
- return False;
- }
-
- set_local_machine_name(global_myname(),false);
-
- DEBUG( 5, ("Netbios name list:-\n") );
- for( n=0; my_netbios_names(n); n++ ) {
- DEBUGADD( 5, ("my_netbios_names[%d]=\"%s\"\n",
- n, my_netbios_names(n) ) );
- }
-
- return( True );
-}
-
/*******************************************************************
Check if a file exists - call vfs_file_exist for samba files.
********************************************************************/
diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c
index bd6e5c1202..8170c8bb11 100644
--- a/source3/lib/util_names.c
+++ b/source3/lib/util_names.c
@@ -6,7 +6,7 @@
Copyright (C) Simo Sorce 2001
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
Copyright (C) James Peach 2006
- Copyright (C) Andrew Bartlett 2010
+ Copyright (C) Andrew Bartlett 2010-2011
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
@@ -24,8 +24,169 @@
#include "includes.h"
+/***********************************************************************
+ Definitions for all names.
+***********************************************************************/
+
static char *smb_myname;
static char *smb_myworkgroup;
+static char *smb_scope;
+static int smb_num_netbios_names;
+static char **smb_my_netbios_names;
+
+/***********************************************************************
+ Allocate and set scope. Ensure upper case.
+***********************************************************************/
+
+bool set_global_scope(const char *scope)
+{
+ SAFE_FREE(smb_scope);
+ smb_scope = SMB_STRDUP(scope);
+ if (!smb_scope)
+ return False;
+ strupper_m(smb_scope);
+ return True;
+}
+
+/*********************************************************************
+ Ensure scope is never null string.
+*********************************************************************/
+
+const char *global_scope(void)
+{
+ if (!smb_scope)
+ set_global_scope("");
+ return smb_scope;
+}
+
+static void free_netbios_names_array(void)
+{
+ int i;
+
+ for (i = 0; i < smb_num_netbios_names; i++)
+ SAFE_FREE(smb_my_netbios_names[i]);
+
+ SAFE_FREE(smb_my_netbios_names);
+ smb_num_netbios_names = 0;
+}
+
+static bool allocate_my_netbios_names_array(size_t number)
+{
+ free_netbios_names_array();
+
+ smb_num_netbios_names = number + 1;
+ smb_my_netbios_names = SMB_MALLOC_ARRAY( char *, smb_num_netbios_names );
+
+ if (!smb_my_netbios_names)
+ return False;
+
+ memset(smb_my_netbios_names, '\0', sizeof(char *) * smb_num_netbios_names);
+ return True;
+}
+
+static bool set_my_netbios_names(const char *name, int i)
+{
+ SAFE_FREE(smb_my_netbios_names[i]);
+
+ smb_my_netbios_names[i] = SMB_STRDUP(name);
+ if (!smb_my_netbios_names[i])
+ return False;
+ strupper_m(smb_my_netbios_names[i]);
+ return True;
+}
+
+/***********************************************************************
+ Free memory allocated to global objects
+***********************************************************************/
+
+void gfree_names(void)
+{
+ gfree_netbios_names();
+ SAFE_FREE( smb_scope );
+ free_netbios_names_array();
+ free_local_machine_name();
+}
+
+const char *my_netbios_names(int i)
+{
+ return smb_my_netbios_names[i];
+}
+
+bool set_netbios_aliases(const char **str_array)
+{
+ size_t namecount;
+
+ /* Work out the max number of netbios aliases that we have */
+ for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ )
+ ;
+
+ if ( global_myname() && *global_myname())
+ namecount++;
+
+ /* Allocate space for the netbios aliases */
+ if (!allocate_my_netbios_names_array(namecount))
+ return False;
+
+ /* Use the global_myname string first */
+ namecount=0;
+ if ( global_myname() && *global_myname()) {
+ set_my_netbios_names( global_myname(), namecount );
+ namecount++;
+ }
+
+ if (str_array) {
+ size_t i;
+ for ( i = 0; str_array[i] != NULL; i++) {
+ size_t n;
+ bool duplicate = False;
+
+ /* Look for duplicates */
+ for( n=0; n<namecount; n++ ) {
+ if( strequal( str_array[i], my_netbios_names(n) ) ) {
+ duplicate = True;
+ break;
+ }
+ }
+ if (!duplicate) {
+ if (!set_my_netbios_names(str_array[i], namecount))
+ return False;
+ namecount++;
+ }
+ }
+ }
+ return True;
+}
+
+/****************************************************************************
+ Common name initialization code.
+****************************************************************************/
+
+bool init_names(void)
+{
+ int n;
+
+ if (global_myname() == NULL || *global_myname() == '\0') {
+ if (!set_global_myname(myhostname())) {
+ DEBUG( 0, ( "init_names: malloc fail.\n" ) );
+ return False;
+ }
+ }
+
+ if (!set_netbios_aliases(lp_netbios_aliases())) {
+ DEBUG( 0, ( "init_names: malloc fail.\n" ) );
+ return False;
+ }
+
+ set_local_machine_name(global_myname(),false);
+
+ DEBUG( 5, ("Netbios name list:-\n") );
+ for( n=0; my_netbios_names(n); n++ ) {
+ DEBUGADD( 5, ("my_netbios_names[%d]=\"%s\"\n",
+ n, my_netbios_names(n) ) );
+ }
+
+ return( True );
+}
/***********************************************************************
Allocate and set myname. Ensure upper case.
diff --git a/source3/wscript_build b/source3/wscript_build
index 7ca39ad2af..842d95e306 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -74,7 +74,7 @@ LIB_SRC = '''
lib/wins_srv.c
lib/util_sid.c
lib/util_file.c
- lib/util.c lib/util_cmdline.c lib/util_names.c
+ lib/util.c lib/util_cmdline.c
lib/util_sock.c lib/sock_exec.c
lib/substitute.c lib/substitute_generic.c
lib/ms_fnmatch.c
@@ -98,7 +98,7 @@ POPT_LIB_SRC = '''lib/popt_common.c'''
PARAM_UTIL_SRC = '''param/util.c'''
PARAM_WITHOUT_REG_SRC = '''param/loadparm.c param/loadparm_server_role.c
- lib/sharesec.c lib/ldap_debug_handler.c'''
+ lib/sharesec.c lib/ldap_debug_handler.c lib/util_names.c'''
KRBCLIENT_SRC = '''libads/kerberos.c libads/ads_status.c libsmb/clikrb5.c'''
@@ -865,7 +865,7 @@ bld.SAMBA3_SUBSYSTEM('LIBAFS_SETTOKEN',
bld.SAMBA3_LIBRARY('smbconf',
source=LIB_SMBCONF_SRC,
deps='''LIBSMBCONF smbregistry REG_SMBCONF talloc PARAM_WITHOUT_REG
- util_reg samba-util-common errors3 CHARSET''',
+ util_reg samba-util-common errors3 CHARSET SAMBA_VERSION''',
public_headers='../lib/smbconf/smbconf.h',
vnum='0')