1999-08-24 01:06:48 +00:00
|
|
|
/****************************************************************************
|
2020-02-19 16:58:06 +00:00
|
|
|
* Copyright 2020 Thomas E. Dickey *
|
|
|
|
* Copyright 1998-2012,2015 Free Software Foundation, Inc. *
|
1999-08-24 01:06:48 +00:00
|
|
|
* *
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
|
|
|
* copy of this software and associated documentation files (the *
|
|
|
|
* "Software"), to deal in the Software without restriction, including *
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish, *
|
|
|
|
* distribute, distribute with modifications, sublicense, and/or sell *
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is *
|
|
|
|
* furnished to do so, subject to the following conditions: *
|
|
|
|
* *
|
|
|
|
* The above copyright notice and this permission notice shall be included *
|
|
|
|
* in all copies or substantial portions of the Software. *
|
|
|
|
* *
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
|
|
|
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
|
|
* *
|
|
|
|
* Except as contained in this notice, the name(s) of the above copyright *
|
|
|
|
* holders shall not be used in advertising or otherwise to promote the *
|
|
|
|
* sale, use or other dealings in this Software without prior written *
|
|
|
|
* authorization. *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2007-01-20 07:32:02 +00:00
|
|
|
* Author: Juergen Pfeifer, 1995,1997 *
|
1999-08-24 01:06:48 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* Module form_request_name *
|
|
|
|
* Routines to handle external names of menu requests *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "form.priv.h"
|
|
|
|
|
2021-02-25 17:22:00 +00:00
|
|
|
MODULE_ID("$Id: frm_req_name.c,v 1.21 2020/05/24 01:40:20 anonymous.maarten Exp $")
|
2007-01-20 07:32:02 +00:00
|
|
|
|
2020-02-07 08:36:41 +00:00
|
|
|
#define DATA(s) { s }
|
|
|
|
|
|
|
|
static const char request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1][13] =
|
2007-01-20 07:32:02 +00:00
|
|
|
{
|
2020-02-07 08:36:41 +00:00
|
|
|
DATA("NEXT_PAGE"),
|
|
|
|
DATA("PREV_PAGE"),
|
|
|
|
DATA("FIRST_PAGE"),
|
|
|
|
DATA("LAST_PAGE"),
|
2007-01-20 07:32:02 +00:00
|
|
|
|
2020-02-07 08:36:41 +00:00
|
|
|
DATA("NEXT_FIELD"),
|
|
|
|
DATA("PREV_FIELD"),
|
|
|
|
DATA("FIRST_FIELD"),
|
|
|
|
DATA("LAST_FIELD"),
|
|
|
|
DATA("SNEXT_FIELD"),
|
|
|
|
DATA("SPREV_FIELD"),
|
|
|
|
DATA("SFIRST_FIELD"),
|
|
|
|
DATA("SLAST_FIELD"),
|
|
|
|
DATA("LEFT_FIELD"),
|
|
|
|
DATA("RIGHT_FIELD"),
|
|
|
|
DATA("UP_FIELD"),
|
|
|
|
DATA("DOWN_FIELD"),
|
2007-01-20 07:32:02 +00:00
|
|
|
|
2020-02-07 08:36:41 +00:00
|
|
|
DATA("NEXT_CHAR"),
|
|
|
|
DATA("PREV_CHAR"),
|
|
|
|
DATA("NEXT_LINE"),
|
|
|
|
DATA("PREV_LINE"),
|
|
|
|
DATA("NEXT_WORD"),
|
|
|
|
DATA("PREV_WORD"),
|
|
|
|
DATA("BEG_FIELD"),
|
|
|
|
DATA("END_FIELD"),
|
|
|
|
DATA("BEG_LINE"),
|
|
|
|
DATA("END_LINE"),
|
|
|
|
DATA("LEFT_CHAR"),
|
|
|
|
DATA("RIGHT_CHAR"),
|
|
|
|
DATA("UP_CHAR"),
|
|
|
|
DATA("DOWN_CHAR"),
|
2007-01-20 07:32:02 +00:00
|
|
|
|
2020-02-07 08:36:41 +00:00
|
|
|
DATA("NEW_LINE"),
|
|
|
|
DATA("INS_CHAR"),
|
|
|
|
DATA("INS_LINE"),
|
|
|
|
DATA("DEL_CHAR"),
|
|
|
|
DATA("DEL_PREV"),
|
|
|
|
DATA("DEL_LINE"),
|
|
|
|
DATA("DEL_WORD"),
|
|
|
|
DATA("CLR_EOL"),
|
|
|
|
DATA("CLR_EOF"),
|
|
|
|
DATA("CLR_FIELD"),
|
|
|
|
DATA("OVL_MODE"),
|
|
|
|
DATA("INS_MODE"),
|
|
|
|
DATA("SCR_FLINE"),
|
|
|
|
DATA("SCR_BLINE"),
|
|
|
|
DATA("SCR_FPAGE"),
|
|
|
|
DATA("SCR_BPAGE"),
|
|
|
|
DATA("SCR_FHPAGE"),
|
|
|
|
DATA("SCR_BHPAGE"),
|
|
|
|
DATA("SCR_FCHAR"),
|
|
|
|
DATA("SCR_BCHAR"),
|
|
|
|
DATA("SCR_HFLINE"),
|
|
|
|
DATA("SCR_HBLINE"),
|
|
|
|
DATA("SCR_HFHALF"),
|
|
|
|
DATA("SCR_HBHALF"),
|
2007-01-20 07:32:02 +00:00
|
|
|
|
2020-02-07 08:36:41 +00:00
|
|
|
DATA("VALIDATION"),
|
|
|
|
DATA("NEXT_CHOICE"),
|
|
|
|
DATA("PREV_CHOICE")
|
1999-08-24 01:06:48 +00:00
|
|
|
};
|
2007-01-20 07:32:02 +00:00
|
|
|
|
2020-02-07 08:36:41 +00:00
|
|
|
#undef DATA
|
|
|
|
|
1999-08-24 01:06:48 +00:00
|
|
|
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------
|
|
|
|
| Facility : libnform
|
|
|
|
| Function : const char * form_request_name (int request);
|
|
|
|
|
|
|
|
|
| Description : Get the external name of a form request.
|
|
|
|
|
|
|
|
|
| Return Values : Pointer to name - on success
|
|
|
|
| NULL - on invalid request code
|
|
|
|
+--------------------------------------------------------------------------*/
|
2021-02-25 17:22:00 +00:00
|
|
|
FORM_EXPORT(const char *)
|
2007-01-20 07:32:02 +00:00
|
|
|
form_request_name(int request)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2007-01-20 07:32:02 +00:00
|
|
|
T((T_CALLED("form_request_name(%d)"), request));
|
|
|
|
|
|
|
|
if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2007-01-20 07:32:02 +00:00
|
|
|
SET_ERROR(E_BAD_ARGUMENT);
|
|
|
|
returnCPtr((const char *)0);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
else
|
2007-01-20 07:32:02 +00:00
|
|
|
returnCPtr(request_names[request - MIN_FORM_COMMAND]);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------
|
|
|
|
| Facility : libnform
|
|
|
|
| Function : int form_request_by_name (const char *str);
|
|
|
|
|
|
|
|
|
| Description : Search for a request with this name.
|
|
|
|
|
|
|
|
|
| Return Values : Request Id - on success
|
|
|
|
| E_NO_MATCH - request not found
|
|
|
|
+--------------------------------------------------------------------------*/
|
2021-02-25 17:22:00 +00:00
|
|
|
FORM_EXPORT(int)
|
2007-01-20 07:32:02 +00:00
|
|
|
form_request_by_name(const char *str)
|
|
|
|
{
|
1999-08-24 01:06:48 +00:00
|
|
|
/* because the table is so small, it doesn't really hurt
|
|
|
|
to run sequentially through it.
|
2007-01-20 07:32:02 +00:00
|
|
|
*/
|
2014-03-01 00:40:26 +00:00
|
|
|
size_t i = 0;
|
|
|
|
char buf[16]; /* longest name is 10 chars */
|
2007-01-20 07:32:02 +00:00
|
|
|
|
|
|
|
T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
|
|
|
|
|
2014-03-01 00:40:26 +00:00
|
|
|
if (str != 0 && (i = strlen(str)) != 0)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2014-03-01 00:40:26 +00:00
|
|
|
if (i > sizeof(buf) - 2)
|
|
|
|
i = sizeof(buf) - 2;
|
|
|
|
memcpy(buf, str, i);
|
|
|
|
buf[i] = '\0';
|
|
|
|
|
|
|
|
for (i = 0; buf[i] != '\0'; ++i)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2014-02-28 19:18:07 +00:00
|
|
|
buf[i] = (char)toupper(UChar(buf[i]));
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
2007-01-20 07:32:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < A_SIZE; i++)
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
2014-03-01 00:40:26 +00:00
|
|
|
if (strcmp(request_names[i], buf) == 0)
|
2014-02-28 19:18:07 +00:00
|
|
|
returnCode(MIN_FORM_COMMAND + (int)i);
|
2007-01-20 07:32:02 +00:00
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
RETURN(E_NO_MATCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* frm_req_name.c ends here */
|