* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
****************************************************************************/
/****************************************************************************
****************************************************************************/
/****************************************************************************
****************************************************************************/
/***************************************************************************
****************************************************************************/
/***************************************************************************
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
/*---------------------------------------------------------------------------
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
/*---------------------------------------------------------------------------
| Return Values : Pointer to name - on success
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
| Return Values : Pointer to name - on success
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int menu_request_by_name (const char *str);
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int menu_request_by_name (const char *str);
| Return Values : Request Id - on success
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
| Return Values : Request Id - on success
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
- strncpy(buf,str,sizeof(buf));
- while( (i<sizeof(buf)) && (buf[i] != '\0') )
+ if (i > sizeof(buf) - 2)
+ i = sizeof(buf) - 2;
+ memcpy(buf, str, i);
+ buf[i] = '\0';
+
+ for (i = 0; buf[i] != '\0'; ++i)
- if (strncmp(request_names[i],buf,sizeof(buf))==0)
- return MIN_MENU_COMMAND + i;
- }
+ if (strcmp(request_names[i], buf) == 0)
+ returnCode(MIN_MENU_COMMAND + (int)i);
+ }