string substitution functions
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Gerald Carter 2006
-
+
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.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
r = p + 3;
copylen = q - r;
-
+
/* reserve space for use later add %$() chars */
if ( (envname = (char *)SMB_MALLOC(copylen + 1 + 4)) == NULL ) {
return NULL;
}
-
+
strncpy(envname,r,copylen);
envname[copylen] = '\0';
envname[copylen] = '\0';
r = realloc_string_sub(str, envname, envval);
SAFE_FREE(envname);
-
+
return r;
}
DOM_SID sid;
fstring tmp;
char *sid_string;
-
+
if ( !secrets_fetch_domain_sid( lp_workgroup(), &sid ) ) {
return NULL;
}
-
+
sid_string = SMB_STRDUP( sid_to_fstring( tmp, &sid ) );
-
+
if ( !sid_string ) {
DEBUG(0,("longvar_domainsid: failed to dup SID string!\n"));
}
-
+
return sid_string;
}
static char *get_longvar_val( const char *varname )
{
int i;
-
+
DEBUG(7,("get_longvar_val: expanding variable [%s]\n", varname));
-
+
for ( i=0; longvar_table[i].name; i++ ) {
if ( strequal( longvar_table[i].name, varname ) ) {
return longvar_table[i].fn();
}
}
-
+
return NULL;
}
char *str, size_t len)
{
char *s;
-
+
if ( (s = alloc_sub_basic( smb_name, domain_name, str )) != NULL ) {
strncpy( str, s, len );
}
-
+
SAFE_FREE( s );
-
}
/****************************************************************************
const char *domain_name, const char *str)
{
char *a, *t;
-
+
if ( (a = alloc_sub_basic(smb_name, domain_name, str)) == NULL ) {
return NULL;
}
TALLOC_CTX *tmp_ctx = NULL;
/* workaround to prevent a crash while looking at bug #687 */
-
+
if (!str) {
DEBUG(0,("alloc_sub_basic: NULL source string! This should not happen\n"));
return NULL;
}
-
+
a_string = SMB_STRDUP(str);
if (a_string == NULL) {
DEBUG(0, ("alloc_sub_basic: Out of memory!\n"));
DEBUG(0, ("talloc_sub_specified: Out of memory!\n"));
goto done;
}
-
+
for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
-
+
b = a_string;
-
+
switch (*(p+1)) {
case 'U' :
a_string = talloc_string_sub(
DEBUG(0, ("alloc_sub_advanced: Out of memory!\n"));
return NULL;
}
-
+
for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
-
+
b = a_string;
-
+
switch (*(p+1)) {
case 'N' :
a_string = realloc_string_sub(a_string, "%N", automount_server(user));
case 'u':
a_string = realloc_string_sub(a_string, "%u", user);
break;
-
+
/* Patch from jkf@soton.ac.uk Left the %N (NIS
* server name) in standard_sub_basic as it is
* a feature for logon servers, hence uses the
a_string = realloc_string_sub(a_string, "%p",
automount_path(servicename));
break;
-
+
default:
break;
}
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.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
SMB_STRUCT_STAT st;
if (!sbuf)
sbuf = &st;
-
+
if (sys_stat(fname,sbuf) != 0)
return(False);
if (!DEBUGLVL(5))
return;
-
+
DEBUG(5,("size=%d\nsmb_com=0x%x\nsmb_rcls=%d\nsmb_reh=%d\nsmb_err=%d\nsmb_flg=%d\nsmb_flg2=%d\n",
smb_len(buf),
(int)CVAL(buf,smb_com),
for (i=0;i<(int)CVAL(buf,smb_wct);i++)
DEBUGADD(5,("smb_vwv[%2d]=%5d (0x%X)\n",i,
SVAL(buf,smb_vwv+2*i),SVAL(buf,smb_vwv+2*i)));
-
+
bcc = (int)SVAL(buf,smb_vwv+2*(CVAL(buf,smb_wct)));
DEBUGADD(5,("smb_bcc=%d\n",bcc));
GetTimeOfDay(&t1);
t2 = t1;
-
+
while (tdiff < t) {
tval.tv_sec = (t-tdiff)/1000;
tval.tv_usec = 1000*((t-tdiff)%1000);
return(PROTOCOL_COREPLUS);
if (strequal(str,"CORE+"))
return(PROTOCOL_COREPLUS);
-
+
DEBUG(0,("Unrecognised protocol level %s\n",str));
-
+
return(def);
}
DEBUG(0, ("BACKTRACE: %lu stack frames:\n",
(unsigned long)backtrace_size));
-
+
if (backtrace_strings) {
int i;
if (!p)
return(NULL);
-
+
ptr = (SMB_STRUCT_DIRENT *)sys_readdir(p);
if (!ptr)
return(NULL);
remove a potentially expensive call to mask_match
if possible.
********************************************************************/
-
+
void set_namearray(name_compare_entry **ppname_array, const char *namelist)
{
char *name_end;
nameptr = name_end + 1;
i++;
}
-
+
(*ppname_array)[i].name = NULL;
return;
*poffset = lock.l_start;
*pcount = lock.l_len;
*ppid = lock.l_pid;
-
+
DEBUG(3,("fcntl_getlock: fd %d is returned info %d pid %u\n",
fd, (int)lock.l_type, (unsigned int)lock.l_pid));
return True;
{
char *p;
ptrdiff_t len;
-
+
p = strrchr_m(dir, '/'); /* Find final '/', if any */
if (p == NULL) {
string = ".";
if (ISDOT(pattern))
return False;
-
+
return ms_fnmatch(pattern, string, Protocol <= PROTOCOL_LANMAN2, is_case_sensitive) == 0;
}
string = ".";
if (ISDOT(pattern))
return False;
-
+
return ms_fnmatch(pattern, string, True, is_case_sensitive) == 0;
}
Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
Copyright (C) Michael Adam 2008
-
+
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.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
bool global_section = False;
char* param_key;
struct param_opt_struct *data;
-
+
if (snum >= iNumServices) return NULL;
-
+
if (snum < 0) {
data = Globals.param_opt;
global_section = True;
} else {
data = ServicePtrs[snum]->param_opt;
}
-
+
if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
DEBUG(0,("asprintf failed!\n"));
return NULL;
}
string_free(¶m_key);
-
+
return NULL;
}
MISSING_PARAMETER(lp_bool);
return False;
}
-
+
if (!set_boolean(s, &ret)) {
DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
return False;
MISSING_PARAMETER(lp_enum);
return (-1);
}
-
+
for (i=0; _enum[i].name; i++) {
if (strequal(_enum[i].name,s))
return _enum[i].value;
char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def)
{
struct param_opt_struct *data = get_parametrics(snum, type, option);
-
+
if (data == NULL||data->value==NULL) {
if (def) {
return lp_string(def);
const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def)
{
struct param_opt_struct *data = get_parametrics(snum, type, option);
-
+
if (data == NULL||data->value==NULL)
return def;
-
+
return data->value;
}
if (data == NULL||data->value==NULL)
return (const char **)def;
-
+
if (data->list==NULL) {
data->list = str_list_make_v3(talloc_autofree_context(), data->value, NULL);
}
int lp_parm_int(int snum, const char *type, const char *option, int def)
{
struct param_opt_struct *data = get_parametrics(snum, type, option);
-
+
if (data && data->value && *data->value)
return lp_int(data->value);
unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def)
{
struct param_opt_struct *data = get_parametrics(snum, type, option);
-
+
if (data && data->value && *data->value)
return lp_ulong(data->value);
bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
{
struct param_opt_struct *data = get_parametrics(snum, type, option);
-
+
if (data && data->value && *data->value)
return lp_bool(data->value);
const struct enum_list *_enum, int def)
{
struct param_opt_struct *data = get_parametrics(snum, type, option);
-
+
if (data && data->value && *data->value && _enum)
return lp_enum(data->value, _enum);
if (ServicePtrs[idx]->szService) {
char *canon_name = canonicalize_servicename(
ServicePtrs[idx]->szService );
-
+
dbwrap_delete_bystring(ServiceHash, canon_name );
TALLOC_FREE(canon_name);
}
if (i == iNumServices) {
struct service **tsp;
int *tinvalid;
-
+
tsp = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(ServicePtrs, struct service *, num_to_alloc);
if (tsp == NULL) {
DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
copy_service(ServicePtrs[i], &tservice, NULL);
if (name)
string_set(&ServicePtrs[i]->szService, name);
-
+
DEBUG(8,("add_a_service: Creating snum = %d for %s\n",
i, ServicePtrs[i]->szService));
if (!hash_a_service(ServicePtrs[i]->szService, i)) {
return (-1);
}
-
+
return (i);
}
ServicePtrs[i]->bOpLocks = False;
/* Printer services must be printable. */
ServicePtrs[i]->bPrint_ok = True;
-
+
DEBUG(3, ("adding printer service %s\n", pszPrintername));
return (True);
bitmap_copy(pserviceDest->copymap,
pserviceSource->copymap);
}
-
+
data = pserviceSource->param_opt;
while (data) {
set_param_opt(&pserviceDest->param_opt, data->key, data->value);
static bool handle_workgroup(int snum, const char *pszParmValue, char **ptr)
{
bool ret;
-
+
ret = set_global_myworkgroup(pszParmValue);
string_set(&Globals.szWorkgroup,lp_workgroup());
-
+
return ret;
}
static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
{
bool ret;
-
+
ret = set_global_scope(pszParmValue);
string_set(&Globals.szNetbiosScope,global_scope());
{
int i;
struct param_opt_struct *data;
-
+
fprintf(f, "[global]\n");
for (i = 0; parm_table[i].label; i++)
{
int i;
struct param_opt_struct *data;
-
+
if (pService != &sDefault)
fprintf(f, "[%s]\n", pService->szService);
(*parm_table[i].label != '-') &&
(i == 0 || (parm_table[i].ptr != parm_table[i - 1].ptr)))
{
-
int pdiff = PTR_DIFF(parm_table[i].ptr, &sDefault);
if (pService == &sDefault) {
&& (parm_table[*i].ptr ==
parm_table[(*i) - 1].ptr))
continue;
-
+
if (is_default(*i) && !allparameters)
continue;
{
int iService;
fstring serviceName;
-
+
if (!pszServiceName) {
return GLOBAL_SECTION_SNUM;
}
-
+
for (iService = iNumServices - 1; iService >= 0; iService--) {
if (VALID(iService) && ServicePtrs[iService]->szService) {
/*
if (!*label) {
label = lp_servicename(snum);
}
-
+
/* This returns a 33 byte guarenteed null terminated string. */
ret = talloc_strndup(talloc_tos(), label, 32);
if (!ret) {
const char *lp_socket_address(void)
{
char *sock_addr = Globals.szSocketAddress;
-
+
if (sock_addr[0] == '\0'){
string_set(&Globals.szSocketAddress, "0.0.0.0");
}