Changeset 18fdd5f9be6de827a19aceb95d4769058b145869
- Timestamp:
- 10/27/09 00:41:17 (4 weeks ago)
- Author:
- Alejandro R. Sedeño <asedeno@mit.edu>
- git-author:
- Alejandro R. Sedeño <asedeno@mit.edu> / 2009-10-24T17:31:48Z-0400
- Parents:
- ffc4df61a846d99a75783f7d348fb98dd19910aa
- Children:
- 6fc40a789c812bcdaacbe64f88178bb1409d1071
- git-committer:
- Alejandro R. Sedeño <asedeno@mit.edu> / 2009-10-27T00:41:17Z-0400
- Message:
-
Switch C to the new I/O Dispatch API.
Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r23fddad
|
r18fdd5f
|
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | | void owl_process_input(owl_dispatch *d) |
| | 317 | void owl_process_input(const owl_io_dispatch *d, void *data) |
| 318 | 318 | { |
| 319 | 319 | owl_input j; |
| … |
… |
|
| 444 | 444 | |
| 445 | 445 | /* Sends stderr (read from rfd) messages to the error console */ |
| 446 | | void stderr_redirect_handler(owl_dispatch *d) |
| | 446 | void stderr_redirect_handler(const owl_io_dispatch *d, void *data) |
| 447 | 447 | { |
| 448 | 448 | int navail, bread; |
| … |
… |
|
| 521 | 521 | owl_global_set_haveaim(&g); |
| 522 | 522 | |
| 523 | | /* prepare stdin dispatch */ |
| 524 | | { |
| 525 | | owl_dispatch *d = owl_malloc(sizeof(owl_dispatch)); |
| 526 | | d->fd = STDIN; |
| 527 | | d->cfunc = &owl_process_input; |
| 528 | | d->destroy = NULL; |
| 529 | | owl_select_add_dispatch(d); |
| 530 | | } |
| 531 | | |
| | 523 | /* register STDIN dispatch; throw away return, we won't need it */ |
| | 524 | owl_select_add_io_dispatch(STDIN, OWL_IO_READ, &owl_process_input, NULL, NULL); |
| 532 | 525 | owl_zephyr_initialize(); |
| 533 | 526 | |
| 534 | 527 | #if OWL_STDERR_REDIR |
| 535 | 528 | /* Do this only after we've started curses up... */ |
| 536 | | { |
| 537 | | owl_dispatch *d = owl_malloc(sizeof(owl_dispatch)); |
| 538 | | owl_function_debugmsg("startup: doing stderr redirection"); |
| 539 | | d->fd = stderr_replace(); |
| 540 | | d->cfunc = stderr_redirect_handler; |
| 541 | | d->destroy = NULL; |
| 542 | | owl_select_add_dispatch(d); |
| 543 | | } |
| | 529 | owl_function_debugmsg("startup: doing stderr redirection"); |
| | 530 | owl_select_add_io_dispatch(stderr_replace(), OWL_IO_READ, &stderr_redirect_handler, NULL, NULL); |
| 544 | 531 | #endif |
| 545 | 532 | |
-
|
rdf0138f
|
r18fdd5f
|
|
| 530 | 530 | int winactive; |
| 531 | 531 | pid_t pid; /* or 0 if it has terminated */ |
| 532 | | owl_dispatch dispatch; |
| | 532 | const owl_io_dispatch *dispatch; |
| 533 | 533 | } owl_popexec; |
| 534 | 534 | |
-
|
r0e5afa2
|
r18fdd5f
|
|
| 53 | 53 | pe->pid=pid; |
| 54 | 54 | pe->winactive=1; |
| 55 | | pe->dispatch.fd = parent_read_fd; |
| 56 | | pe->dispatch.cfunc = owl_popexec_inputhandler; |
| 57 | | pe->dispatch.destroy = owl_popexec_free_dispatch; |
| 58 | | pe->dispatch.data = pe; |
| 59 | | owl_select_add_dispatch(&pe->dispatch); |
| | 55 | pe->dispatch = owl_select_add_io_dispatch(parent_read_fd, OWL_IO_READ|OWL_IO_EXCEPT, &owl_popexec_inputhandler, &owl_popexec_delete_dispatch, pe); |
| 60 | 56 | pe->refcount++; |
| 61 | 57 | } else { |
| … |
… |
|
| 78 | 74 | } |
| 79 | 75 | |
| 80 | | void owl_popexec_inputhandler(owl_dispatch *d) |
| | 76 | void owl_popexec_inputhandler(const owl_io_dispatch *d, void *data) |
| 81 | 77 | { |
| 82 | | owl_popexec *pe = d->data; |
| | 78 | owl_popexec *pe = data; |
| 83 | 79 | int navail, bread, rv_navail; |
| 84 | 80 | char *buf; |
| … |
… |
|
| 99 | 95 | /* the viewwin has closed */ |
| 100 | 96 | if (!pe->pid && !pe->winactive) { |
| 101 | | owl_select_remove_dispatch(d->fd); |
| | 97 | owl_select_remove_io_dispatch(d); |
| 102 | 98 | return; |
| 103 | 99 | } |
| … |
… |
|
| 116 | 112 | owl_viewwin_redisplay(pe->vwin, 1); |
| 117 | 113 | } |
| 118 | | owl_select_remove_dispatch(d->fd); |
| | 114 | owl_select_remove_io_dispatch(d); |
| 119 | 115 | return; |
| 120 | 116 | } |
| … |
… |
|
| 146 | 142 | } |
| 147 | 143 | |
| 148 | | void owl_popexec_free_dispatch(owl_dispatch *d) |
| | 144 | void owl_popexec_delete_dispatch(const owl_io_dispatch *d) |
| 149 | 145 | { |
| 150 | 146 | owl_popexec *pe = d->data; |
| … |
… |
|
| 159 | 155 | |
| 160 | 156 | pe->winactive = 0; |
| 161 | | if (pe->dispatch.fd>0) { |
| 162 | | owl_select_remove_dispatch(pe->dispatch.fd); |
| | 157 | if (pe->dispatch->fd > 0) { |
| | 158 | owl_select_remove_io_dispatch(pe->dispatch); |
| 163 | 159 | } |
| 164 | 160 | if (pe->pid) { |
-
|
r12e291a
|
r18fdd5f
|
|
| 36 | 36 | ZNotice_t req; |
| 37 | 37 | Code_t code; |
| 38 | | owl_dispatch *dispatch; |
| 39 | 38 | |
| 40 | 39 | /* |
| … |
… |
|
| 80 | 79 | } |
| 81 | 80 | |
| 82 | | dispatch = owl_malloc(sizeof(*dispatch)); |
| 83 | | dispatch->fd = ZGetFD(); |
| 84 | | dispatch->cfunc = owl_zephyr_finish_initialization; |
| 85 | | dispatch->destroy = (void(*)(owl_dispatch*))owl_free; |
| 86 | | |
| 87 | | owl_select_add_dispatch(dispatch); |
| 88 | | } |
| 89 | | |
| 90 | | void owl_zephyr_finish_initialization(owl_dispatch *d) { |
| | 81 | owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_finish_initialization, NULL, NULL); |
| | 82 | } |
| | 83 | |
| | 84 | void owl_zephyr_finish_initialization(const owl_io_dispatch *d, void *data) { |
| 91 | 85 | Code_t code; |
| 92 | 86 | char *perl; |
| 93 | 87 | |
| 94 | | owl_select_remove_dispatch(d->fd); |
| | 88 | owl_select_remove_io_dispatch(d); |
| 95 | 89 | |
| 96 | 90 | ZClosePort(); |
| … |
… |
|
| 106 | 100 | } |
| 107 | 101 | |
| 108 | | d = owl_malloc(sizeof(owl_dispatch)); |
| 109 | | d->fd = ZGetFD(); |
| 110 | | d->cfunc = &owl_zephyr_process_events; |
| 111 | | d->destroy = NULL; |
| 112 | | owl_select_add_dispatch(d); |
| | 102 | owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_process_events, NULL, NULL); |
| | 103 | |
| 113 | 104 | owl_global_set_havezephyr(&g); |
| 114 | 105 | |
| … |
… |
|
| 1350 | 1341 | } |
| 1351 | 1342 | |
| 1352 | | void owl_zephyr_process_events(owl_dispatch *d) |
| | 1343 | void owl_zephyr_process_events(const owl_io_dispatch *d, void *data) |
| 1353 | 1344 | { |
| 1354 | 1345 | _owl_zephyr_process_events(); |