summaryrefslogtreecommitdiffstats
path: root/ldap/systools/pio.c
diff options
context:
space:
mode:
authorcvsadm <cvsadm>2005-01-21 00:44:34 +0000
committercvsadm <cvsadm>2005-01-21 00:44:34 +0000
commitb2093e3016027d6b5cf06b3f91f30769bfc099e2 (patch)
treecf58939393a9032182c4fbc4441164a9456e82f8 /ldap/systools/pio.c
downloadds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.gz
ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.xz
ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.zip
Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)ldapserver7x
Diffstat (limited to 'ldap/systools/pio.c')
-rw-r--r--ldap/systools/pio.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/ldap/systools/pio.c b/ldap/systools/pio.c
new file mode 100644
index 00000000..4d6593c0
--- /dev/null
+++ b/ldap/systools/pio.c
@@ -0,0 +1,94 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#include "pio.h"
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+
+int iii_pio_procparse (
+ const char *cmd,
+ int count,
+ struct iii_pio_parsetab *tb
+)
+{
+ FILE *fp;
+ char buf[8192];
+ int rc = 0;
+
+ fp = popen(cmd,"r");
+
+ if (fp == NULL) {
+ return -1;
+ }
+
+ while (fgets(buf,8192,fp) != NULL && rc >= 0) {
+ char *rp;
+ int i;
+
+ rp = strchr(buf,'\n');
+
+ if (rp) {
+ *rp = '\0';
+ }
+
+ rp = strchr(buf,':');
+
+#if defined(__osf__)
+ if (rp == NULL) {
+ rp = strchr(buf,'=');
+ }
+#endif
+
+ if (rp == NULL) continue;
+
+ *rp = '\0';
+ rp++;
+ while(isspace(*rp)) rp++;
+
+ for (i = 0; i < count; i++) {
+ if (strcmp(tb[i].token,buf) == 0) {
+ rc = (tb[i].fn)(buf,rp);
+ break;
+ }
+ }
+ }
+
+ pclose(fp);
+
+ return rc;
+}
+
+int iii_pio_getnum (
+ const char *cmd,
+ long *valPtr
+)
+{
+ FILE *fp;
+ char buf[8192];
+ int rc = 0;
+
+ fp = popen(cmd,"r");
+
+ if (fp == NULL) {
+ return -1;
+ }
+
+ if (fgets(buf,8192,fp) == NULL) {
+ pclose(fp);
+ return -1;
+ }
+
+ pclose(fp);
+
+ if (!(isdigit(*buf))) {
+ return -1;
+ }
+
+ *valPtr = atol(buf);
+
+ return 0;
+}