* profile.c: Remove unused code. Eliminate global variables.
(is_loaded): Rename to find_loaded(). return matching profile. Adjust all dependencies.
Этот коммит содержится в:
родитель
ca90bd204f
Коммит
53982cb546
@ -1,5 +1,9 @@
|
|||||||
2002-09-06 Pavel Roskin <proski@gnu.org>
|
2002-09-06 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* profile.c: Remove unused code. Eliminate global variables.
|
||||||
|
(is_loaded): Rename to find_loaded(). return matching profile.
|
||||||
|
Adjust all dependencies.
|
||||||
|
|
||||||
* fs.h: Only redefine S_IS* macros if they are undefined, and
|
* fs.h: Only redefine S_IS* macros if they are undefined, and
|
||||||
then define them to 0. S_IF* constants should be avoided.
|
then define them to 0. S_IF* constants should be avoided.
|
||||||
* util.c : Whenever possible, use standard POSIX macros to test
|
* util.c : Whenever possible, use standard POSIX macros to test
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
|
|
||||||
#define INIFILE "xxx.ini"
|
|
||||||
#define STRSIZE 4096
|
#define STRSIZE 4096
|
||||||
#define overflow (next == &CharBuffer [STRSIZE-1])
|
#define overflow (next == &CharBuffer [STRSIZE-1])
|
||||||
|
|
||||||
@ -53,22 +52,21 @@ typedef struct TProfile {
|
|||||||
struct TProfile *link;
|
struct TProfile *link;
|
||||||
} TProfile;
|
} TProfile;
|
||||||
|
|
||||||
TProfile *Current = 0;
|
static TProfile *Base = 0;
|
||||||
TProfile *Base = 0;
|
|
||||||
|
|
||||||
static int is_loaded (char *FileName, TSecHeader **section)
|
static TProfile *
|
||||||
|
find_loaded (char *FileName, TSecHeader ** section)
|
||||||
{
|
{
|
||||||
TProfile *p = Base;
|
TProfile *p = Base;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
if (!g_strcasecmp (FileName, p->FileName)) {
|
if (!g_strcasecmp (FileName, p->FileName)) {
|
||||||
Current = p;
|
|
||||||
*section = p->Section;
|
*section = p->Section;
|
||||||
return 1;
|
return p;
|
||||||
}
|
}
|
||||||
p = p->link;
|
p = p->link;
|
||||||
}
|
}
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TRANSLATION_CHAR '\200'
|
#define TRANSLATION_CHAR '\200'
|
||||||
@ -260,18 +258,18 @@ GetSetProfileChar (int set, const char *AppName, char *KeyName,
|
|||||||
char *Default, char *FileName)
|
char *Default, char *FileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
TProfile *New;
|
TProfile *Current;
|
||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
TKeys *key;
|
TKeys *key;
|
||||||
|
|
||||||
if (!is_loaded (FileName, §ion)){
|
Current = find_loaded (FileName, §ion);
|
||||||
New = g_new (TProfile, 1);
|
if (!Current) {
|
||||||
New->link = Base;
|
Current = g_new (TProfile, 1);
|
||||||
New->FileName = g_strdup (FileName);
|
Current->link = Base;
|
||||||
New->Section = load (FileName);
|
Current->FileName = g_strdup (FileName);
|
||||||
Base = New;
|
Current->Section = load (FileName);
|
||||||
section = New->Section;
|
Base = Current;
|
||||||
Current = New;
|
section = Current->Section;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start search */
|
/* Start search */
|
||||||
@ -336,15 +334,6 @@ char *get_profile_string (const char *AppName, char *KeyName, char *Default,
|
|||||||
return GetSetProfileChar (0, AppName, KeyName, Default, FileName);
|
return GetSetProfileChar (0, AppName, KeyName, Default, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int GetProfileString (const char * AppName, char * KeyName, char * Default,
|
|
||||||
char * ReturnedString, int Size)
|
|
||||||
{
|
|
||||||
return GetPrivateProfileString (AppName, KeyName, Default,
|
|
||||||
ReturnedString, Size, INIFILE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int GetPrivateProfileInt (const char * AppName, char * KeyName, int Default,
|
int GetPrivateProfileInt (const char * AppName, char * KeyName, int Default,
|
||||||
char * File)
|
char * File)
|
||||||
{
|
{
|
||||||
@ -362,26 +351,12 @@ int GetPrivateProfileInt (const char * AppName, char * KeyName, int Default,
|
|||||||
return (int) atol (IntBuf);
|
return (int) atol (IntBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int GetProfileInt (const char * AppName, char * KeyName, int Default)
|
|
||||||
{
|
|
||||||
return GetPrivateProfileInt (AppName, KeyName, Default, INIFILE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int WritePrivateProfileString (const char * AppName, char * KeyName, char * String,
|
int WritePrivateProfileString (const char * AppName, char * KeyName, char * String,
|
||||||
char * FileName)
|
char * FileName)
|
||||||
{
|
{
|
||||||
return GetSetProfile (1, AppName, KeyName, String, "", 0, FileName);
|
return GetSetProfile (1, AppName, KeyName, String, "", 0, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int WriteProfileString (const char * AppName, char * KeyName, char * String)
|
|
||||||
{
|
|
||||||
return (WritePrivateProfileString (AppName, KeyName, String, INIFILE));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void dump_keys (FILE * profile, TKeys * p)
|
static void dump_keys (FILE * profile, TKeys * p)
|
||||||
{
|
{
|
||||||
char *t;
|
char *t;
|
||||||
@ -484,17 +459,17 @@ void free_profiles (void)
|
|||||||
|
|
||||||
void *profile_init_iterator (char *appname, char *file)
|
void *profile_init_iterator (char *appname, char *file)
|
||||||
{
|
{
|
||||||
TProfile *New;
|
TProfile *Current;
|
||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
|
|
||||||
if (!is_loaded (file, §ion)){
|
Current = find_loaded (file, §ion);
|
||||||
New = g_new (TProfile, 1);
|
if (!Current) {
|
||||||
New->link = Base;
|
Current = g_new (TProfile, 1);
|
||||||
New->FileName = g_strdup (file);
|
Current->link = Base;
|
||||||
New->Section = load (file);
|
Current->FileName = g_strdup (file);
|
||||||
Base = New;
|
Current->Section = load (file);
|
||||||
section = New->Section;
|
Base = Current;
|
||||||
Current = New;
|
section = Current->Section;
|
||||||
}
|
}
|
||||||
for (; section; section = section->link){
|
for (; section; section = section->link){
|
||||||
if ( g_strcasecmp (section->AppName, appname))
|
if ( g_strcasecmp (section->AppName, appname))
|
||||||
@ -521,7 +496,7 @@ void profile_clean_section (char *appname, char *file)
|
|||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
|
|
||||||
/* We assume the user has called one of the other initialization funcs */
|
/* We assume the user has called one of the other initialization funcs */
|
||||||
if (!is_loaded (file, §ion)){
|
if (!find_loaded (file, §ion)){
|
||||||
fprintf (stderr,"Warning: profile_clean_section called before init\n");
|
fprintf (stderr,"Warning: profile_clean_section called before init\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -540,7 +515,7 @@ int profile_has_section (char *section_name, char *profile)
|
|||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
|
|
||||||
/* We assume the user has called one of the other initialization funcs */
|
/* We assume the user has called one of the other initialization funcs */
|
||||||
if (!is_loaded (profile, §ion)){
|
if (!find_loaded (profile, §ion)){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (; section; section = section->link){
|
for (; section; section = section->link){
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user