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
1dbbe232
Commit
1dbbe232
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Renamed strListAlloc() to strListInit().
Created strListAddList() and strListMerge().
parent
8069f5ce
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
+38
-7
38 additions, 7 deletions
src/xpdev/str_list.c
src/xpdev/str_list.h
+10
-1
10 additions, 1 deletion
src/xpdev/str_list.h
with
48 additions
and
8 deletions
src/xpdev/str_list.c
+
38
−
7
View file @
1dbbe232
...
...
@@ -39,7 +39,7 @@
#include
"genwrap.h"
/* stricmp */
#include
"str_list.h"
str_list_t
strList
Alloc
()
str_list_t
strList
Init
()
{
str_list_t
list
;
...
...
@@ -63,7 +63,7 @@ size_t strListCount(const str_list_t list)
return
(
i
);
}
str_list_t
str
L
ist
AddA
t
(
str_list_t
*
list
,
const
char
*
str
,
size_t
count
)
static
str_list_t
str
_l
ist
_add_a
t
(
str_list_t
*
list
,
char
*
str
,
size_t
count
)
{
str_list_t
lp
;
...
...
@@ -71,27 +71,47 @@ str_list_t strListAddAt(str_list_t* list, const char* str, size_t count)
return
(
NULL
);
*
list
=
lp
;
if
((
lp
[
count
]
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
))
==
NULL
)
return
(
NULL
);
strcpy
(
lp
[
count
++
],
str
);
lp
[
count
++
]
=
str
;
lp
[
count
]
=
NULL
;
/* terminate list */
return
(
lp
);
}
str_list_t
strListAddAt
(
str_list_t
*
list
,
const
char
*
str
,
size_t
count
)
{
char
*
buf
;
if
((
buf
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
))
==
NULL
)
return
(
NULL
);
strcpy
(
buf
,
str
);
return
(
str_list_add_at
(
list
,
buf
,
count
));
}
str_list_t
strListAdd
(
str_list_t
*
list
,
const
char
*
str
)
{
return
strListAddAt
(
list
,
str
,
strListCount
(
*
list
));
}
str_list_t
strListAddList
(
str_list_t
*
list
,
str_list_t
add_list
)
{
size_t
i
,
j
;
j
=
strListCount
(
*
list
);
for
(
i
=
0
;
add_list
[
i
];
i
++
)
strListAddAt
(
list
,
add_list
[
i
],
j
++
);
return
(
*
list
);
}
str_list_t
strListSplit
(
str_list_t
*
list
,
char
*
str
,
const
char
*
delimit
)
{
char
*
token
;
if
(
list
==
NULL
)
{
if
((
*
list
=
strList
Alloc
())
==
NULL
)
if
((
*
list
=
strList
Init
())
==
NULL
)
return
(
NULL
);
}
...
...
@@ -117,6 +137,17 @@ str_list_t strListSplitCopy(str_list_t* list, const char* str, const char* delim
return
(
*
list
);
}
str_list_t
strListMerge
(
str_list_t
*
list
,
str_list_t
add_list
)
{
size_t
i
,
j
;
j
=
strListCount
(
*
list
);
for
(
i
=
0
;
add_list
[
i
];
i
++
)
str_list_add_at
(
list
,
add_list
[
i
],
j
++
);
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
−
1
View file @
1dbbe232
...
...
@@ -47,7 +47,7 @@ extern "C" {
typedef
char
**
str_list_t
;
/* Returns an allocated and terminated string list */
str_list_t
strList
Alloc
(
void
);
str_list_t
strList
Init
(
void
);
/* Frees the strings in the list (and the list itself) */
void
strListFree
(
str_list_t
*
list
);
...
...
@@ -59,6 +59,9 @@ 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
,
const
char
*
str
,
size_t
index
);
/* Append a string list onto an another string */
str_list_t
strListAddList
(
str_list_t
*
list
,
str_list_t
append_list
);
/* 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
);
...
...
@@ -66,11 +69,17 @@ 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
);
/* Merge 2 string lists (no copying of string data) */
str_list_t
strListMerge
(
str_list_t
*
list
,
str_list_t
append_list
);
/* Count the number of strings in the list and returns the count */
size_t
strListCount
(
const
str_list_t
list
);
/* Sort the strings in the string list */
void
strListSortAlpha
(
str_list_t
list
);
void
strListSortAlphaReverse
(
str_list_t
list
);
/* Case-sensitive sorting */
void
strListSortAlphaCase
(
str_list_t
list
);
void
strListSortAlphaCaseReverse
(
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