aboutsummaryrefslogtreecommitdiffstats
path: root/src/shvar.h
diff options
context:
space:
mode:
authorMichael K. Johnson <johnsonm@redhat.com>1999-09-06 22:42:05 +0000
committerMichael K. Johnson <johnsonm@redhat.com>1999-09-06 22:42:05 +0000
commit57487e296e885786382588f547d259bec4c3595e (patch)
treeb85655e478e1c22807d754df6a6c3d4f39cb46fc /src/shvar.h
parent5ae520ecf238d6c5d1db515bb3217501f93c8a13 (diff)
downloadinitscripts-57487e296e885786382588f547d259bec4c3595e.tar
initscripts-57487e296e885786382588f547d259bec4c3595e.tar.gz
initscripts-57487e296e885786382588f547d259bec4c3595e.tar.bz2
initscripts-57487e296e885786382588f547d259bec4c3595e.tar.xz
initscripts-57487e296e885786382588f547d259bec4c3595e.zip
first pass at ppp-watch
Diffstat (limited to 'src/shvar.h')
-rw-r--r--src/shvar.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/shvar.h b/src/shvar.h
new file mode 100644
index 00000000..ee60e12b
--- /dev/null
+++ b/src/shvar.h
@@ -0,0 +1,100 @@
+/* copied from rp3 -- DO NOT EDIT HERE, ONLY COPY FROM rp3 */
+/*
+ * shvar.h
+ *
+ * Interface for non-destructively reading/writing files containing
+ * only shell variable declarations and full-line comments.
+ *
+ * Includes explicit inheritance mechanism intended for use with
+ * Red Hat Linux ifcfg-* files. There is no protection against
+ * inheritance loops; they will generally cause stack overflows.
+ * Furthermore, they are only intended for one level of inheritance;
+ * the value setting algorithm assumes this.
+ *
+ * Copyright 1999 Red Hat, Inc.
+ *
+ * This 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef _SHVAR_H
+#define _SHVAR_H
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _shvarFile shvarFile;
+struct _shvarFile {
+ char *fileName; /* read-only */
+ int fd; /* read-only */
+ char *arena; /* ignore */
+ GList *lineList; /* read-only */
+ GList *freeList; /* ignore */
+ GList *current; /* set implicitly or explicitly,
+ points to element of lineList */
+ shvarFile *parent; /* set explicitly */
+ int modified; /* ignore */
+};
+
+
+/* Open the file <name>, return shvarFile on success, NULL on failure */
+shvarFile *
+svNewFile(char *name);
+
+/* Get the value associated with the key, and leave the current pointer
+ * pointing at the line containing the value. The char* returned MUST
+ * be freed by the caller.
+ */
+char *
+svGetValue(shvarFile *s, char *key);
+
+/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
+ * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
+ * return <def> otherwise
+ */
+int
+svTrueValue(shvarFile *s, char *key, int def);
+
+/* Set the variable <key> equal to the value <value>.
+ * If <key> does not exist, and the <current> pointer is set, append
+ * the key=value pair after that line. Otherwise, prepend the pair
+ * to the top of the file.
+ */
+void
+svSetValue(shvarFile *s, char *key, char *value);
+
+
+/* Write the current contents iff modified. Returns -1 on error
+ * and 0 on success. Do not write if no values have been modified.
+ * The mode argument is only used if creating the file, not if
+ * re-writing an existing file, and is passed unchanged to the
+ * open() syscall.
+ */
+int
+svWriteFile(shvarFile *s, int mode);
+
+/* Close the file descriptor (if open) and delete the shvarFile.
+ * Returns -1 on error and 0 on success.
+ */
+int
+svCloseFile(shvarFile *s);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* ! _SHVAR_H */