150276Speter/**************************************************************************** 2184989Srafan * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 30166124Srafan * Author: Juergen Pfeifer, 1995,1997 * 3150276Speter ****************************************************************************/ 3250276Speter 3350276Speter/*************************************************************************** 3450276Speter* Module form_request_name * 3550276Speter* Routines to handle external names of menu requests * 3650276Speter***************************************************************************/ 3750276Speter 3850276Speter#include "form.priv.h" 3950276Speter 40184989SrafanMODULE_ID("$Id: frm_req_name.c,v 1.16 2008/07/05 23:22:08 tom Exp $") 4150276Speter 42166124Srafanstatic const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] = 43166124Srafan{ 44166124Srafan "NEXT_PAGE", 45166124Srafan "PREV_PAGE", 46166124Srafan "FIRST_PAGE", 47166124Srafan "LAST_PAGE", 4850276Speter 49166124Srafan "NEXT_FIELD", 50166124Srafan "PREV_FIELD", 51166124Srafan "FIRST_FIELD", 52166124Srafan "LAST_FIELD", 53166124Srafan "SNEXT_FIELD", 54166124Srafan "SPREV_FIELD", 55166124Srafan "SFIRST_FIELD", 56166124Srafan "SLAST_FIELD", 57166124Srafan "LEFT_FIELD", 58166124Srafan "RIGHT_FIELD", 59166124Srafan "UP_FIELD", 60166124Srafan "DOWN_FIELD", 6150276Speter 62166124Srafan "NEXT_CHAR", 63166124Srafan "PREV_CHAR", 64166124Srafan "NEXT_LINE", 65166124Srafan "PREV_LINE", 66166124Srafan "NEXT_WORD", 67166124Srafan "PREV_WORD", 68166124Srafan "BEG_FIELD", 69166124Srafan "END_FIELD", 70166124Srafan "BEG_LINE", 71166124Srafan "END_LINE", 72166124Srafan "LEFT_CHAR", 73166124Srafan "RIGHT_CHAR", 74166124Srafan "UP_CHAR", 75166124Srafan "DOWN_CHAR", 7650276Speter 77166124Srafan "NEW_LINE", 78166124Srafan "INS_CHAR", 79166124Srafan "INS_LINE", 80166124Srafan "DEL_CHAR", 81166124Srafan "DEL_PREV", 82166124Srafan "DEL_LINE", 83166124Srafan "DEL_WORD", 84166124Srafan "CLR_EOL", 85166124Srafan "CLR_EOF", 86166124Srafan "CLR_FIELD", 87166124Srafan "OVL_MODE", 88166124Srafan "INS_MODE", 89166124Srafan "SCR_FLINE", 90166124Srafan "SCR_BLINE", 91166124Srafan "SCR_FPAGE", 92166124Srafan "SCR_BPAGE", 93166124Srafan "SCR_FHPAGE", 94166124Srafan "SCR_BHPAGE", 95166124Srafan "SCR_FCHAR", 96166124Srafan "SCR_BCHAR", 97166124Srafan "SCR_HFLINE", 98166124Srafan "SCR_HBLINE", 99166124Srafan "SCR_HFHALF", 100166124Srafan "SCR_HBHALF", 10150276Speter 102166124Srafan "VALIDATION", 103166124Srafan "NEXT_CHOICE", 104166124Srafan "PREV_CHOICE" 10550276Speter}; 106166124Srafan 10750276Speter#define A_SIZE (sizeof(request_names)/sizeof(request_names[0])) 10850276Speter 10950276Speter/*--------------------------------------------------------------------------- 11050276Speter| Facility : libnform 11150276Speter| Function : const char * form_request_name (int request); 11250276Speter| 11350276Speter| Description : Get the external name of a form request. 11450276Speter| 11550276Speter| Return Values : Pointer to name - on success 11650276Speter| NULL - on invalid request code 11750276Speter+--------------------------------------------------------------------------*/ 11876726SpeterNCURSES_EXPORT(const char *) 119166124Srafanform_request_name(int request) 12050276Speter{ 121166124Srafan T((T_CALLED("form_request_name(%d)"), request)); 122166124Srafan 123166124Srafan if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND)) 12450276Speter { 125166124Srafan SET_ERROR(E_BAD_ARGUMENT); 126166124Srafan returnCPtr((const char *)0); 12750276Speter } 12850276Speter else 129166124Srafan returnCPtr(request_names[request - MIN_FORM_COMMAND]); 13050276Speter} 13150276Speter 13250276Speter/*--------------------------------------------------------------------------- 13350276Speter| Facility : libnform 13450276Speter| Function : int form_request_by_name (const char *str); 13550276Speter| 13650276Speter| Description : Search for a request with this name. 13750276Speter| 13850276Speter| Return Values : Request Id - on success 13950276Speter| E_NO_MATCH - request not found 14050276Speter+--------------------------------------------------------------------------*/ 14176726SpeterNCURSES_EXPORT(int) 142166124Srafanform_request_by_name(const char *str) 143166124Srafan{ 14450276Speter /* because the table is so small, it doesn't really hurt 14550276Speter to run sequentially through it. 146166124Srafan */ 14750276Speter unsigned int i = 0; 14850276Speter char buf[16]; 149166124Srafan 150166124Srafan T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str))); 151166124Srafan 15250276Speter if (str) 15350276Speter { 154166124Srafan strncpy(buf, str, sizeof(buf)); 155166124Srafan while ((i < sizeof(buf)) && (buf[i] != '\0')) 15650276Speter { 157184989Srafan buf[i] = toupper(UChar(buf[i])); 15850276Speter i++; 15950276Speter } 160166124Srafan 161166124Srafan for (i = 0; i < A_SIZE; i++) 16250276Speter { 163166124Srafan if (strncmp(request_names[i], buf, sizeof(buf)) == 0) 164166124Srafan returnCode(MIN_FORM_COMMAND + (int) i); 165166124Srafan } 16650276Speter } 16750276Speter RETURN(E_NO_MATCH); 16850276Speter} 16950276Speter 17050276Speter/* frm_req_name.c ends here */ 171