#include <stdio.h> /* FILE, sprintf(), snprintf() */
#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include <stdlib.h> /* free(), atoi() */
-#include <string.h> /* strlen(), strchr(), strcmp(), memcpy() */
+#include <string.h> /* strlen(), strchr() */
#include "../common/readwrite.h" /* try_fopen(), textfile_sizes(), try_fgets(),
* try_fclose(), try_fclose_unlink_rename(),
* try_fwrite()
-extern char * get_command_to_keycode(struct KeyBinding * kb_p, uint16_t key)
+extern struct Command * get_command_to_keycode(struct KeyBinding * kb_p,
+ uint16_t key)
{
while (0 != kb_p)
{
-extern uint16_t get_keycode_to_command(struct KeyBinding * kb_p, char * command)
-{
- while (0 != kb_p)
- {
- if (0 == strcmp(kb_p->command, command))
- {
- return kb_p->key;
- }
- kb_p = kb_p->next;
- }
- return 0;
-}
-
-
-
extern char * get_keyname_to_keycode(uint16_t keycode)
{
char * f_name = "get_name_to_keycode()";
kb_p->next = 0;
kb_p->key = atoi(command);
cmdptr = strchr(command, ' ') + 1;
- kb_p->command = try_malloc(strlen(cmdptr), f_name);
- memcpy(kb_p->command, cmdptr, strlen(cmdptr) - 1);
- kb_p->command[strlen(cmdptr) - 1] = '\0';
+ cmdptr[strlen(cmdptr) - 1] = '\0';
+ kb_p->command = get_command(cmdptr);
loc_last_ptr = & kb_p->next;
}
try_fclose(file, f_name);
struct KeyBinding * kb_p = kbd->kbs;
while (0 != kb_p)
{
- if (strlen(kb_p->command) > linemax)
+ if (strlen(kb_p->command->dsc_short) > linemax)
{
- linemax = strlen(kb_p->command);
+ linemax = strlen(kb_p->command->dsc_short);
}
kb_p = kb_p->next;
}
kb_p = kbd->kbs;
while (0 != kb_p)
{
- snprintf(line, linemax, "%d %s\n", kb_p->key, kb_p->command);
+ snprintf(line, linemax, "%d %s\n", kb_p->key, kb_p->command->dsc_short);
try_fwrite(line, sizeof(char), strlen(line), file, f_name);
kb_p = kb_p->next;
}
{
free_keybindings(kb_p);
}
- free(kb_start->command);
free(kb_start);
}