Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
9f47569a
Commit
9f47569a
authored
May 17, 2004
by
rswindell
Browse files
Added str_list sorting functions.
parent
d8b66f2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
src/xpdev/str_list.c
src/xpdev/str_list.c
+41
-1
src/xpdev/str_list.h
src/xpdev/str_list.h
+5
-0
No files found.
src/xpdev/str_list.c
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
;
...
...
src/xpdev/str_list.h
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment