00001 /**************************************************************************** 00002 * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * 00003 * * 00004 * Permission is hereby granted, free of charge, to any person obtaining a * 00005 * copy of this software and associated documentation files (the * 00006 * "Software"), to deal in the Software without restriction, including * 00007 * without limitation the rights to use, copy, modify, merge, publish, * 00008 * distribute, distribute with modifications, sublicense, and/or sell * 00009 * copies of the Software, and to permit persons to whom the Software is * 00010 * furnished to do so, subject to the following conditions: * 00011 * * 00012 * The above copyright notice and this permission notice shall be included * 00013 * in all copies or substantial portions of the Software. * 00014 * * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 00016 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 00018 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 00019 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 00020 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 00021 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 00022 * * 00023 * Except as contained in this notice, the name(s) of the above copyright * 00024 * holders shall not be used in advertising or otherwise to promote the * 00025 * sale, use or other dealings in this Software without prior written * 00026 * authorization. * 00027 ****************************************************************************/ 00028 00029 /**************************************************************************** 00030 * Author: Juergen Pfeifer, 1995,1997 * 00031 ****************************************************************************/ 00032 00033 /*************************************************************************** 00034 * Module form_request_name * 00035 * Routines to handle external names of menu requests * 00036 ***************************************************************************/ 00037 00038 #include "form.priv.h" 00039 00040 MODULE_ID("$Id: frm_req_name.c,v 1.15 2005/04/16 16:59:27 tom Exp $") 00041 00042 static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] = 00043 { 00044 "NEXT_PAGE", 00045 "PREV_PAGE", 00046 "FIRST_PAGE", 00047 "LAST_PAGE", 00048 00049 "NEXT_FIELD", 00050 "PREV_FIELD", 00051 "FIRST_FIELD", 00052 "LAST_FIELD", 00053 "SNEXT_FIELD", 00054 "SPREV_FIELD", 00055 "SFIRST_FIELD", 00056 "SLAST_FIELD", 00057 "LEFT_FIELD", 00058 "RIGHT_FIELD", 00059 "UP_FIELD", 00060 "DOWN_FIELD", 00061 00062 "NEXT_CHAR", 00063 "PREV_CHAR", 00064 "NEXT_LINE", 00065 "PREV_LINE", 00066 "NEXT_WORD", 00067 "PREV_WORD", 00068 "BEG_FIELD", 00069 "END_FIELD", 00070 "BEG_LINE", 00071 "END_LINE", 00072 "LEFT_CHAR", 00073 "RIGHT_CHAR", 00074 "UP_CHAR", 00075 "DOWN_CHAR", 00076 00077 "NEW_LINE", 00078 "INS_CHAR", 00079 "INS_LINE", 00080 "DEL_CHAR", 00081 "DEL_PREV", 00082 "DEL_LINE", 00083 "DEL_WORD", 00084 "CLR_EOL", 00085 "CLR_EOF", 00086 "CLR_FIELD", 00087 "OVL_MODE", 00088 "INS_MODE", 00089 "SCR_FLINE", 00090 "SCR_BLINE", 00091 "SCR_FPAGE", 00092 "SCR_BPAGE", 00093 "SCR_FHPAGE", 00094 "SCR_BHPAGE", 00095 "SCR_FCHAR", 00096 "SCR_BCHAR", 00097 "SCR_HFLINE", 00098 "SCR_HBLINE", 00099 "SCR_HFHALF", 00100 "SCR_HBHALF", 00101 00102 "VALIDATION", 00103 "NEXT_CHOICE", 00104 "PREV_CHOICE" 00105 }; 00106 00107 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0])) 00108 00109 /*--------------------------------------------------------------------------- 00110 | Facility : libnform 00111 | Function : const char * form_request_name (int request); 00112 | 00113 | Description : Get the external name of a form request. 00114 | 00115 | Return Values : Pointer to name - on success 00116 | NULL - on invalid request code 00117 +--------------------------------------------------------------------------*/ 00118 NCURSES_EXPORT(const char *) 00119 form_request_name(int request) 00120 { 00121 T((T_CALLED("form_request_name(%d)"), request)); 00122 00123 if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND)) 00124 { 00125 SET_ERROR(E_BAD_ARGUMENT); 00126 returnCPtr((const char *)0); 00127 } 00128 else 00129 returnCPtr(request_names[request - MIN_FORM_COMMAND]); 00130 } 00131 00132 /*--------------------------------------------------------------------------- 00133 | Facility : libnform 00134 | Function : int form_request_by_name (const char *str); 00135 | 00136 | Description : Search for a request with this name. 00137 | 00138 | Return Values : Request Id - on success 00139 | E_NO_MATCH - request not found 00140 +--------------------------------------------------------------------------*/ 00141 NCURSES_EXPORT(int) 00142 form_request_by_name(const char *str) 00143 { 00144 /* because the table is so small, it doesn't really hurt 00145 to run sequentially through it. 00146 */ 00147 unsigned int i = 0; 00148 char buf[16]; 00149 00150 T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str))); 00151 00152 if (str) 00153 { 00154 strncpy(buf, str, sizeof(buf)); 00155 while ((i < sizeof(buf)) && (buf[i] != '\0')) 00156 { 00157 buf[i] = toupper(buf[i]); 00158 i++; 00159 } 00160 00161 for (i = 0; i < A_SIZE; i++) 00162 { 00163 if (strncmp(request_names[i], buf, sizeof(buf)) == 0) 00164 returnCode(MIN_FORM_COMMAND + (int) i); 00165 } 00166 } 00167 RETURN(E_NO_MATCH); 00168 } 00169 00170 /* frm_req_name.c ends here */