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
9f47569a
Commit
9f47569a
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added str_list sorting functions.
parent
d8b66f2d
Branches
Branches containing commit
Tags
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
+41
-1
41 additions, 1 deletion
src/xpdev/str_list.c
src/xpdev/str_list.h
+5
-0
5 additions, 0 deletions
src/xpdev/str_list.h
with
46 additions
and
1 deletion
src/xpdev/str_list.c
+
41
−
1
View file @
9f47569a
...
...
@@ -35,7 +35,7 @@
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include
<stdlib.h>
/* malloc */
#include
<stdlib.h>
/* malloc
and qsort
*/
#include
"str_list.h"
str_list_t
strListAlloc
()
...
...
@@ -85,6 +85,46 @@ str_list_t strListAdd(str_list_t* list, char* str)
return
strListAddAt
(
list
,
str
,
strListCount
(
*
list
));
}
static
int
strListCompareAlpha
(
const
void
*
arg1
,
const
void
*
arg2
)
{
return
stricmp
(
*
(
char
**
)
arg1
,
*
(
char
**
)
arg2
);
}
static
int
strListCompareAlphaReverse
(
const
void
*
arg1
,
const
void
*
arg2
)
{
return
stricmp
(
*
(
char
**
)
arg2
,
*
(
char
**
)
arg1
);
}
static
int
strListCompareAlphaCase
(
const
void
*
arg1
,
const
void
*
arg2
)
{
return
strcmp
(
*
(
char
**
)
arg1
,
*
(
char
**
)
arg2
);
}
static
int
strListCompareAlphaCaseReverse
(
const
void
*
arg1
,
const
void
*
arg2
)
{
return
strcmp
(
*
(
char
**
)
arg2
,
*
(
char
**
)
arg1
);
}
void
strListSortAlpha
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlpha
);
}
void
strListSortAlphaReverse
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaReverse
);
}
void
strListSortAlphaCase
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaCase
);
}
void
strListSortAlphaCaseReverse
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaCaseReverse
);
}
void
strListFree
(
str_list_t
*
list
)
{
size_t
i
;
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/str_list.h
+
5
−
0
View file @
9f47569a
...
...
@@ -62,6 +62,11 @@ str_list_t strListAddAt(str_list_t* list, char* str, size_t index);
/* Count the number of strings in the list and returns the count */
size_t
strListCount
(
str_list_t
list
);
void
strListSortAlpha
(
str_list_t
list
);
void
strListSortAlphaReverse
(
str_list_t
list
);
void
strListSortAlphaCase
(
str_list_t
list
);
void
strListSortAlphaCaseReverse
(
str_list_t
list
);
#if defined(__cplusplus)
}
#endif
...
...
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