1 /*-----------------------------------------------------------------------------+
2 | The ncurses form library is Copyright (C) 1995-1997 |
3 | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
4 | All Rights Reserved. |
6 | Permission to use, copy, modify, and distribute this software and its |
7 | documentation for any purpose and without fee is hereby granted, provided |
8 | that the above copyright notice appear in all copies and that both that |
9 | copyright notice and this permission notice appear in supporting |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the |
12 | software without specific, written prior permission. |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 +-----------------------------------------------------------------------------*/
23 /***************************************************************************
24 * Module form_request_name *
25 * Routines to handle external names of menu requests *
26 ***************************************************************************/
28 #include "form.priv.h"
30 MODULE_ID("$Id: frm_req_name.c,v 1.4 1997/05/01 16:47:54 juergen Exp $")
32 static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
95 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
97 /*---------------------------------------------------------------------------
99 | Function : const char * form_request_name (int request);
101 | Description : Get the external name of a form request.
103 | Return Values : Pointer to name - on success
104 | NULL - on invalid request code
105 +--------------------------------------------------------------------------*/
106 const char *form_request_name( int request )
108 if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
110 SET_ERROR (E_BAD_ARGUMENT);
111 return (const char *)0;
114 return request_names[ request - MIN_FORM_COMMAND ];
118 /*---------------------------------------------------------------------------
119 | Facility : libnform
120 | Function : int form_request_by_name (const char *str);
122 | Description : Search for a request with this name.
124 | Return Values : Request Id - on success
125 | E_NO_MATCH - request not found
126 +--------------------------------------------------------------------------*/
127 int form_request_by_name( const char *str )
129 /* because the table is so small, it doesn't really hurt
130 to run sequentially through it.
137 strncpy(buf,str,sizeof(buf));
138 while( (i<sizeof(buf)) && (buf[i] != '\0') )
140 buf[i] = toupper(buf[i]);
144 for (i=0; i < A_SIZE; i++)
146 if (strncmp(request_names[i],buf,sizeof(buf))==0)
147 return MIN_FORM_COMMAND + i;
153 /* frm_req_name.c ends here */