]>
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.
10 #include "context_find.h"
14 context_find (const char *str
)
19 for (np
= m_defs
; np
; np
= np
->n_next
)
20 if (!strcasecmp(FENDNULL(np
->n_name
), str
))
28 * Helper function to search first, if subtype is non-NULL, for
29 * invoname-string-type/subtype and then, if not yet found,
30 * invoname-string-type. If entry is found but is empty, it is
31 * treated as not found.
34 context_find_by_type (const char *string
, const char *type
,
42 cp
= concat (invo_name
, "-", string
, "-", type
, "/", subtype
, NULL
);
43 if ((value
= context_find (cp
)) != NULL
&& *value
== '\0') value
= NULL
;
50 cp
= concat (invo_name
, "-", string
, "-", type
, NULL
);
51 if ((value
= context_find (cp
)) != NULL
&& *value
== '\0') value
= NULL
;
60 * Helper function to search profile an entry with name beginning with prefix.
61 * The search is case insensitive.
64 context_find_prefix (const char *prefix
)
70 for (np
= m_defs
; np
; np
= np
->n_next
) {
71 if (np
->n_name
&& ! strncasecmp (np
->n_name
, prefix
, len
)) {