Changeset 18fdd5f9


Ignore:
Timestamp:
Oct 27, 2009, 12:41:17 AM (14 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6fc40a7
Parents:
ffc4df6
git-author:
Alejandro R. Sedeño <asedeno@mit.edu> (10/24/09 17:31:48)
git-committer:
Alejandro R. Sedeño <asedeno@mit.edu> (10/27/09 00:41:17)
Message:
Switch C to the new I/O Dispatch API.

Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    r23fddad r18fdd5f9  
    315315}
    316316
    317 void owl_process_input(owl_dispatch *d)
     317void owl_process_input(const owl_io_dispatch *d, void *data)
    318318{
    319319  owl_input j;
     
    444444
    445445/* Sends stderr (read from rfd) messages to the error console */
    446 void stderr_redirect_handler(owl_dispatch *d)
     446void stderr_redirect_handler(const owl_io_dispatch *d, void *data)
    447447{
    448448  int navail, bread;
     
    521521  owl_global_set_haveaim(&g);
    522522
    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);
    532525  owl_zephyr_initialize();
    533526
    534527#if OWL_STDERR_REDIR
    535528  /* 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);
    544531#endif
    545532
  • owl.h

    rdf0138f r18fdd5f9  
    530530  int winactive;
    531531  pid_t pid;                    /* or 0 if it has terminated */
    532   owl_dispatch dispatch;
     532  const owl_io_dispatch *dispatch;
    533533} owl_popexec;
    534534
  • popexec.c

    r0e5afa2 r18fdd5f9  
    5353    pe->pid=pid;
    5454    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);
    6056    pe->refcount++;
    6157  } else {
     
    7874}
    7975
    80 void owl_popexec_inputhandler(owl_dispatch *d)
     76void owl_popexec_inputhandler(const owl_io_dispatch *d, void *data)
    8177{
    82   owl_popexec *pe = d->data;
     78  owl_popexec *pe = data;
    8379  int navail, bread, rv_navail;
    8480  char *buf;
     
    9995  /* the viewwin has closed */
    10096  if (!pe->pid && !pe->winactive) {
    101     owl_select_remove_dispatch(d->fd);
     97    owl_select_remove_io_dispatch(d);
    10298    return;
    10399  }
     
    116112      owl_viewwin_redisplay(pe->vwin, 1);
    117113    }
    118     owl_select_remove_dispatch(d->fd);
     114    owl_select_remove_io_dispatch(d);
    119115    return;
    120116  }
     
    146142}
    147143
    148 void owl_popexec_free_dispatch(owl_dispatch *d)
     144void owl_popexec_delete_dispatch(const owl_io_dispatch *d)
    149145{
    150146  owl_popexec *pe = d->data;
     
    159155
    160156  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);
    163159  }
    164160  if (pe->pid) {
  • zephyr.c

    r12e291a r18fdd5f9  
    3636  ZNotice_t req;
    3737  Code_t code;
    38   owl_dispatch *dispatch;
    3938
    4039  /*
     
    8079  }
    8180
    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
     84void owl_zephyr_finish_initialization(const owl_io_dispatch *d, void *data) {
    9185  Code_t code;
    9286  char *perl;
    9387
    94   owl_select_remove_dispatch(d->fd);
     88  owl_select_remove_io_dispatch(d);
    9589
    9690  ZClosePort();
     
    106100  }
    107101
    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
    113104  owl_global_set_havezephyr(&g);
    114105
     
    13501341}
    13511342
    1352 void owl_zephyr_process_events(owl_dispatch *d)
     1343void owl_zephyr_process_events(const owl_io_dispatch *d, void *data)
    13531344{
    13541345  _owl_zephyr_process_events();
Note: See TracChangeset for help on using the changeset viewer.