Changeset afbf668


Ignore:
Timestamp:
Mar 1, 2004, 12:42:56 PM (17 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
948b942
Parents:
c61918e
Message:
	pexec will now incrimentally display data as it is output
	  by the child process.  Additionally, commands running under
	  pexec may now be killed by quitting out of the popless window.
	Added muxevents select loop dispatcher.  File descriptors may
	  be registered with muxevents and handlers will be dispatched
	  to when data is available for non-blocking read/write/except.
	Switched the stderr_redir stuff to use muxevents.
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rc61918e rafbf668  
    11$Id$
    22
     32.1.6pre1
     4        pexec will now incrimentally display data as it is output
     5          by the child process.  Additionally, commands running under
     6          pexec may now be killed by quitting out of the popless window.
     7        Added muxevents select loop dispatcher.  File descriptors may
     8          be registered with muxevents and handlers will be dispatched
     9          to when data is available for non-blocking read/write/except.
     10        Switched the stderr_redir stuff to use muxevents.
     11       
    3122.1.5
    413        Added a licence
  • Makefile.in

    r094009a rafbf668  
    2424     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
    2525     aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c \
    26      zbuddylist.c
     26     zbuddylist.c muxevents.c popexec.c
    2727OWL_SRC = owl.c
    2828TESTER_SRC = tester.c
  • functions.c

    rdebb15d rafbf668  
    22412241  strcat(newbuff, redirect);
    22422242
    2243   p=popen(newbuff, "r");
    2244   out=owl_malloc(1024);
    2245   size=1024;
    2246   strcpy(out, "");
    2247   while (fgets(buff2, 1024, p)!=NULL) {
    2248     size+=1024;
    2249     out=owl_realloc(out, size);
    2250     strcat(out, buff2);
    2251   }
    2252   pclose(p);
    2253 
    2254   if (type==1) {
    2255     owl_function_popless_text(out);
    2256   } else if (type==0) {
    2257     return out;
    2258   } else if (type==2) {
    2259     owl_function_adminmsg(buff, out);
     2243  if (type == 1) {
     2244    owl_popexec_new(newbuff);
    22602245  } else {
    2261     owl_function_popless_text(out);
    2262   }
    2263   owl_free(out);
     2246    p=popen(newbuff, "r");
     2247    out=owl_malloc(1024);
     2248    size=1024;
     2249    strcpy(out, "");
     2250    while (fgets(buff2, 1024, p)!=NULL) {
     2251      size+=1024;
     2252      out=owl_realloc(out, size);
     2253      strcat(out, buff2);
     2254    }
     2255    pclose(p);
     2256   
     2257    if (type==1) {
     2258      owl_function_popless_text(out);
     2259    } else if (type==0) {
     2260      return out;
     2261    } else if (type==2) {
     2262      owl_function_adminmsg(buff, out);
     2263    } else {
     2264      owl_function_popless_text(out);
     2265    }
     2266    owl_free(out);
     2267  }
    22642268  return NULL;
    22652269}
  • global.c

    r5a95b69 rafbf668  
    5050  owl_keys_setup_keymaps(&g->kh);
    5151
     52  owl_list_create(&(g->muxevents));
    5253  owl_list_create(&(g->filterlist));
    5354  owl_list_create(&(g->puntlist));
     
    523524}
    524525
     526/* muxevents */
     527
     528owl_muxevents *owl_global_get_muxevents(owl_global *g) {
     529  return(&(g->muxevents));
     530}
     531
    525532/* filterlist */
    526533
  • owl.c

    r5d365f6 rafbf668  
    5757#endif
    5858int stderr_replace(void);
    59 void stderr_redirect(int rfd);
    6059#endif
    6160
     
    196195  owl_function_debugmsg("startup: doing stderr redirection");
    197196  newstderr = stderr_replace();
     197  owl_muxevents_add(owl_global_get_muxevents(&g), newstderr, OWL_MUX_READ,
     198                    stderr_redirect_handler, NULL);
    198199#endif   
    199200
     
    579580      }
    580581    }
     582
     583    /* dispatch any muxevents */
     584    owl_muxevents_dispatch(owl_global_get_muxevents(&g), 0);
    581585
    582586    /* follow the last message if we're supposed to */
     
    665669    }
    666670
    667 #if OWL_STDERR_REDIR
    668     stderr_redirect(newstderr);
    669 #endif   
    670 
    671671    /* Log any error signals */
    672672    {
     
    675675      if ((signum = owl_global_get_errsignal_and_clear(&g, &si)) > 0) {
    676676        owl_function_error("Got unexpected signal: %d %s  (code: %d band: %d  errno: %d)",
    677                            signum, signum==SIGPIPE?"SIGPIPE":"",
     677                           signum, signum==SIGPIPE?"SIGPIPE":"SIG????",
    678678                           si.si_code, si.si_band, si.si_errno);
    679679      }
     
    690690     */
    691691    owl_function_resize();
    692   } else if (sig==SIGPIPE) {
     692  } else if (sig==SIGPIPE || sig==SIGCHLD) {
    693693    /* Set a flag and some info that we got the sigpipe
    694694     * so we can record that we got it and why... */
     
    732732}
    733733
    734 /* Sends stderr (read from rfd) messages to a file */
    735 void stderr_redirect(int rfd)
     734/* Sends stderr (read from rfd) messages to the error console */
     735void stderr_redirect_handler(int handle, int rfd, int eventmask, void *data)
    736736{
    737737  int navail, bread;
  • owl.h

    rc61918e rafbf668  
    5959static const char owl_h_fileIdent[] = "$Id$";
    6060
    61 #define OWL_VERSION         2.1.5
    62 #define OWL_VERSION_STRING "2.1.5"
     61#define OWL_VERSION         2.1.6pre1
     62#define OWL_VERSION_STRING "2.1.6pre1"
    6363
    6464/* Feature that is being tested to redirect stderr through a pipe.
     
    110110#define OWL_MESSAGE_DIRECTION_IN    1
    111111#define OWL_MESSAGE_DIRECTION_OUT   2
     112
     113#define OWL_MUX_READ   1
     114#define OWL_MUX_WRITE  2
     115#define OWL_MUX_EXCEPT 4
    112116
    113117#define OWL_DIRECTION_NONE      0
     
    352356  int winlines, wincols;
    353357  WINDOW *curswin;
     358  void (*onclose_hook) (struct _owl_viewwin *vwin, void *data);
     359  void *onclose_hook_data;
    354360} owl_viewwin;
    355361 
     
    363369  void (*handler) (int ch);
    364370} owl_popwin;
     371
     372typedef struct _owl_popexec {
     373  int refcount;
     374  owl_viewwin *vwin;
     375  int winactive;
     376  int pid;                      /* or 0 if it has terminated */
     377  int rfd; 
     378} owl_popexec;
    365379
    366380typedef struct _owl_messagelist {
     
    419433} owl_editwin;
    420434
     435typedef struct _owl_mux {
     436  int handle;                   /* for referencing this */
     437  int active;                   /* has this been deleted? */
     438  int fd;                     
     439  int eventmask;                /* bitmask of OWL_MUX_* */
     440  void (*handler_fn)(int handle, int fd, int eventmask, void *data);
     441  void *data;                   /* data reference to pass to callback */
     442} owl_mux;
     443typedef owl_list owl_muxevents;
     444
    421445typedef struct _owl_keybinding {
    422446  int  *j;                      /* keypress stack (0-terminated) */ 
     
    478502  owl_list filterlist;
    479503  owl_list puntlist;
     504  owl_muxevents muxevents;      /* fds to dispatch on */
    480505  owl_vardict vars;
    481506  owl_cmddict cmds;
  • viewwin.c

    rb2b0773 rafbf668  
    1414  if (text) {
    1515    owl_fmtext_append_normal(&(v->fmtext), text);
    16     if (text[strlen(text)-1]!='\n') {
     16    if (text[strlen(text)-1]!='\n' && text[0]!='\0') {
    1717      owl_fmtext_append_normal(&(v->fmtext), "\n");
    1818    }
     
    2424  v->wincols=wincols;
    2525  v->curswin=win;
     26  v->onclose_hook = NULL;
     27}
     28
     29void owl_viewwin_append_text(owl_viewwin *v, char *text) {
     30    owl_fmtext_append_normal(&(v->fmtext), text);
     31    v->textlines=owl_fmtext_num_lines(&(v->fmtext)); 
    2632}
    2733
     
    4551  v->winlines=winlines;
    4652  v->wincols=wincols;
     53}
     54
     55void owl_viewwin_set_onclose_hook(owl_viewwin *v, void (*onclose_hook) (owl_viewwin *vwin, void *data), void *onclose_hook_data) {
     56  v->onclose_hook = onclose_hook;
     57  v->onclose_hook_data = onclose_hook_data;
    4758}
    4859
     
    135146void owl_viewwin_free(owl_viewwin *v)
    136147{
     148  if (v->onclose_hook) {
     149    v->onclose_hook(v, v->onclose_hook_data);
     150  }
    137151  owl_fmtext_free(&(v->fmtext));
    138152}
Note: See TracChangeset for help on using the changeset viewer.