mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-15 01:10:52 +08:00
9697f95b8f
This reverts commit 15d999759e
.
35 lines
713 B
C
35 lines
713 B
C
#include "StdAfx.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "name_code.h"
|
|
|
|
/* name_code - look up code by name */
|
|
|
|
int name_code(const NAME_CODE *table, int flags, const char *name)
|
|
{
|
|
const NAME_CODE *np;
|
|
int (*lookup) (const char *, const char *);
|
|
|
|
if (flags & NAME_CODE_FLAG_STRICT_CASE)
|
|
lookup = strcmp;
|
|
else
|
|
lookup = strcasecmp;
|
|
|
|
for (np = table; np->name; np++)
|
|
if (lookup(name, np->name) == 0)
|
|
break;
|
|
return (np->code);
|
|
}
|
|
|
|
/* str_name_code - look up name by code */
|
|
|
|
const char *str_name_code(const NAME_CODE *table, int code)
|
|
{
|
|
const NAME_CODE *np;
|
|
|
|
for (np = table; np->name; np++)
|
|
if (code == np->code)
|
|
break;
|
|
return (np->name);
|
|
}
|