diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-10-06 23:36:14 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-10-06 23:36:14 +0100 |
commit | e3eca8d51a7d6c0676b973713a1ff043eb0095c7 (patch) | |
tree | 37f12e4734916972ed6e2f851841430102d3cdb2 /termkey.c | |
parent | f5c6ecf9af6a024c1c4a0d486303516a6381ddc7 (diff) | |
download | termo-e3eca8d51a7d6c0676b973713a1ff043eb0095c7.tar.gz termo-e3eca8d51a7d6c0676b973713a1ff043eb0095c7.tar.xz termo-e3eca8d51a7d6c0676b973713a1ff043eb0095c7.zip |
Use vtable in driver to indirect calls to the CSI driver
Diffstat (limited to 'termkey.c')
-rw-r--r-- | termkey.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -8,12 +8,6 @@ #include <stdio.h> -// TODO: Move these into t->driver -void *termkeycsi_new_driver(termkey_t *tk); -void termkeycsi_free_driver(void *private); -termkey_result termkeycsi_getkey(termkey_t *tk, termkey_key *key); -// END TODO - termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime) { termkey_t *tk = malloc(sizeof(*tk)); @@ -65,7 +59,9 @@ termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime) for(i = 0; i < tk->nkeynames; i++) tk->keynames[i] = NULL; - tk->driver_info = termkeycsi_new_driver(tk); + tk->driver = termkey_driver_csi; + + tk->driver_info = (*tk->driver.new_driver)(tk); // Special built-in names termkey_register_keyname(tk, TERMKEY_SYM_NONE, "NONE"); @@ -168,7 +164,7 @@ void termkey_free(termkey_t *tk) free(tk->buffer); tk->buffer = NULL; free(tk->keynames); tk->keynames = NULL; - termkeycsi_free_driver(tk->driver_info); + (*tk->driver.free_driver)(tk->driver_info); tk->driver_info = NULL; /* Be nice to GC'ers, etc */ free(tk); @@ -194,7 +190,7 @@ int termkey_getwaittime(termkey_t *tk) termkey_result termkey_getkey(termkey_t *tk, termkey_key *key) { - return termkeycsi_getkey(tk, key); + return (*tk->driver.getkey)(tk, key); } termkey_result termkey_getkey_force(termkey_t *tk, termkey_key *key) |