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
27f55277
Commit
27f55277
authored
5 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added strListJoin() and strListIsEmpty() functions (for use in SBBSecho).
parent
8ef6b662
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/str_list.c
+30
-0
30 additions, 0 deletions
src/xpdev/str_list.c
src/xpdev/str_list.h
+6
-2
6 additions, 2 deletions
src/xpdev/str_list.h
with
36 additions
and
2 deletions
src/xpdev/str_list.c
+
30
−
0
View file @
27f55277
...
...
@@ -61,6 +61,11 @@ size_t DLLCALL strListCount(const str_list_t list)
return
(
i
);
}
BOOL
DLLCALL
strListIsEmpty
(
const
str_list_t
list
)
{
return
(
list
==
NULL
)
||
(
list
[
0
]
==
NULL
);
}
int
DLLCALL
strListIndexOf
(
const
str_list_t
list
,
const
char
*
str
)
{
size_t
i
;
...
...
@@ -614,6 +619,31 @@ size_t DLLCALL strListWriteFile(FILE* fp, const str_list_t list, const char* sep
return
(
i
);
}
char
*
strListJoin
(
const
str_list_t
list
,
char
*
buf
,
size_t
buflen
,
const
char
*
separator
)
{
size_t
i
;
if
(
buflen
<
1
)
return
NULL
;
*
buf
=
'\0'
;
if
(
list
==
NULL
)
return
buf
;
if
(
separator
==
NULL
)
separator
=
", "
;
for
(
i
=
0
;
list
[
i
]
!=
NULL
;
i
++
)
{
if
(
strlen
(
buf
)
+
strlen
(
separator
)
+
strlen
(
list
[
i
])
>=
buflen
)
break
;
if
(
i
>
0
)
strcat
(
buf
,
separator
);
strcat
(
buf
,
list
[
i
]);
}
return
buf
;
}
size_t
DLLCALL
strListBlockLength
(
char
*
block
)
{
char
*
p
=
block
;
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/str_list.h
+
6
−
2
View file @
27f55277
...
...
@@ -71,7 +71,7 @@ DLLEXPORT char* DLLCALL strListAppend(str_list_t*, const char* str, size_t inde
DLLEXPORT
size_t
DLLCALL
strListAppendList
(
str_list_t
*
,
const
str_list_t
append_list
);
/* Append a malloc'd formatted string to the end of the list */
DLLEXPORT
char
*
DLLCALL
strListAppendFormat
(
str_list_t
*
list
,
const
char
*
format
,
...);
DLLEXPORT
char
*
DLLCALL
strListAppendFormat
(
str_list_t
*
list
,
const
char
*
format
,
...);
/* Inserts a string into the list at a specific index */
/* Pass a pointer to a string list, the string to add (insert) */
...
...
@@ -82,7 +82,7 @@ DLLEXPORT char* DLLCALL strListInsert(str_list_t*, const char* str, size_t inde
DLLEXPORT
size_t
DLLCALL
strListInsertList
(
str_list_t
*
,
const
str_list_t
append_list
,
size_t
index
);
/* Insert a malloc'd formatted string into the list */
DLLEXPORT
char
*
DLLCALL
strListInsertFormat
(
str_list_t
*
list
,
size_t
index
,
const
char
*
format
,
...);
DLLEXPORT
char
*
DLLCALL
strListInsertFormat
(
str_list_t
*
list
,
size_t
index
,
const
char
*
format
,
...);
/* Remove a string at a specific index */
DLLEXPORT
char
*
DLLCALL
strListRemove
(
str_list_t
*
,
size_t
index
);
...
...
@@ -93,6 +93,9 @@ DLLEXPORT BOOL DLLCALL strListDelete(str_list_t*, size_t index);
/* Replace a string at a specific index */
DLLEXPORT
char
*
DLLCALL
strListReplace
(
const
str_list_t
,
size_t
index
,
const
char
*
str
);
/* Return a single-string representation of the entire string list, joined with the specified separator */
DLLEXPORT
char
*
DLLCALL
strListJoin
(
const
str_list_t
,
char
*
buf
,
size_t
buflen
,
const
char
*
separator
);
/* Call a modification callback function for each string in a list */
/* and replace each string with the result of the modification callback. */
/* If the modification callback function returns NULL, the string is not modified. */
...
...
@@ -127,6 +130,7 @@ DLLEXPORT char* DLLCALL strListCombine(str_list_t, char* buf, size_t maxlen, co
/* Count the number of strings in the list and returns the count */
DLLEXPORT
size_t
DLLCALL
strListCount
(
const
str_list_t
);
DLLEXPORT
BOOL
DLLCALL
strListIsEmpty
(
const
str_list_t
);
/* Returns the index of the specified str (by ptr compare) or -1 if not found */
DLLEXPORT
int
DLLCALL
strListIndexOf
(
const
str_list_t
,
const
char
*
str
);
...
...
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