Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
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
uplex-varnish
trackrdrd
Commits
5da6aa30
Commit
5da6aa30
authored
May 09, 2014
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CONF_ReadFile moved to config_common.c (so that MQ implementations can use it)
parent
9e4ae90c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
155 additions
and
80 deletions
+155
-80
config_common.h
trackrdrd/include/config_common.h
+33
-0
Makefile.am
trackrdrd/src/Makefile.am
+3
-1
child.c
trackrdrd/src/child.c
+2
-1
config.c
trackrdrd/src/config.c
+2
-75
config_common.c
trackrdrd/src/config_common.c
+111
-0
Makefile.am
trackrdrd/src/test/Makefile.am
+2
-1
trackrdrd.c
trackrdrd/src/trackrdrd.c
+2
-1
trackrdrd.h
trackrdrd/src/trackrdrd.h
+0
-1
No files found.
trackrdrd/include/config_common.h
0 → 100644
View file @
5da6aa30
/*-
* Copyright (c) 2014 UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2014 Otto Gmbh & Co KG
* All rights reserved
* Use only with permission
*
* Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
typedef
int
conf_add_f
(
const
char
*
lval
,
const
char
*
rval
);
int
CONF_ReadFile
(
const
char
*
file
,
conf_add_f
*
func
);
trackrdrd/src/Makefile.am
View file @
5da6aa30
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
-I
$(top_srcdir)
/include
bin_PROGRAMS
=
trackrdrd
...
...
@@ -9,6 +9,8 @@ trackrdrd_SOURCES = \
trackrdrd.c
\
parse.c
\
log.c
\
config_common.h
\
config_common.c
\
config.c
\
data.c
\
monitor.c
\
...
...
trackrdrd/src/child.c
View file @
5da6aa30
...
...
@@ -64,6 +64,7 @@
#include "miniobj.h"
#include "trackrdrd.h"
#include "config_common.h"
#define TRACK_TAGS "ReqStart,VCL_log,ReqEnd"
...
...
@@ -875,7 +876,7 @@ CHILD_Main(struct VSM_data *vd, int endless, int readconfig)
if
(
!
EMPTY
(
cli_config_filename
))
LOG_Log
(
LOG_INFO
,
"Reading config from %s"
,
cli_config_filename
);
/* XXX: CONF_ReadFile prints err messages to stderr */
if
(
CONF_ReadFile
(
cli_config_filename
)
!=
0
)
{
if
(
CONF_ReadFile
(
cli_config_filename
,
CONF_Add
)
!=
0
)
{
LOG_Log
(
LOG_ERR
,
"Error reading config from %s"
,
cli_config_filename
);
exit
(
EXIT_FAILURE
);
...
...
trackrdrd/src/config.c
View file @
5da6aa30
...
...
@@ -44,6 +44,7 @@
#include "trackrdrd.h"
#include "libvarnish.h"
#include "config_common.h"
#define DEFAULT_USER "nobody"
...
...
@@ -195,30 +196,6 @@ CONF_Add(const char *lval, const char *rval)
return
EINVAL
;
}
static
int
conf_ParseLine
(
char
*
ptr
,
char
**
lval
,
char
**
rval
)
{
char
*
endlval
;
*
lval
=
ptr
;
while
(
*++
ptr
&&
!
isspace
(
*
ptr
)
&&
*
ptr
!=
'='
)
;
if
(
*
ptr
==
'\0'
)
return
(
1
);
endlval
=
ptr
;
while
(
isspace
(
*
ptr
)
&&
*++
ptr
)
;
if
(
ptr
==
'\0'
||
*
ptr
!=
'='
)
return
(
1
);
while
(
*++
ptr
&&
isspace
(
*
ptr
))
;
if
(
ptr
==
'\0'
)
return
(
1
);
*
endlval
=
'\0'
;
*
rval
=
ptr
;
return
(
0
);
}
void
CONF_Init
(
void
)
{
...
...
@@ -257,56 +234,6 @@ CONF_Init(void)
config
.
gid
=
pw
->
pw_gid
;
}
int
CONF_ReadFile
(
const
char
*
file
)
{
FILE
*
in
;
char
line
[
BUFSIZ
];
int
linenum
=
0
;
in
=
fopen
(
file
,
"r"
);
if
(
in
==
NULL
)
{
perror
(
file
);
return
(
-
1
);
}
while
(
fgets
(
line
,
BUFSIZ
,
in
)
!=
NULL
)
{
char
orig
[
BUFSIZ
];
linenum
++
;
char
*
comment
=
strchr
(
line
,
'#'
);
if
(
comment
!=
NULL
)
*
comment
=
'\0'
;
if
(
strlen
(
line
)
==
0
)
continue
;
char
*
ptr
=
line
+
strlen
(
line
)
-
1
;
while
(
ptr
!=
line
&&
isspace
(
*
ptr
))
--
ptr
;
ptr
[
isspace
(
*
ptr
)
?
0
:
1
]
=
'\0'
;
if
(
strlen
(
line
)
==
0
)
continue
;
ptr
=
line
;
while
(
isspace
(
*
ptr
)
&&
*++
ptr
)
;
strcpy
(
orig
,
ptr
);
char
*
lval
,
*
rval
;
if
(
conf_ParseLine
(
ptr
,
&
lval
,
&
rval
)
!=
0
)
{
fprintf
(
stderr
,
"Cannot parse %s line %d: '%s'
\n
"
,
file
,
linenum
,
orig
);
return
(
-
1
);
}
int
ret
;
if
((
ret
=
CONF_Add
((
const
char
*
)
lval
,
(
const
char
*
)
rval
))
!=
0
)
{
fprintf
(
stderr
,
"Error in %s line %d (%s): '%s'
\n
"
,
file
,
linenum
,
strerror
(
ret
),
orig
);
return
(
-
1
);
}
}
return
(
0
);
}
/* XXX: stdout is /dev/null in child process */
int
CONF_ReadDefault
(
void
)
...
...
@@ -315,7 +242,7 @@ CONF_ReadDefault(void)
if
(
access
(
DEFAULT_CONFIG
,
R_OK
)
!=
0
)
return
(
errno
);
printf
(
"Reading config from %s
\n
"
,
DEFAULT_CONFIG
);
if
(
CONF_ReadFile
(
DEFAULT_CONFIG
)
!=
0
)
if
(
CONF_ReadFile
(
DEFAULT_CONFIG
,
CONF_Add
)
!=
0
)
return
-
1
;
}
return
0
;
...
...
trackrdrd/src/config_common.c
0 → 100644
View file @
5da6aa30
/*-
* Copyright (c) 2012-2014 UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2012-2014 Otto Gmbh & Co KG
* All rights reserved
* Use only with permission
*
* Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "config_common.h"
static
int
conf_ParseLine
(
char
*
ptr
,
char
**
lval
,
char
**
rval
)
{
char
*
endlval
;
*
lval
=
ptr
;
while
(
*++
ptr
&&
!
isspace
(
*
ptr
)
&&
*
ptr
!=
'='
)
;
if
(
*
ptr
==
'\0'
)
return
(
1
);
endlval
=
ptr
;
while
(
isspace
(
*
ptr
)
&&
*++
ptr
)
;
if
(
ptr
==
'\0'
||
*
ptr
!=
'='
)
return
(
1
);
while
(
*++
ptr
&&
isspace
(
*
ptr
))
;
if
(
ptr
==
'\0'
)
return
(
1
);
*
endlval
=
'\0'
;
*
rval
=
ptr
;
return
(
0
);
}
int
CONF_ReadFile
(
const
char
*
file
,
conf_add_f
*
conf_add
)
{
FILE
*
in
;
char
line
[
BUFSIZ
];
int
linenum
=
0
;
in
=
fopen
(
file
,
"r"
);
if
(
in
==
NULL
)
{
perror
(
file
);
return
(
-
1
);
}
while
(
fgets
(
line
,
BUFSIZ
,
in
)
!=
NULL
)
{
char
orig
[
BUFSIZ
];
linenum
++
;
char
*
comment
=
strchr
(
line
,
'#'
);
if
(
comment
!=
NULL
)
*
comment
=
'\0'
;
if
(
strlen
(
line
)
==
0
)
continue
;
char
*
ptr
=
line
+
strlen
(
line
)
-
1
;
while
(
ptr
!=
line
&&
isspace
(
*
ptr
))
--
ptr
;
ptr
[
isspace
(
*
ptr
)
?
0
:
1
]
=
'\0'
;
if
(
strlen
(
line
)
==
0
)
continue
;
ptr
=
line
;
while
(
isspace
(
*
ptr
)
&&
*++
ptr
)
;
strcpy
(
orig
,
ptr
);
char
*
lval
,
*
rval
;
if
(
conf_ParseLine
(
ptr
,
&
lval
,
&
rval
)
!=
0
)
{
fprintf
(
stderr
,
"Cannot parse %s line %d: '%s'
\n
"
,
file
,
linenum
,
orig
);
return
(
-
1
);
}
int
ret
;
if
((
ret
=
conf_add
((
const
char
*
)
lval
,
(
const
char
*
)
rval
))
!=
0
)
{
fprintf
(
stderr
,
"Error in %s line %d (%s): '%s'
\n
"
,
file
,
linenum
,
strerror
(
ret
),
orig
);
return
(
-
1
);
}
}
return
(
0
);
}
trackrdrd/src/test/Makefile.am
View file @
5da6aa30
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
-I
$(top_srcdir)
/include
TESTS
=
test_parse test_data test_hash test_mq test_spmcq
\
test_spmcq_loop.sh test_worker regress.sh
...
...
@@ -41,6 +41,7 @@ test_hash_LDADD = \
../monitor.
$(OBJEXT)
\
../parse.
$(OBJEXT)
\
../config.
$(OBJEXT)
\
../config_common.
$(OBJEXT)
\
../sandbox.
$(OBJEXT)
test_hash_CFLAGS
=
-DTEST_DRIVER
...
...
trackrdrd/src/trackrdrd.c
View file @
5da6aa30
...
...
@@ -69,6 +69,7 @@
#include "miniobj.h"
#include "trackrdrd.h"
#include "config_common.h"
#include "revision.h"
#include "usage.h"
...
...
@@ -273,7 +274,7 @@ main(int argc, char * const *argv)
if
(
c_arg
)
{
strcpy
(
cli_config_filename
,
c_arg
);
printf
(
"Reading config from %s
\n
"
,
c_arg
);
if
(
CONF_ReadFile
(
c_arg
)
!=
0
)
if
(
CONF_ReadFile
(
c_arg
,
CONF_Add
)
!=
0
)
exit
(
EXIT_FAILURE
);
}
...
...
trackrdrd/src/trackrdrd.h
View file @
5da6aa30
...
...
@@ -325,7 +325,6 @@ struct config {
void
CONF_Init
(
void
);
int
CONF_Add
(
const
char
*
lval
,
const
char
*
rval
);
int
CONF_ReadFile
(
const
char
*
file
);
int
CONF_ReadDefault
(
void
);
void
CONF_Dump
(
void
);
...
...
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