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
81457b26
Commit
81457b26
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Add iniGetSString() that takes the size of the buffer
parent
904d202a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/ini_file.c
+23
-0
23 additions, 0 deletions
src/xpdev/ini_file.c
src/xpdev/ini_file.h
+5
-0
5 additions, 0 deletions
src/xpdev/ini_file.h
with
28 additions
and
0 deletions
src/xpdev/ini_file.c
+
23
−
0
View file @
81457b26
...
...
@@ -1038,6 +1038,29 @@ char* iniGetString(str_list_t list, const char* section, const char* key, const
return
(
vp
);
}
char
*
iniGetSString
(
str_list_t
list
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
,
size_t
sz
)
{
char
fval
[
INI_MAX_VALUE_LEN
];
char
*
ret
;
size_t
pos
;
ret
=
iniGetString
(
list
,
section
,
key
,
deflt
,
value
);
if
(
ret
==
NULL
)
return
ret
;
if
(
sz
<
1
||
value
==
NULL
)
return
ret
;
for
(
pos
=
0
;
fval
[
pos
];
pos
++
)
{
Rob Swindell
@rswindell
·
Feb 20, 2024
Owner
It appears you're using
fval
here without being initialized.
It appears you're using `fval` here without being initialized.
Please
register
or
sign in
to reply
if
(
pos
==
sz
-
1
)
{
value
[
pos
]
=
0
;
break
;
}
value
[
pos
]
=
fval
[
pos
];
}
if
(
ret
==
fval
)
return
value
;
return
ret
;
}
/* Does NOT support string literals: */
char
*
iniGetValue
(
str_list_t
list
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
)
{
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/ini_file.h
+
5
−
0
View file @
81457b26
...
...
@@ -149,6 +149,11 @@ DLLEXPORT char* iniGetExistingValue(str_list_t, const char* section, const cha
/* Return the string value (potentially string literals separated by colon rather than equal): */
DLLEXPORT
char
*
iniGetString
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
/* may be NULL */
);
/* As above but specify the size of value */
DLLEXPORT
char
*
iniGetSString
(
str_list_t
listr
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
/* may be NULL */
,
size_t
sz
);
/* If the key doesn't exist, iniGetExistingString just returns NULL */
DLLEXPORT
char
*
iniGetExistingString
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
/* may be NULL */
);
...
...
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