Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=gfpm.git;a=commitdiff;h=a0baf106fd3c381756d6f803e6ae40864af7656c

commit a0baf106fd3c381756d6f803e6ae40864af7656c
Author: Priyank <priy...@frugalware.org>
Date:   Tue Jun 9 13:33:16 2009 +0530

update wejpconfig to version 061102

diff --git a/src/wejpconfig.c b/src/wejpconfig.c
index d81a118..35536e0 100644
--- a/src/wejpconfig.c
+++ b/src/wejpconfig.c
@@ -2,8 +2,9 @@
* Wejp's Config File Parser
*
* File: wejpconfig.c
+ * Version: 061102
*
- * Copyright (c) 2003-2004 Johannes Heimansberg
+ * Copyright (c) 2003-2006 Johannes Heimansberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -19,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

-#define VERSION 20051026
+#define VERSION 20061102
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -127,11 +128,17 @@ int cfg_read_config_file(ConfigFile *cf, char *filename)
{
ch = fgetc(file);
/* Skip blanks... */
-                       if (ch == ' ' || ch == '\t')
-                               while (ch == ' ' || ch == '\t') ch = 
fgetc(file);
+                       if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
+                               while (ch == ' ' || ch == '\t' || ch == '\r' || 
ch == '\n') ch = fgetc(file);
/* ...and comments (#)... */
-                       if (ch == '#')
-                               while (ch != '\n' && ch != '\r') ch = 
fgetc(file);
+                       do {
+                               if (ch == '#') {
+                                       while (ch != '\n' && ch != '\r') ch = 
fgetc(file);
+                                       ch = fgetc(file);
+                               }
+                               if (ch == ' ' || ch == '\t' || ch == '\n' || ch 
== '\r')
+                                       ch = fgetc(file);
+                       } while (ch == '#' || ch == ' ' || ch == '\t' || ch == 
'\n' || ch == '\r');

bufcnt = 0;
/* Read key name: */
@@ -183,14 +190,13 @@ int cfg_write_config_file(ConfigFile *cf, char *filename)
{
FILE *file;
int  i = 0, result = 0;
-       char buffer[128];
-
+       char buffer[256];
file = fopen(filename, "w");
if (file != NULL)
{
while (i < cf->lastkey)
{
-                       sprintf(buffer, "%s=%s\n", cf->key[i], cf->value[i]);
+                       snprintf(buffer, 255, "%s=%s\n", cf->key[i], 
cf->value[i]);
fwrite(buffer, strlen(buffer) * sizeof(char), 1, file);
i++;
}
diff --git a/src/wejpconfig.h b/src/wejpconfig.h
index 403731c..51a2826 100644
--- a/src/wejpconfig.h
+++ b/src/wejpconfig.h
@@ -2,8 +2,9 @@
* Wejp's Config File Parser
*
* File: wejpconfig.h
+ * Version: 061102
*
- * Copyright (c) 2003-2004 Johannes Heimansberg
+ * Copyright (c) 2003-2006 Johannes Heimansberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -19,8 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

-#ifndef _CONFIG_H
-#define _CONFIG_H
+#ifndef _WEJPCONFIG_H
+#define _WEJPCONFIG_H
#ifndef TRUE
#define TRUE 1
#define FALSE 0
@@ -35,12 +36,12 @@ typedef struct
} ConfigFile;
#endif

-void cfg_init_config_file_struct(ConfigFile *cf);
-int  cfg_add_key(ConfigFile *cf, char *key, char *value);
-void cfg_free_config_file_struct(ConfigFile *cf);
-int  cfg_read_config_file(ConfigFile *cf, char *filename);
-int  cfg_write_config_file(ConfigFile *cf, char *filename);
+void  cfg_init_config_file_struct(ConfigFile *cf);
+int   cfg_add_key(ConfigFile *cf, char *key, char *value);
+void  cfg_free_config_file_struct(ConfigFile *cf);
+int   cfg_read_config_file(ConfigFile *cf, char *filename);
+int   cfg_write_config_file(ConfigFile *cf, char *filename);
char *cfg_get_key_value(ConfigFile cf, char *key);
-int  cfg_check_config_file(char *filename);
+int   cfg_check_config_file(char *filename);
char *cfg_get_path_to_config_file(char *filename);
-int  cfg_is_key_available(ConfigFile cf, char *key);
+int   cfg_is_key_available(ConfigFile cf, char *key);
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to