Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/librecsort/rskeymeth.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1996-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* Glenn Fowler <[email protected]> *
19
* *
20
***********************************************************************/
21
#pragma prototyped
22
23
/*
24
* rskey method by name
25
*/
26
27
#include "rskeyhdr.h"
28
29
static Rsmethod_t** methods[] =
30
{
31
&Rsrasp,
32
&Rsradix,
33
&Rssplay,
34
&Rsverify,
35
&Rscopy,
36
};
37
38
/*
39
* return rs method given name
40
*/
41
42
Rsmethod_t*
43
#if __STD_C
44
rskeymeth(register Rskey_t* kp, const char* name)
45
#else
46
rskeymeth(kp, name)
47
register Rskey_t* kp;
48
char* name;
49
#endif
50
{
51
register int n;
52
53
if (!name || !*name || streq(name, "-") || streq(name, "default"))
54
return Rsrasp;
55
for (n = 0; n < elementsof(methods); n++)
56
if (streq(name, (*methods[n])->name))
57
return *methods[n];
58
return 0;
59
}
60
61
/*
62
* list rs method names on fp
63
*/
64
65
int
66
#if __STD_C
67
rskeylist(register Rskey_t* kp, Sfio_t* fp, int usage)
68
#else
69
rskeylist(kp, fp, usage)
70
register Rskey_t* kp;
71
Sfio_t* fp;
72
int usage;
73
#endif
74
{
75
register int i;
76
register int n;
77
78
n = 0;
79
for (i = 0; i < elementsof(methods); i++)
80
if (usage)
81
n += sfprintf(fp, "[+%s?%s]", (*methods[i])->name, (*methods[i])->desc);
82
else
83
n += sfprintf(fp, "%-10s %s\n", (*methods[i])->name, (*methods[i])->desc);
84
return n;
85
}
86
87