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
4b2c80c2
Commit
4b2c80c2
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created strListSplit() and strListSplitCopy().
parent
a2fed57c
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
+34
-3
34 additions, 3 deletions
src/xpdev/str_list.c
src/xpdev/str_list.h
+10
-3
10 additions, 3 deletions
src/xpdev/str_list.h
with
44 additions
and
6 deletions
src/xpdev/str_list.c
+
34
−
3
View file @
4b2c80c2
...
...
@@ -49,7 +49,7 @@ str_list_t strListAlloc()
return
(
list
);
}
size_t
strListCount
(
str_list_t
list
)
size_t
strListCount
(
const
str_list_t
list
)
{
size_t
i
;
...
...
@@ -62,7 +62,7 @@ size_t strListCount(str_list_t list)
return
(
i
);
}
str_list_t
strListAddAt
(
str_list_t
*
list
,
char
*
str
,
size_t
count
)
str_list_t
strListAddAt
(
str_list_t
*
list
,
const
char
*
str
,
size_t
count
)
{
str_list_t
lp
;
...
...
@@ -80,11 +80,42 @@ str_list_t strListAddAt(str_list_t* list, char* str, size_t count)
}
str_list_t
strListAdd
(
str_list_t
*
list
,
char
*
str
)
str_list_t
strListAdd
(
str_list_t
*
list
,
const
char
*
str
)
{
return
strListAddAt
(
list
,
str
,
strListCount
(
*
list
));
}
str_list_t
strListSplit
(
str_list_t
*
list
,
char
*
str
,
const
char
*
delimit
)
{
char
*
token
;
if
(
list
==
NULL
)
{
if
((
*
list
=
strListAlloc
())
==
NULL
)
return
(
NULL
);
}
for
(
token
=
strtok
(
str
,
delimit
);
token
!=
NULL
;
token
=
strtok
(
NULL
,
delimit
))
strListAdd
(
list
,
token
);
return
(
*
list
);
}
str_list_t
strListSplitCopy
(
str_list_t
*
list
,
const
char
*
str
,
const
char
*
delimit
)
{
char
*
buf
;
if
((
buf
=
malloc
(
strlen
(
str
)
+
1
))
==
NULL
)
return
(
NULL
);
strcpy
(
buf
,
str
);
*
list
=
strListSplit
(
list
,
buf
,
delimit
);
free
(
buf
);
return
(
*
list
);
}
static
int
strListCompareAlpha
(
const
void
*
arg1
,
const
void
*
arg2
)
{
return
stricmp
(
*
(
char
**
)
arg1
,
*
(
char
**
)
arg2
);
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/str_list.h
+
10
−
3
View file @
4b2c80c2
...
...
@@ -54,13 +54,20 @@ void strListFree(str_list_t* list);
/* Pass a pointer to a string list, the string to add */
/* Returns the updated list or NULL on error */
str_list_t
strListAdd
(
str_list_t
*
list
,
char
*
str
);
str_list_t
strListAdd
(
str_list_t
*
list
,
const
char
*
str
);
/* Adds a string into the list at a specific index */
str_list_t
strListAddAt
(
str_list_t
*
list
,
char
*
str
,
size_t
index
);
str_list_t
strListAddAt
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
);
/* Add to an exiting or new string list by splitting specified string (str) */
/* into multiple strings, separated by one of the delimit characters */
str_list_t
strListSplit
(
str_list_t
*
list
,
char
*
str
,
const
char
*
delimit
);
/* Same as above, but copies str to temporary heap buffer first */
str_list_t
strListSplitCopy
(
str_list_t
*
list
,
const
char
*
str
,
const
char
*
delimit
);
/* Count the number of strings in the list and returns the count */
size_t
strListCount
(
str_list_t
list
);
size_t
strListCount
(
const
str_list_t
list
);
void
strListSortAlpha
(
str_list_t
list
);
void
strListSortAlphaReverse
(
str_list_t
list
);
...
...
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