"Fossies" - the Fresh Open Source Software Archive 
Member "xtermcontrol-3.8/src/configuration.h" (9 Dec 2018, 2502 Bytes) of package /linux/privat/xtermcontrol-3.8.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "configuration.h" see the
Fossies "Dox" file reference documentation and the last
Fossies "Diffs" side-by-side code changes report:
3.4_vs_3.5.
1 /****************************************************************************
2 ** $Id: configuration.h,v 1.5 2002/08/01 21:54:17 jet Exp $
3 **
4 ** Copyright (C) 2002-2013 Jess Thrysoee <jess@thrysoee.dk>
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 *************************************************************************** */
12
13 /* Configuration files must be plain ascii test file. Each line in the file is
14 * either a comment or contains an attribute. Attributes consist of a keyword
15 * and an associated value:
16 *
17 * keyword = value # comment
18 *
19 * Whitespace is ignored in attributes unless within a quoted value. The
20 * character '#' is taken to begin a comment. Each '#' and all remaining
21 * characters on that line is ignored.
22 *
23 *
24 * EXAMPLE:
25 *
26 * char path[BUFSIZ];
27 * configuration list;
28 * const configuration_element *lp;
29 *
30 * configuration_init(&list)
31 * configuration_read(&list, "/etc/application.conf");
32 * snprintf(path, sizeof(path), "%s/.%s", getenv("HOME"), "application");
33 * configuration_read(&list, path);
34 *
35 * for (lp = list.first; lp != NULL; lp = lp->next) {
36 * printf("key:%s value:%s\n", lp->keyword, lp->value);
37 * }
38 *
39 * if (lp = configuration_find(&list, "example_keyword"))
40 * printf("found %s with value %s\n", lp->keyword, lp->value);
41 *
42 * configuration_free(&list);
43 */
44
45 #ifndef CONFIGURATION_H
46 #define CONFIGURATION_H
47
48 typedef struct configuration_element
49 {
50 struct configuration_element *next;
51 char *keyword;
52 char *value;
53
54 } configuration_element;
55
56 typedef struct configuration
57 {
58 struct configuration_element *first;
59 int n_elements;
60
61 } configuration;
62
63 /* configuration.c */
64 void configuration_init(configuration *list);
65 int configuration_read(configuration *list, const char *filepath);
66 void configuration_free(configuration *list);
67 const configuration_element *configuration_find(configuration *list, const char *keyword);
68
69 /*
70 Something like the following function should be created to write the
71 configuration to a file, but it will always be very implementation specific,
72 so it is left to be done per project and not in this library.
73
74 int configuration_write(const char* filepath);
75 */
76
77 #endif