Check-in [5eff930a35]
Overview
Comment:Updated man pages. Updated Makefile.in to delete new man pages. Updated configure.ac to check for fopen_net() instead of open_net().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5eff930a35f54e8958b1c37be6e0b1431757a0e3
User & Date: rkeene on 2004-11-24 23:40:13
Other Links: manifest | tags
Context
2004-12-03
12:19
Merged patches from Mirko Buffoni <mirko.buffoni@synthesys.it> That fixed installation and RPM `spec file' issues. check-in: 1c4c941633 user: rkeene tags: trunk
2004-11-24
23:40
Updated man pages. Updated Makefile.in to delete new man pages. Updated configure.ac to check for fopen_net() instead of open_net(). check-in: 5eff930a35 user: rkeene tags: trunk
23:13
Added an optional dependency to libopennet. If libopennet is used fopen_net is used instead of fopen. Made lc_process_file() a publicly callable function. Added a (blank!) man page for it. Made lc_cleanup() a publicly callable function, and removed calls to it from lc_process(). Added a (blank!) man page for it. check-in: cff8496e42 user: rkeene tags: trunk
Changes

Modified Makefile.in from [2f13fb7b2e] to [40dfe8fe47].

54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68







-
+







test-lc: $(LIBS) test-lc.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $(filter %.c, $?) $(LDFLAGS) -Wl,-R -Wl,. -L. -lconfig

.PHONY: clean distclean install
clean:
	rm -f *.o $(BINS) $(LIBS) libconfig.h *~ test-lc
distclean: clean
	rm -f Makefile config.h config.status config.log lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3
	rm -f Makefile config.h config.status config.log lc_geterrno.3 lc_process.3 lc_cleanup.3 lc_process_file.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 libconfig.3


install: all libconfig.h
	-$(INSTALL) -d $(mandir)
	-$(INSTALL) -d $(mandir)/man3
	-$(INSTALL) -d $(libdir)
	-$(INSTALL) -d $(includedir)

Modified README from [a14993d947] to [0dae6d03cb].

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8
9








+
Tested platforms:
  Mac OS X 10.1
  HP-UX 11.11
  NetBSD 1.6.1
  FreeBSD 4.8
  OpenBSD 3.4
  SunOS 5.9
  Linux (Slackware, RedHat, Fedora Core, Debian)
  IRIX 6.5

Modified config.h.in from [f405f5e957] to [093c4e8a7f].

8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22







-
+








/* Define to 1 if you have the `getpwuid' function. */
#undef HAVE_GETPWUID

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have open_net from libopennet */
/* Define to 1 if you have fopen_net from libopennet */
#undef HAVE_LIBOPENNET

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the <opennet.h> header file. */
#undef HAVE_OPENNET_H

Modified configure from [306d8f9a52] to [fd25645a6f].

15667
15668
15669
15670
15671
15672
15673
15674
15675
15676



15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694

15695
15696
15697
15698

15699
15700
15701
15702
15703
15704
15705
15667
15668
15669
15670
15671
15672
15673



15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693

15694
15695
15696
15697

15698
15699
15700
15701
15702
15703
15704
15705







-
-
-
+
+
+

















-
+



-
+







    LIBSPEC=$withval

else

# Not specified
    LIBSPECFLAGS=`pkg-config --libs libopennet 2>/dev/null`
    LIBSPECCFLAGS=`pkg-config --cflags libopennet 2>/dev/null`
    echo "$as_me:$LINENO: checking for open_net in -lopennet" >&5
echo $ECHO_N "checking for open_net in -lopennet... $ECHO_C" >&6
if test "${ac_cv_lib_opennet_open_net+set}" = set; then
    echo "$as_me:$LINENO: checking for fopen_net in -lopennet" >&5
echo $ECHO_N "checking for fopen_net in -lopennet... $ECHO_C" >&6
if test "${ac_cv_lib_opennet_fopen_net+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lopennet $LIBSPECFLAGS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h.  */

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char open_net ();
char fopen_net ();
int
main ()
{
open_net ();
fopen_net ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
  (eval $ac_link) 2>conftest.er1
15718
15719
15720
15721
15722
15723
15724
15725

15726
15727
15728
15729
15730

15731
15732
15733
15734
15735
15736
15737
15738



15739
15740
15741
15742
15743
15744
15745
15718
15719
15720
15721
15722
15723
15724

15725
15726
15727
15728
15729

15730
15731
15732
15733
15734
15735



15736
15737
15738
15739
15740
15741
15742
15743
15744
15745







-
+




-
+





-
-
-
+
+
+







  (exit $ac_status); }; } &&
	 { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_opennet_open_net=yes
  ac_cv_lib_opennet_fopen_net=yes
else
  echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

ac_cv_lib_opennet_open_net=no
ac_cv_lib_opennet_fopen_net=no
fi
rm -f conftest.err conftest.$ac_objext \
      conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_open_net" >&5
echo "${ECHO_T}$ac_cv_lib_opennet_open_net" >&6
if test $ac_cv_lib_opennet_open_net = yes; then
echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_fopen_net" >&5
echo "${ECHO_T}$ac_cv_lib_opennet_fopen_net" >&6
if test $ac_cv_lib_opennet_fopen_net = yes; then

      OLDCPPFLAGS="$CPPFLAGS"
      OLDCFLAGS="$CFLAGS"
      CPPFLAGS="$CPPFLAGS $LIBSPECCFLAGS"
      CFLAGS="$CFLAGS $LIBSPECCFLAGS"
      if test "${ac_cv_header_opennet_h+set}" = set; then
  echo "$as_me:$LINENO: checking for opennet.h" >&5
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919



15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937

15938
15939
15940
15941

15942
15943
15944
15945
15946
15947
15948
15910
15911
15912
15913
15914
15915
15916



15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936

15937
15938
15939
15940

15941
15942
15943
15944
15945
15946
15947
15948







-
-
-
+
+
+

















-
+



-
+







  	*)
  		if test "${LIBSPEC}" = "yes"; then
			true
		else
			LIBSPECFLAGS="-L${LIBSPEC}/lib ${LIBSPECFLAGS}"
			LIBSPECCFLAGS="-I${LIBSPEC}/include ${LIBSPECCFLAGS}"
  		fi
		echo "$as_me:$LINENO: checking for open_net in -lopennet" >&5
echo $ECHO_N "checking for open_net in -lopennet... $ECHO_C" >&6
if test "${ac_cv_lib_opennet_open_net+set}" = set; then
		echo "$as_me:$LINENO: checking for fopen_net in -lopennet" >&5
echo $ECHO_N "checking for fopen_net in -lopennet... $ECHO_C" >&6
if test "${ac_cv_lib_opennet_fopen_net+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lopennet $LIBSPECFLAGS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h.  */

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char open_net ();
char fopen_net ();
int
main ()
{
open_net ();
fopen_net ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
  (eval $ac_link) 2>conftest.er1
15961
15962
15963
15964
15965
15966
15967
15968

15969
15970
15971
15972
15973

15974
15975
15976
15977
15978
15979
15980
15981



15982
15983
15984
15985
15986
15987
15988
15961
15962
15963
15964
15965
15966
15967

15968
15969
15970
15971
15972

15973
15974
15975
15976
15977
15978



15979
15980
15981
15982
15983
15984
15985
15986
15987
15988







-
+




-
+





-
-
-
+
+
+







  (exit $ac_status); }; } &&
	 { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_opennet_open_net=yes
  ac_cv_lib_opennet_fopen_net=yes
else
  echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

ac_cv_lib_opennet_open_net=no
ac_cv_lib_opennet_fopen_net=no
fi
rm -f conftest.err conftest.$ac_objext \
      conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_open_net" >&5
echo "${ECHO_T}$ac_cv_lib_opennet_open_net" >&6
if test $ac_cv_lib_opennet_open_net = yes; then
echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_fopen_net" >&5
echo "${ECHO_T}$ac_cv_lib_opennet_fopen_net" >&6
if test $ac_cv_lib_opennet_fopen_net = yes; then

		  OLDCFLAGS="$CFLAGS"
		  OLDCPPFLAGS="$CPPFLAGS"
		  CPPFLAGS="$CPPFLAGS ${LIBSPECCFLAGS}"
		  CFLAGS="$CFLAGS ${LIBSPECCFLAGS}"
  		  if test "${ac_cv_header_opennet_h+set}" = set; then
  echo "$as_me:$LINENO: checking for opennet.h" >&5

Modified configure.ac from [298ad28fdd] to [d2f6f7f2f1].

23
24
25
26
27
28
29
30

31
32
33
34
35
36
37
23
24
25
26
27
28
29

30
31
32
33
34
35
36
37







-
+







DC_DO_TYPE(int32_t, signed, 4)
DC_DO_TYPE(uint16_t, unsigned, 2)
DC_DO_TYPE(int16_t, signed, 2)

AC_REPLACE_FUNCS(strsep strtoll)
AC_CHECK_FUNCS(getpwuid)

DC_ASK_OPTLIB(opennet, open_net, opennet.h, [      Enable opennet support], libopennet, HAVE_LIBOPENNET, HAVE_OPENNET_H)
DC_ASK_OPTLIB(opennet, fopen_net, opennet.h, [      Enable opennet support], libopennet, HAVE_LIBOPENNET, HAVE_OPENNET_H)

dnl Checks for Win32 specific things.
DC_DO_WIN32

dnl This must be last.
DC_GET_SHOBJFLAGS

Modified lc_geterrno.3.in from [f1a44ec899] to [cd34ea9cd7].

61
62
63
64
65
66
67



68
69
70
71
72
73
74
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







+
+
+







		fprintf(stderr, "Error registering variable: %i.\\n",
		        lc_geterrno());
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE,
	                      NULL);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}

	if (filename != NULL) {

Modified lc_geterrstr.3.in from [1700112ee5] to [72b9664bc6].

29
30
31
32
33
34
35



36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







+
+
+







		fprintf(stderr, "Error registering variable: %s.\\n",
		        lc_geterrstr());
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE,
	                      NULL);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}

	if (filename != NULL) {

Modified lc_process.3.in from [14e5602803] to [95fe0e123b].

1
2
3
4
5
6
7
8
9
10
11
12
13












































14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64













+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







.TH LC_PROCESS 3 "25 Oct 04" "@PACKAGE_STRING@"
.SH NAME
lc_process \- Begin processing configuration files.

.SH SYNOPSIS
.B #include <libconfig.h>
.sp
.BI "int lc_process(int " argc ", char **" argv ", const char *" appname ", lc_conf_type_t " type ", const char *" extra ");"

.SH DESCRIPTION
The
.BR lc_process (3)
function begins processing of the command line arguments, environment variables, and command line options.
The
.I argc
and
.I argv
parameters should be in the same format as passed to the
.B main
function of your program.
The
.I appname
parameter should be a reasonable form of the name of the application.
The
.I type
parameter should describe the format of the configuration file (see below).
The
.I extra
parameter should list any extra configuration files to process.

Valid type parameter values:
.TP
LC_CONF_SECTION
This type of configuration file is similar to the Windows INI-file style.
An example configuration file:
.nf
	[section]
	variable = value
.fi

.TP
LC_CONF_APACHE
This type of configuration file is similar to the Apache configuration file.
An example configuration file:
.nf
	<Section argument>
		variable value
	</Section>
.fi

.TP
LC_CONF_SPACE
This is a simple, flat configuration file.  It has no section headers.
An example configuration file:
.nf
	variable value
.fi

.SH "RETURN VALUE"
On success 0 is returned, otherwise -1 is returned.

.SH EXAMPLE
.nf
#include <libconfig.h>
31
32
33
34
35
36
37



38
39
40
41
42
43
44
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91







+
+
+







		fprintf(stderr, "Error registering variable: %i.\\n",
		        lc_geterrno());
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE,
	                      NULL);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}

	if (filename != NULL) {

Modified lc_process_file.3.in from [da39a3ee5e] to [ea98de7617].






































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
.TH LC_PROCESS_FILE 3 "25 Oct 04" "@PACKAGE_STRING@"
.SH NAME
lc_process_file \- Process a specific file

.SH SYNOPSIS
.B #include <libconfig.h>
.sp
.BI "int lc_process_file(const char *" appname ", const char *" pathname ", lc_conf_type_t " type ");"

.SH DESCRIPTION
The
.BR lc_process_file (3)
function processes exactly one configuration file.  The file is specified by the
.I pathname
argument and should be in the format specified by the
.I type
argument.  The
.I appname
argument should be a reasonable form of the name of the application.

.SH "RETURN VALUE"
On success 0 is returned, otherwise -1 is returned.

.SH EXAMPLE
.nf
#include <libconfig.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv) {
	int lc_p_ret, lc_rv_ret;
	char *filename = NULL;

	lc_rv_ret = lc_register_var("File", LC_VAR_STRING,
	                            &filename, 'f');
	if (lc_rv_ret != 0) {
		fprintf(stderr, "Error registering variable: %i.\\n",
		        lc_geterrno());
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process_file("example", "/data/extra.conf",
	                           LC_CONF_APACHE);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration file: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}

	if (filename != NULL) {
		printf("File specified was: %s\\n", filename);
	} else {
		printf("No filename specified.\\n");
	}

	return(EXIT_SUCCESS);
}
.fi

.SH "SEE ALSO"
.BR lc_register_var (3),
.BR lc_register_callback (3),
.BR lc_geterrno (3),
.BR lc_geterrstr (3),
.BR lc_cleanup (3),
.BR lc_process (3)

Modified lc_register_callback.3.in from [91e00aa66a] to [cea18abe88].

202
203
204
205
206
207
208



209
210
211
212
213
214
215
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218







+
+
+







	if (lc_rc_ret != 0) {
		fprintf(stderr, "Error registering callback.\\n");
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE,
	                      NULL);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}

	return(EXIT_SUCCESS);

Modified lc_register_var.3.in from [aade6a66d6] to [e33efd4ec7].

113
114
115
116
117
118
119



120
121
122
123
124
125
126
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129







+
+
+







		fprintf(stderr, "Error registering variable: %i.\\n",
		        lc_geterrno());
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE,
	                      NULL);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}

	if (filename != NULL) {

Modified libconfig.3.in from [70716a9252] to [08444a4029].

49
50
51
52
53
54
55

56
57
58
59
60
61
62
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63







+







		fprintf(stderr, "Error registering variable: %i.\\n",
		        lc_geterrno());
		return(EXIT_FAILURE);
	}

	lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE,
	                      NULL);

	lc_cleanup();

	if (lc_p_ret != 0) {
		fprintf(stderr, "Error processing configuration: \\
		        %s\\n", lc_geterrstr());
		return(EXIT_FAILURE);
	}