[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src/config configuration.c
From: |
Neil Tiffin |
Subject: |
gnue/geas/src/config configuration.c |
Date: |
Sun, 16 Sep 2001 10:52:37 -0400 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/09/16 10:52:37
Modified files:
geas/src/config: configuration.c
Log message:
remove tabs from source.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/config/configuration.c.diff?cvsroot=OldCVS&tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gnue/geas/src/config/configuration.c
diff -u gnue/geas/src/config/configuration.c:1.14
gnue/geas/src/config/configuration.c:1.15
--- gnue/geas/src/config/configuration.c:1.14 Fri Jun 8 16:06:52 2001
+++ gnue/geas/src/config/configuration.c Sun Sep 16 10:52:37 2001
@@ -19,7 +19,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: configuration.c,v 1.14 2001/06/08 20:06:52 reinhard Exp $
+ $Id: configuration.c,v 1.15 2001/09/16 14:52:37 ntiffin Exp $
*/
/* ------------------------------------------------------------------------- *\
@@ -140,7 +140,7 @@
{
i = (configuration_data *) l->data;
if (g_strcasecmp (i->name, name) == 0)
- return (i);
+ return (i);
l = g_list_next (l);
}
return (NULL);
@@ -286,44 +286,44 @@
while (!feof (fp))
{
if (fgets (buf, 255, fp) != NULL)
- {
- /* strip comments */
- p = strchr (buf, '#');
- if (p)
- *p = '\0';
- for (p = buf; *p != '\0'; p++)
- if (!isspace (*p))
- break;
- if (*p == '\0')
- continue; /* blank line or comment only line
- */
- q = strchr (p, ':');
- if (!q)
- {
- config_failed = 1;
- if (!errdone)
- fprintf (stderr, "Shadow password file error.");
- errdone = 1;
- continue;
- }
- *q = '\0';
-
- q++;
- /* trim whitespace from left side */
- while (isspace (*p))
- p++;
- while (isspace (p[strlen (p) - 1]))
- p[strlen (p) - 1] = '\0';
- /* trim whitespace from right side */
- while (isspace (*q))
- q++;
- while (isspace (q[strlen (q) - 1]))
- q[strlen (q) - 1] = '\0';
- if (adminuser && strcmp (p, "adminuser") == 0)
- add_section_option (c, "adminpassword", q);
- else
- add_database_option (c, p, "password", q);
- }
+ {
+ /* strip comments */
+ p = strchr (buf, '#');
+ if (p)
+ *p = '\0';
+ for (p = buf; *p != '\0'; p++)
+ if (!isspace (*p))
+ break;
+ if (*p == '\0')
+ continue; /* blank line or comment only line
+ */
+ q = strchr (p, ':');
+ if (!q)
+ {
+ config_failed = 1;
+ if (!errdone)
+ fprintf (stderr, "Shadow password file error.");
+ errdone = 1;
+ continue;
+ }
+ *q = '\0';
+
+ q++;
+ /* trim whitespace from left side */
+ while (isspace (*p))
+ p++;
+ while (isspace (p[strlen (p) - 1]))
+ p[strlen (p) - 1] = '\0';
+ /* trim whitespace from right side */
+ while (isspace (*q))
+ q++;
+ while (isspace (q[strlen (q) - 1]))
+ q[strlen (q) - 1] = '\0';
+ if (adminuser && strcmp (p, "adminuser") == 0)
+ add_section_option (c, "adminpassword", q);
+ else
+ add_database_option (c, p, "password", q);
+ }
}
fclose (fp);
}
@@ -345,42 +345,42 @@
if (c)
{
for (loop = 0; loop < indent; loop++)
- printf (" ");
+ printf (" ");
if (c->name)
- {
- printf ("Section: %s\n", c->name);
- for (loop = 0; loop < indent; loop++)
- printf (" ");
- printf ("--------\n");
- }
+ {
+ printf ("Section: %s\n", c->name);
+ for (loop = 0; loop < indent; loop++)
+ printf (" ");
+ printf ("--------\n");
+ }
else
- {
- printf ("Section: <unknown>\n");
- for (loop = 0; loop < indent; loop++)
- printf (" ");
- printf ("--------\n");
- }
+ {
+ printf ("Section: <unknown>\n");
+ for (loop = 0; loop < indent; loop++)
+ printf (" ");
+ printf ("--------\n");
+ }
l = c->globals;
while (l)
- {
- for (loop = 0; loop < indent; loop++)
- printf (" ");
- i = (config_item *) l->data;
- if (show_passwords == FALSE && strstr (i->key, "password") != NULL)
- printf ("%s \t: <hidden for security>\n", i->key);
- else
- printf ("%s \t: %s\n", i->key, i->value);
- l = g_list_next (l);
- }
+ {
+ for (loop = 0; loop < indent; loop++)
+ printf (" ");
+ i = (config_item *) l->data;
+ if (show_passwords == FALSE && strstr (i->key, "password") != NULL)
+ printf ("%s \t: <hidden for security>\n", i->key);
+ else
+ printf ("%s \t: %s\n", i->key, i->value);
+ l = g_list_next (l);
+ }
l = c->database;
while (l)
- {
- printf ("\n");
- real_show_configuration ((configuration) l->data, indent + 4,
- show_passwords);
- l = g_list_next (l);
- }
+ {
+ printf ("\n");
+ real_show_configuration ((configuration) l->data, indent + 4,
+ show_passwords);
+ l = g_list_next (l);
+ }
printf ("\n");
}
}
@@ -400,48 +400,48 @@
while (1)
{
if (fgets (buf, 1022, fp) != NULL)
- {
- while (buf[strlen (buf) - 1] == '\r'
- || buf[strlen (buf) - 1] ==
- '\n') buf[strlen (buf) - 1] = '\0';
- /* strip comments */
- p = strchr (buf, '#');
- if (p)
- *p = '\0';
- /* strip whitespace from ends */
- p = buf;
- while (isspace (*p))
- p++;
- if (*p == '\0')
- continue;
- while (isspace (p[strlen (p) - 1]))
- p[strlen (p) - 1] = '\0';
- /* skip empty lines/only comment lines */
- if (*p == '\0')
- continue;
- /* strip double spaces */
- retval = p;
- q = p;
- while (*p != '\0')
- {
- p = strchr (p, ' ');
- if (!p)
- break;
- p++;
- q = p;
- while (isspace (*q))
- q++;
- memmove (p, q, strlen (q) + 1);
- p++;
- }
-
- /* got a valid line */
- return (retval);
- }
+ {
+ while (buf[strlen (buf) - 1] == '\r'
+ || buf[strlen (buf) - 1] ==
+ '\n') buf[strlen (buf) - 1] = '\0';
+ /* strip comments */
+ p = strchr (buf, '#');
+ if (p)
+ *p = '\0';
+ /* strip whitespace from ends */
+ p = buf;
+ while (isspace (*p))
+ p++;
+ if (*p == '\0')
+ continue;
+ while (isspace (p[strlen (p) - 1]))
+ p[strlen (p) - 1] = '\0';
+ /* skip empty lines/only comment lines */
+ if (*p == '\0')
+ continue;
+ /* strip double spaces */
+ retval = p;
+ q = p;
+ while (*p != '\0')
+ {
+ p = strchr (p, ' ');
+ if (!p)
+ break;
+ p++;
+ q = p;
+ while (isspace (*q))
+ q++;
+ memmove (p, q, strlen (q) + 1);
+ p++;
+ }
+
+ /* got a valid line */
+ return (retval);
+ }
/* EOF return NULL */
if (feof (fp))
- return (NULL);
+ return (NULL);
}
}
@@ -480,93 +480,93 @@
{
p = read_line (fp);
if (!p)
- break;
+ break;
if (p[0] == '[' && p[strlen (p) - 1] == ']')
- {
- mode = MODE_UNKNOWN;
- /* strip [ ] braces */
- if (p[1] == ' ')
- p += 2;
- else
- p += 1;
- p[strlen (p) - 1] = '\0';
- if (isspace (p[strlen (p) - 1]))
- p[strlen (p) - 1] = '\0';
- q = strchr (p, ' ');
- if (q)
- *q++ = '\0';
-
- if (g_strcasecmp (p, "database") == 0)
- {
- if (q && *q != '\0')
- {
- mode = MODE_DATABASE;
- if (dbname)
- g_free (dbname);
- dbname = g_strdup (q);
- add_database (c, q);
- }
- else
- {
- mode = MODE_UNKNOWN;
- fprintf (stderr, "error: database name not given.\n");
- config_failed = 1;
- }
- }
- else if (g_strcasecmp (p, "global") == 0)
- {
- mode = MODE_GLOBAL;
- }
- else
- {
- config_failed = 1;
- fprintf (stderr, "error: unknown section '%s'\n", p);
- }
- }
+ {
+ mode = MODE_UNKNOWN;
+ /* strip [ ] braces */
+ if (p[1] == ' ')
+ p += 2;
+ else
+ p += 1;
+ p[strlen (p) - 1] = '\0';
+ if (isspace (p[strlen (p) - 1]))
+ p[strlen (p) - 1] = '\0';
+ q = strchr (p, ' ');
+ if (q)
+ *q++ = '\0';
+
+ if (g_strcasecmp (p, "database") == 0)
+ {
+ if (q && *q != '\0')
+ {
+ mode = MODE_DATABASE;
+ if (dbname)
+ g_free (dbname);
+ dbname = g_strdup (q);
+ add_database (c, q);
+ }
+ else
+ {
+ mode = MODE_UNKNOWN;
+ fprintf (stderr, "error: database name not given.\n");
+ config_failed = 1;
+ }
+ }
+ else if (g_strcasecmp (p, "global") == 0)
+ {
+ mode = MODE_GLOBAL;
+ }
+ else
+ {
+ config_failed = 1;
+ fprintf (stderr, "error: unknown section '%s'\n", p);
+ }
+ }
else
- {
- q = strchr (p, ' ');
- if (q)
- *q++ = '\0';
- if (!q)
- {
- config_failed = 1;
- fprintf (stderr,
- "error: option %s does not have a value.\n", p);
- continue;
- }
- /* key to lower case */
- tmp = p;
- while (p != NULL && *p != '\0')
- {
- *p = tolower (*p);
- p++;
- }
- p = tmp;
-
- switch (mode)
- {
- case MODE_UNKNOWN:
- break;
- case MODE_DATABASE:
- /* printf( "database %s : %s = %s\n" , dbname , p , q
- ); */
- add_database_option (c, dbname, p, q);
- break;
- case MODE_GLOBAL:
- /* printf( "global: %s = %s\n" , p , q ); */
- if (strstr (p, "password") != NULL)
- {
- fprintf (stderr,
- "error: passwords must not be included in the main
configuration file.\n");
- fprintf (stderr,
- " the shadow password file should be used,
instead.\n");
- config_failed = 1;
- }
- add_section_option (c, p, q);
- break;
- }
- }
+ {
+ q = strchr (p, ' ');
+ if (q)
+ *q++ = '\0';
+ if (!q)
+ {
+ config_failed = 1;
+ fprintf (stderr,
+ "error: option %s does not have a value.\n", p);
+ continue;
+ }
+ /* key to lower case */
+ tmp = p;
+ while (p != NULL && *p != '\0')
+ {
+ *p = tolower (*p);
+ p++;
+ }
+ p = tmp;
+
+ switch (mode)
+ {
+ case MODE_UNKNOWN:
+ break;
+ case MODE_DATABASE:
+ /* printf( "database %s : %s = %s\n" , dbname , p , q
+ ); */
+ add_database_option (c, dbname, p, q);
+ break;
+ case MODE_GLOBAL:
+ /* printf( "global: %s = %s\n" , p , q ); */
+ if (strstr (p, "password") != NULL)
+ {
+ fprintf (stderr,
+ "error: passwords must not be included in the main
configuration file.\n");
+ fprintf (stderr,
+ " the shadow password file should be used,
instead.\n");
+ config_failed = 1;
+ }
+ add_section_option (c, p, q);
+ break;
+ }
+ }
}
fclose (fp);
if (dbname)
@@ -635,25 +635,25 @@
{
/* free name */
if (c->name)
- g_free (c->name);
+ g_free (c->name);
/* free options in this section */
l = c->globals;
while (l)
- {
- i = (config_item *) l->data;
- free_config_item (i);
- l = g_list_next (l);
- }
+ {
+ i = (config_item *) l->data;
+ free_config_item (i);
+ l = g_list_next (l);
+ }
g_list_free (c->globals);
/* free contained sections */
l = c->database;
while (l)
- {
- free_configuration ((configuration) l->data);
- l = g_list_next (l);
- }
+ {
+ free_configuration ((configuration) l->data);
+ l = g_list_next (l);
+ }
g_list_free (c->database);
/* free data */
@@ -718,15 +718,14 @@
g_return_val_if_fail (key, NULL);
l = ((configuration_data *) config)->globals;
-
while (l)
{
i = (config_item *) l->data;
g_assert (i);
if (g_strcasecmp (i->key, key) == 0)
- {
- return (i->value);
- }
+ {
+ return (i->value);
+ }
l = g_list_next (l);
}
return (NULL);
@@ -749,7 +748,7 @@
\* ------------------------------------------------------------------------- */
gboolean
get_global_option_bool (configuration config, const char *key,
- gboolean defaultval)
+ gboolean defaultval)
{
const char *o = get_global_option (config, key);
if (!o)
@@ -777,7 +776,7 @@
\* ------------------------------------------------------------------------- */
const char *
get_global_option_str (configuration config, const char *key,
- const char *defaultval)
+ const char *defaultval)
{
const char *o = get_global_option (config, key);
if (o)
@@ -791,7 +790,7 @@
\* ------------------------------------------------------------------------- */
const char *
get_database_option (configuration tree, const char *database,
- const char *key)
+ const char *key)
{
configuration_data *c;
@@ -811,7 +810,7 @@
\* ------------------------------------------------------------------------- */
const char *
get_database_option_str (configuration tree, const char *databasename,
- const char *key, const char *defaultvalue)
+ const char *key, const char *defaultvalue)
{
const char *o = get_database_option (tree, databasename, key);
if (o)
@@ -825,7 +824,7 @@
\* ------------------------------------------------------------------------- */
gboolean
get_database_option_bool (configuration tree, const char *databasename,
- const char *key, gboolean defaultval)
+ const char *key, gboolean defaultval)
{
const char *o = get_database_option (tree, databasename, key);
if (!o)
@@ -853,7 +852,7 @@
\* ------------------------------------------------------------------------- */
int
get_database_option_int (configuration tree, const char *databasename,
- const char *key, int defaultval)
+ const char *key, int defaultval)
{
const char *o = get_database_option (tree, databasename, key);
if (o)
@@ -877,7 +876,7 @@
i = (configuration_data *) l->data;
dbname = i->name;
if (get_database_option_bool (tree, dbname, "active", FALSE))
- return (dbname);
+ return (dbname);
l = g_list_next (l);
}
return (NULL);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/src/config configuration.c,
Neil Tiffin <=