X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Ffiles%2Fcfgreader.c;h=dd0e575e5c0ff11e05aa3ed7ecd128b821dc8722;hp=ad257087afbf2c585e5d2587c96d3078794e7e17;hb=0484268a27be1ab830d087847d830bc0ec734016;hpb=975a83d253eea8aa37bf3dfd7e026df3027db4ff diff --git a/common/files/cfgreader.c b/common/files/cfgreader.c index ad25708..dd0e575 100644 --- a/common/files/cfgreader.c +++ b/common/files/cfgreader.c @@ -27,10 +27,8 @@ #include "files/cfgreader.h" -#ifndef UCLINUX - /* Read configuration information from a ".INI" style file */ -static struct CFG_Header *CFG_ReadFile(char *filename) +struct CFG_Header *CFG_ReadFile(char *filename) { FILE *handle; char *line; @@ -50,7 +48,7 @@ static struct CFG_Header *CFG_ReadFile(char *filename) /* Open file */ if ((handle = fopen(filename, "r")) == NULL) { #ifdef DEBUG - fprintf( stderr, "CFG_ReadFile - open %s: %s\n", filename, strerror(errno)); +// fprintf( stderr, "CFG_ReadFile - open %s: %s\n", filename, strerror(errno)); #endif /* DEBUG */ return NULL; } @@ -106,7 +104,7 @@ static struct CFG_Header *CFG_ReadFile(char *filename) cfg_info = heading; #ifdef DEBUG - fprintf(stderr, "Added new section %s\n", heading->section); +// fprintf(stderr, "Added new section %s\n", heading->section); #endif /* Go on to next line */ @@ -155,7 +153,7 @@ static struct CFG_Header *CFG_ReadFile(char *filename) cfg_info->entries = entry; #ifdef DEBUG - fprintf(stderr, "Adding key/value %s/%s\n", entry->key, entry->value); +// fprintf(stderr, "Adding key/value %s/%s\n", entry->key, entry->value); #endif /* Go on to next line */ continue; @@ -171,7 +169,7 @@ static struct CFG_Header *CFG_ReadFile(char *filename) /* Write configuration information to a config file */ -static int CFG_WriteFile(struct CFG_Header *cfg, char *filename) +int CFG_WriteFile(struct CFG_Header *cfg, char *filename) { /* Not implemented - tricky to do and preserve comments */ @@ -211,7 +209,7 @@ char *CFG_Get(struct CFG_Header *cfg, char *section, char *key) /* Set the value of a key in a config file. Return the new value if the section/key can be found, else return NULL. */ -static char *CFG_Set(struct CFG_Header *cfg, char *section, char *key, +char *CFG_Set(struct CFG_Header *cfg, char *section, char *key, char *value) { struct CFG_Header *h; @@ -267,7 +265,7 @@ struct CFG_Header *CFG_FindGnokiirc() if ((cfg_info = CFG_ReadFile("/etc/gnokiirc")) == NULL) { /* That failed too so exit */ #ifdef DEBUG - fprintf(stderr, _("Couldn't open %s or /etc/gnokiirc. Using defaults...\n"), rcfile); +// fprintf(stderr, _("Couldn't open %s or /etc/gnokiirc. Using defaults...\n"), rcfile); #endif /* DEBUG */ return NULL; } @@ -278,7 +276,7 @@ struct CFG_Header *CFG_FindGnokiirc() if ((cfg_info = CFG_ReadFile("gnokiirc")) == NULL) { /* That failed too so exit */ #ifdef DEBUG - fprintf(stderr, _("Couldn't open %s or gnokiirc. Using defaults...\n"), rcfile); +// fprintf(stderr, _("Couldn't open %s or gnokiirc. Using defaults...\n"), rcfile); #endif /* DEBUG */ return NULL; } @@ -289,21 +287,10 @@ struct CFG_Header *CFG_FindGnokiirc() return cfg_info; } -#endif /* UCLINUX */ - int CFG_ReadConfig(char **model, char **port, char **initlength, - char **connection, char **bindir, + char **connection, char **bindir, char **synchronizetime, bool isgnokiid) { -#ifdef UCLINUX - - *model=strdup(CONFIG_CFG_MODEL); - *port=strdup(CONFIG_CFG_PORT); - *initlength=strdup(CONFIG_CFG_INITLENGTH); - *connection=strdup("fbus"); - *bindir=NULL; - -#else /* UCLINUX */ struct CFG_Header *cfg_info; #ifdef WIN32 char *DefaultPort = "com2:"; @@ -313,6 +300,7 @@ int CFG_ReadConfig(char **model, char **port, char **initlength, char *DefaultModel = "auto"; char *DefaultConnection = "fbus"; char *DefaultBindir = "/usr/local/sbin/"; + char *DefaultSynchronizeTime = "yes"; char *DefaultInitLength = "30"; char *section = "global"; @@ -321,6 +309,7 @@ int CFG_ReadConfig(char **model, char **port, char **initlength, (char *)*port = DefaultPort; (char *)*connection = DefaultConnection; (char *)*bindir = DefaultBindir; + (char *)*synchronizetime = DefaultSynchronizeTime; (char *)*initlength = DefaultInitLength; cfg_info=CFG_FindGnokiirc(); @@ -340,9 +329,11 @@ int CFG_ReadConfig(char **model, char **port, char **initlength, (char *)*bindir = CFG_Get(cfg_info, section, "bindir"); if (!*bindir) (char *)*bindir = DefaultBindir; + (char *)*synchronizetime = CFG_Get(cfg_info, section, "synchronizetime"); + if (!*synchronizetime) (char *)*synchronizetime = DefaultSynchronizeTime; + (char *)*initlength = CFG_Get(cfg_info, section, "initlength"); if (!*initlength) (char *)*initlength = "default"; -#endif /* UCLINUX */ return 0; }