]>
diplodocus.org Git - nmh/blob - sbr/context_find.c
1 /* context_find.c -- find an entry in the context/profile list
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
12 context_find (const char *str
)
16 for (np
= m_defs
; np
; np
= np
->n_next
)
17 if (!strcasecmp (FENDNULL(np
->n_name
), FENDNULL(str
)))
25 * Helper function to search first, if subtype is non-NULL, for
26 * invoname-string-type/subtype and then, if not yet found,
27 * invoname-string-type. If entry is found but is empty, it is
28 * treated as not found.
31 context_find_by_type (const char *string
, const char *type
,
32 const char *subtype
) {
38 cp
= concat (invo_name
, "-", string
, "-", type
, "/", subtype
, NULL
);
39 if ((value
= context_find (cp
)) != NULL
&& *value
== '\0') value
= NULL
;
46 cp
= concat (invo_name
, "-", string
, "-", type
, NULL
);
47 if ((value
= context_find (cp
)) != NULL
&& *value
== '\0') value
= NULL
;
56 * Helper function to search profile an entry with name beginning with prefix.
57 * The search is case insensitive.
60 context_find_prefix (const char *prefix
) {
63 for (np
= m_defs
; np
; np
= np
->n_next
) {
64 if (np
->n_name
&& ! strncasecmp (np
->n_name
, prefix
, strlen(prefix
))) {