Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
c02e5f74
Commit
c02e5f74
authored
17 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created iniGet/ReadEnumList() functions for Deuce (he did say "please").
Do we need an iniSetEnumList() function too?
parent
45a55fce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/ini_file.c
+58
-0
58 additions, 0 deletions
src/xpdev/ini_file.c
src/xpdev/ini_file.h
+4
-0
4 additions, 0 deletions
src/xpdev/ini_file.h
with
62 additions
and
0 deletions
src/xpdev/ini_file.c
+
58
−
0
View file @
c02e5f74
...
...
@@ -1523,6 +1523,36 @@ static unsigned parseEnum(const char* value, str_list_t names)
return
(
strtoul
(
value
,
NULL
,
0
));
}
static
unsigned
*
parseEnumList
(
const
char
*
values
,
const
char
*
sep
,
str_list_t
names
)
{
char
*
vals
;
str_list_t
list
;
unsigned
*
enum_list
;
size_t
i
,
count
;
if
(
values
==
NULL
)
return
NULL
;
if
((
vals
=
strdup
(
values
))
==
NULL
)
return
NULL
;
list
=
splitList
(
vals
,
sep
);
free
(
vals
);
if
((
count
=
strListCount
(
list
))
<
1
)
return
NULL
;
if
((
enum_list
=
(
unsigned
*
)
malloc
(
count
*
sizeof
(
unsigned
)))
!=
NULL
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
enum_list
[
i
]
=
parseEnum
(
list
[
i
],
names
);
}
strListFree
(
&
list
);
return
enum_list
;
}
unsigned
iniReadEnum
(
FILE
*
fp
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
deflt
)
{
char
buf
[
INI_MAX_VALUE_LEN
];
...
...
@@ -1537,6 +1567,19 @@ unsigned iniReadEnum(FILE* fp, const char* section, const char* key, str_list_t
return
(
parseEnum
(
value
,
names
));
}
unsigned
*
iniReadEnumList
(
FILE
*
fp
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
const
char
*
sep
,
const
char
*
deflt
)
{
char
*
value
;
char
buf
[
INI_MAX_VALUE_LEN
];
if
((
value
=
read_value
(
fp
,
section
,
key
,
buf
))
==
NULL
||
*
value
==
0
/* blank */
)
value
=
(
char
*
)
deflt
;
return
(
parseEnumList
(
value
,
sep
,
names
));
}
unsigned
iniGetEnum
(
str_list_t
list
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
deflt
)
{
char
value
[
INI_MAX_VALUE_LEN
];
...
...
@@ -1549,6 +1592,21 @@ unsigned iniGetEnum(str_list_t list, const char* section, const char* key, str_l
return
(
parseEnum
(
value
,
names
));
}
unsigned
*
iniGetEnumList
(
str_list_t
list
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
const
char
*
sep
,
const
char
*
deflt
)
{
char
value
[
INI_MAX_VALUE_LEN
];
get_value
(
list
,
section
,
key
,
value
);
if
(
*
value
==
0
/* blank value or missing key */
)
{
if
(
deflt
==
NULL
)
return
(
NULL
);
SAFECOPY
(
value
,
deflt
);
}
return
(
parseEnumList
(
value
,
sep
,
names
));
}
static
long
parseNamedInt
(
const
char
*
value
,
named_long_t
*
names
)
{
unsigned
i
;
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/ini_file.h
+
4
−
0
View file @
c02e5f74
...
...
@@ -100,6 +100,8 @@ time_t iniReadDateTime(FILE*, const char* section, const char* key
,
time_t
deflt
);
unsigned
iniReadEnum
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
deflt
);
unsigned
*
iniReadEnumList
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
const
char
*
sep
,
const
char
*
deflt
);
long
iniReadNamedInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
named_long_t
*
,
long
deflt
);
double
iniReadNamedFloat
(
FILE
*
,
const
char
*
section
,
const
char
*
key
...
...
@@ -152,6 +154,8 @@ time_t iniGetDateTime(str_list_t, const char* section, const char* key
,
time_t
deflt
);
unsigned
iniGetEnum
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
deflt
);
unsigned
*
iniGetEnumList
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
const
char
*
sep
,
const
char
*
deflt
);
long
iniGetNamedInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
named_long_t
*
,
long
deflt
);
double
iniGetNamedFloat
(
str_list_t
,
const
char
*
section
,
const
char
*
key
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment