Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
b583594a
Commit
b583594a
authored
Jul 27, 2008
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the references to "service" to be either "section" or "module".
parent
36828dae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
60 deletions
+60
-60
clientserver.c
clientserver.c
+1
-1
loadparm.c
loadparm.c
+59
-59
No files found.
clientserver.c
View file @
b583594a
...
...
@@ -879,7 +879,7 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
with "list = False". */
static
void
send_listing
(
int
fd
)
{
int
n
=
lp_num
servic
es
();
int
n
=
lp_num
_modul
es
();
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
...
...
loadparm.c
View file @
b583594a
...
...
@@ -23,16 +23,16 @@
/* Load parameters.
*
* This module provides suitable callback functions for the params
* module. It builds the internal table of se
rvice
details which is
* module. It builds the internal table of se
ction
details which is
* then used by the rest of the server.
*
* To add a parameter:
*
* 1) add it to the global or se
rvice
structure definition
* 1) add it to the global or se
ction
structure definition
* 2) add it to the parm_table
* 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
* 4) If it's a global then initialise it in init_globals. If a local
* (ie. se
rvice
) parameter then initialise it in the sDefault structure
* 4) If it's a global then initialise it in init_globals. If a local
module
* (ie. se
ction
) parameter then initialise it in the sDefault structure
*
*
* Notes:
...
...
@@ -87,9 +87,9 @@ struct parm_struct {
#endif
/* some helpful bits */
#define pSE
RVICE(i) Service
Ptrs[i]
#define iSE
RVICE(i) (*pSERVICE
(i))
#define LP_SNUM_OK(i
Service) (((iService) >= 0) && ((iService) < iNumServices)
)
#define pSE
CTION(i) Section
Ptrs[i]
#define iSE
CTION(i) (*pSECTION
(i))
#define LP_SNUM_OK(i
) ((i) >= 0 && (i) < iNumSections
)
/*
* This structure describes global (ie., server-wide) parameters.
...
...
@@ -106,7 +106,7 @@ typedef struct {
static
global
Globals
;
/*
* This structure describes a single se
rvice
. Their order must match the
* This structure describes a single se
ction
. Their order must match the
* initializers below, which you can accomplish by keeping each sub-section
* sorted. (e.g. in vim, just visually select each subsection and use !sort.)
*/
...
...
@@ -153,13 +153,13 @@ typedef struct {
BOOL
transfer_logging
;
BOOL
use_chroot
;
BOOL
write_only
;
}
se
rvice
;
}
se
ction
;
/* This is a default se
rvice used to prime a service
s structure. In order
/* This is a default se
ction used to prime a section
s structure. In order
* to make these easy to keep sorted in the same way as the variables
* above, use the variable name in the leading comment, including a
* trailing ';' (to avoid a sorting problem with trailing digits). */
static
se
rvice
sDefault
=
{
static
se
ction
sDefault
=
{
/* auth_users; */
NULL
,
/* charset; */
NULL
,
/* comment; */
NULL
,
...
...
@@ -205,9 +205,9 @@ static service sDefault = {
};
/* local variables */
static
se
rvice
**
Service
Ptrs
=
NULL
;
static
int
iNumSe
rvice
s
=
0
;
static
int
iSe
rviceIndex
=
0
;
static
se
ction
**
Section
Ptrs
=
NULL
;
static
int
iNumSe
ction
s
=
0
;
static
int
iSe
ctionIndex
=
-
1
;
static
BOOL
bInGlobalSection
=
True
;
#define NUMPARAMETERS (sizeof (parm_table) / sizeof (struct parm_struct))
...
...
@@ -359,13 +359,13 @@ static void init_locals(void)
int fn_name(void) {return *(int *)(ptr);}
#define FN_LOCAL_STRING(fn_name, val) \
char *fn_name(int i) {return LP_SNUM_OK(i) &&
pSERVICE(i)->val? pSERVICE(i)->
val : (sDefault.val? sDefault.val : "");}
char *fn_name(int i) {return LP_SNUM_OK(i) &&
iSECTION(i).val? iSECTION(i).
val : (sDefault.val? sDefault.val : "");}
#define FN_LOCAL_BOOL(fn_name, val) \
BOOL fn_name(int i) {return LP_SNUM_OK(i)?
pSERVICE(i)->
val : sDefault.val;}
BOOL fn_name(int i) {return LP_SNUM_OK(i)?
iSECTION(i).
val : sDefault.val;}
#define FN_LOCAL_CHAR(fn_name, val) \
char fn_name(int i) {return LP_SNUM_OK(i)?
pSERVICE(i)->
val : sDefault.val;}
char fn_name(int i) {return LP_SNUM_OK(i)?
iSECTION(i).
val : sDefault.val;}
#define FN_LOCAL_INTEGER(fn_name, val) \
int fn_name(int i) {return LP_SNUM_OK(i)?
pSERVICE(i)->
val : sDefault.val;}
int fn_name(int i) {return LP_SNUM_OK(i)?
iSECTION(i).
val : sDefault.val;}
FN_GLOBAL_STRING
(
lp_bind_address
,
&
Globals
.
bind_address
)
FN_GLOBAL_STRING
(
lp_motd_file
,
&
Globals
.
motd_file
)
...
...
@@ -437,16 +437,16 @@ static void string_set(char **s, const char *v)
exit_cleanup
(
RERR_MALLOC
);
}
/* Copy a se
rvice
structure to another. */
static
void
copy_se
rvice
(
service
*
pserviceDest
,
service
*
pservice
Source
)
/* Copy a se
ction
structure to another. */
static
void
copy_se
ction
(
section
*
psectionDest
,
section
*
psection
Source
)
{
int
i
;
for
(
i
=
0
;
parm_table
[
i
].
label
;
i
++
)
{
if
(
parm_table
[
i
].
ptr
&&
parm_table
[
i
].
class
==
P_LOCAL
)
{
void
*
def_ptr
=
parm_table
[
i
].
ptr
;
void
*
src_ptr
=
((
char
*
)
pse
rvice
Source
)
+
PTR_DIFF
(
def_ptr
,
&
sDefault
);
void
*
dest_ptr
=
((
char
*
)
pse
rvice
Dest
)
+
PTR_DIFF
(
def_ptr
,
&
sDefault
);
void
*
src_ptr
=
((
char
*
)
pse
ction
Source
)
+
PTR_DIFF
(
def_ptr
,
&
sDefault
);
void
*
dest_ptr
=
((
char
*
)
pse
ction
Dest
)
+
PTR_DIFF
(
def_ptr
,
&
sDefault
);
switch
(
parm_table
[
i
].
type
)
{
case
P_BOOL
:
...
...
@@ -476,11 +476,11 @@ static void copy_service(service *pserviceDest, service *pserviceSource)
}
}
/* Initialise a se
rvice
to the defaults. */
static
void
init_se
rvice
(
service
*
pservice
)
/* Initialise a se
ction
to the defaults. */
static
void
init_se
ction
(
section
*
psection
)
{
memset
((
char
*
)
pse
rvice
,
0
,
sizeof
(
service
));
copy_se
rvice
(
pservice
,
&
sDefault
);
memset
((
char
*
)
pse
ction
,
0
,
sizeof
(
section
));
copy_se
ction
(
psection
,
&
sDefault
);
}
/* Do a case-insensitive, whitespace-ignoring string compare. */
...
...
@@ -511,15 +511,15 @@ static int strwicmp(char *psz1, char *psz2)
return
*
psz1
-
*
psz2
;
}
/* Find a se
rvice by name. Otherwise works like get_service
. */
static
int
getse
rvicebyname
(
char
*
name
,
service
*
pservice
Dest
)
/* Find a se
ction by name. Otherwise works like get_section
. */
static
int
getse
ctionbyname
(
char
*
name
,
section
*
psection
Dest
)
{
int
i
;
for
(
i
=
iNumSe
rvice
s
-
1
;
i
>=
0
;
i
--
)
{
if
(
strwicmp
(
iSE
RVICE
(
i
).
name
,
name
)
==
0
)
{
if
(
pse
rvice
Dest
!=
NULL
)
copy_se
rvice
(
pserviceDest
,
pSERVICE
(
i
));
for
(
i
=
iNumSe
ction
s
-
1
;
i
>=
0
;
i
--
)
{
if
(
strwicmp
(
iSE
CTION
(
i
).
name
,
name
)
==
0
)
{
if
(
pse
ction
Dest
!=
NULL
)
copy_se
ction
(
psectionDest
,
pSECTION
(
i
));
break
;
}
}
...
...
@@ -527,33 +527,33 @@ static int getservicebyname(char *name, service *pserviceDest)
return
i
;
}
/* Add a new se
rvice to the services array, with defaults set
. */
static
int
add_a_se
rvice
(
char
*
name
)
/* Add a new se
ction to the sections array w/the default values
. */
static
int
add_a_se
ction
(
char
*
name
)
{
int
i
;
int
num_to_alloc
=
iNumSe
rvice
s
+
1
;
int
num_to_alloc
=
iNumSe
ction
s
+
1
;
/* it might already exist */
if
(
name
)
{
i
=
getse
rvice
byname
(
name
,
NULL
);
i
=
getse
ction
byname
(
name
,
NULL
);
if
(
i
>=
0
)
return
i
;
}
i
=
iNumSe
rvice
s
;
Se
rvicePtrs
=
realloc_array
(
ServicePtrs
,
service
*
,
num_to_alloc
);
i
=
iNumSe
ction
s
;
Se
ctionPtrs
=
realloc_array
(
SectionPtrs
,
section
*
,
num_to_alloc
);
if
(
Se
rvice
Ptrs
)
pSE
RVICE
(
iNumServices
)
=
new
(
service
);
if
(
Se
ction
Ptrs
)
pSE
CTION
(
iNumSections
)
=
new
(
section
);
if
(
!
Se
rvicePtrs
||
!
pSERVICE
(
iNumService
s
))
if
(
!
Se
ctionPtrs
||
!
pSECTION
(
iNumSection
s
))
return
-
1
;
iNumSe
rvice
s
++
;
iNumSe
ction
s
++
;
init_se
rvice
(
pSERVICE
(
i
));
init_se
ction
(
pSECTION
(
i
));
if
(
name
)
string_set
(
&
iSE
RVICE
(
i
).
name
,
name
);
string_set
(
&
iSE
CTION
(
i
).
name
,
name
);
return
i
;
}
...
...
@@ -617,10 +617,10 @@ static BOOL do_parameter(char *parmname, char *parmvalue)
parm_ptr
=
def_ptr
;
else
{
if
(
parm_table
[
parmnum
].
class
==
P_GLOBAL
)
{
rprintf
(
FLOG
,
"Global parameter %s found in
servic
e section!
\n
"
,
parmname
);
rprintf
(
FLOG
,
"Global parameter %s found in
modul
e section!
\n
"
,
parmname
);
return
True
;
}
parm_ptr
=
((
char
*
)
pSE
RVICE
(
iService
Index
))
+
PTR_DIFF
(
def_ptr
,
&
sDefault
);
parm_ptr
=
((
char
*
)
pSE
CTION
(
iSection
Index
))
+
PTR_DIFF
(
def_ptr
,
&
sDefault
);
}
/* now switch on the type of variable it is */
...
...
@@ -700,8 +700,8 @@ static BOOL do_section(char *sectionname)
return
True
;
#if 0
/* If we have a current se
rvice
, tidy it up before moving on. */
if (iSe
rvice
Index >= 0) {
/* If we have a current se
ction
, tidy it up before moving on. */
if (iSe
ction
Index >= 0) {
/* Add any tidy work as needed ... */
if (problem)
return False;
...
...
@@ -713,7 +713,7 @@ static BOOL do_section(char *sectionname)
return
False
;
}
if
((
iSe
rviceIndex
=
add_a_service
(
sectionname
))
<
0
)
{
if
((
iSe
ctionIndex
=
add_a_section
(
sectionname
))
<
0
)
{
rprintf
(
FLOG
,
"Failed to add a new module
\n
"
);
bInGlobalSection
=
True
;
return
False
;
...
...
@@ -722,7 +722,7 @@ static BOOL do_section(char *sectionname)
return
True
;
}
/* Load the
services array from the services
file. Return True on success,
/* Load the
modules from the config
file. Return True on success,
* False on failure. */
BOOL
lp_load
(
char
*
pszFname
,
int
globals_only
)
{
...
...
@@ -734,26 +734,26 @@ BOOL lp_load(char *pszFname, int globals_only)
pstrcpy
(
n2
,
pszFname
);
/* We get sections first, so have to start 'behind' to make up */
iSe
rvice
Index
=
-
1
;
/* We get sections first, so have to start 'behind' to make up
.
*/
iSe
ction
Index
=
-
1
;
return
pm_process
(
n2
,
globals_only
?
NULL
:
do_section
,
do_parameter
);
}
/* Return the max number of
services
. */
int
lp_num
servic
es
(
void
)
/* Return the max number of
modules (sections)
. */
int
lp_num
_modul
es
(
void
)
{
return
iNumSe
rvice
s
;
return
iNumSe
ction
s
;
}
/* Return the number of the
servic
e with the given name, or -1 if it doesn't
/* Return the number of the
modul
e with the given name, or -1 if it doesn't
* exist. Note that this is a DIFFERENT ANIMAL from the internal function
* getse
rvicebyname()! This works ONLY if all service
s have been loaded,
* and does not copy the found se
rvice
. */
* getse
ctionbyname()! This works ONLY if all section
s have been loaded,
* and does not copy the found se
ction
. */
int
lp_number
(
char
*
name
)
{
int
i
;
for
(
i
=
iNumSe
rvice
s
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
iNumSe
ction
s
-
1
;
i
>=
0
;
i
--
)
{
if
(
strcmp
(
lp_name
(
i
),
name
)
==
0
)
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment