| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
#include <stdlib.h> |
#include <stdlib.h> |
| 10 |
|
#include <string.h> |
| 11 |
|
|
| 12 |
struct categories { |
static int category_cmp(const void *, const void *); |
| 13 |
|
|
| 14 |
|
const struct categories { |
| 15 |
const char *catname; |
const char *catname; |
| 16 |
const char *catdesc; |
const char *catdesc; |
| 17 |
} categories[] = { |
} categories[] = { |
| 18 |
|
/* this list MUST be sorted all the time */ |
| 19 |
{ "base", "Base system" }, |
{ "base", "Base system" }, |
| 20 |
{ "shells", "Shells" }, |
{ "comms", "Serial communications & terminal emulation" }, |
|
{ "misc", "Applications" }, |
|
|
{ "net", "Networking" }, |
|
| 21 |
{ "crypto", "Crypto" }, |
{ "crypto", "Crypto" }, |
| 22 |
|
{ "fsutils", "FileSystem related" }, |
| 23 |
{ "ipv6", "IPv6" }, |
{ "ipv6", "IPv6" }, |
| 24 |
{ "libs", "Libraries" }, |
{ "libs", "Libraries" }, |
| 25 |
|
{ "misc", "Applications" }, |
| 26 |
{ "multimedia", "Multimedia" }, |
{ "multimedia", "Multimedia" }, |
| 27 |
{ "comms", "Serial communications & terminal emulation" }, |
{ "net", "Networking" }, |
|
{ "voip", "Telephony" }, |
|
|
{ "sysutils", "Utilities" }, |
|
|
{ "fsutils", "FileSystem related" }, |
|
| 28 |
{ "netbt", "Bluetooth" }, |
{ "netbt", "Bluetooth" }, |
| 29 |
|
{ "shells", "Shells" }, |
| 30 |
|
{ "sysutils", "Utilities" }, |
| 31 |
|
{ "voip", "Telephony" }, |
| 32 |
{ NULL, NULL } |
{ NULL, NULL } |
| 33 |
}; |
}; |
| 34 |
|
|
| 35 |
|
const char * |
| 36 |
|
category(const char *name) |
| 37 |
|
{ |
| 38 |
|
return (name == NULL ? NULL : ((struct categories *)bsearch(name, |
| 39 |
|
categories, (sizeof (categories) / sizeof (categories[0])), |
| 40 |
|
sizeof (struct categories), category_cmp))->catdesc); |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
static int |
| 44 |
|
category_cmp(const void *key, const void *item) |
| 45 |
|
{ |
| 46 |
|
return (strcmp((const char *)key, |
| 47 |
|
((const struct categories *)item)->catname)); |
| 48 |
|
} |