示例#1
0
Channel IvyChannelAdd(IVY_HANDLE fd, void *data,
				ChannelHandleDelete handle_delete,
				ChannelHandleRead handle_read,
		                ChannelHandleWrite handle_write
				)						
{
	Channel channel;

	channel = XtNew( struct _channel );
	if ( !channel )
		{
		fprintf(stderr,"NOK Memory Alloc Error\n");
		exit(0);
		}

	channel->handle_delete = handle_delete;
	channel->handle_read = handle_read;
	channel->handle_write = handle_write;
	channel->data = data;
	channel->fd = fd;

	channel->id_read = XtAppAddInput( app, fd, (XtPointer)XtInputReadMask, IvyXtHandleChannelRead, channel);
	channel->id_delete = XtAppAddInput( app, fd, (XtPointer)XtInputExceptMask, IvyXtHandleChannelDelete, channel);

	return channel;
}
示例#2
0
文件: gsockmot.cpp 项目: EdgarTx/wx
void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket *socket, GSocketEvent event)
{
    int *m_id = (int *)(socket->m_gui_dependent);
    int c;

    if (socket->m_fd == -1)
        return;

    switch (event)
    {
        case GSOCK_LOST:       /* fall-through */
        case GSOCK_INPUT:      c = 0; break;
        case GSOCK_OUTPUT:     c = 1; break;
        case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break;
        default: return;
    }

    if (m_id[c] != -1)
        XtRemoveInput(m_id[c]);

    if (c == 0)
    {
        m_id[0] = XtAppAddInput(wxGetAppContext(), socket->m_fd,
                                (XtPointer *)XtInputReadMask,
                                (XtInputCallbackProc) _GSocket_Motif_Input,
                                (XtPointer) socket);
    }
    else
    {
        m_id[1] = XtAppAddInput(wxGetAppContext(), socket->m_fd,
                                (XtPointer *)XtInputWriteMask,
                                (XtInputCallbackProc) _GSocket_Motif_Output,
                                (XtPointer) socket);
    }
}
示例#3
0
static void
osx_load_image_file_async (Screen *screen, Window xwindow, Drawable drawable,
                           const char *dir,
                           void (*callback) (Screen *, Window, Drawable,
                                             const char *name,
                                             XRectangle *geom,
                                             void *closure),
                       void *closure)
{
  xscreensaver_getimage_data *clo2 =
    (xscreensaver_getimage_data *) calloc (1, sizeof(*clo2));

  clo2->screen = screen;
  clo2->window = xwindow;
  clo2->drawable = drawable;
  clo2->callback = callback;
  clo2->closure = closure;

# ifndef USE_IPHONE   /* Desktop OSX */
  clo2->directory = strdup (dir);
  clo2->pipe = open_image_name_pipe (dir);
  clo2->pipe_id = XtAppAddInput (XtDisplayToApplicationContext (
                            DisplayOfScreen (screen)), 
                            fileno (clo2->pipe),
                            (XtPointer) (XtInputReadMask | XtInputExceptMask),
                            xscreensaver_getimage_file_cb, (XtPointer) clo2);
# else /* USE_IPHONE */
  ios_load_random_image (ios_load_random_image_cb, clo2);
# endif /* USE_IPHONE */
}
示例#4
0
文件: file.c 项目: idunham/dtextra
static FILE *
comp(MGV *m, char *compress, char *filename)
{
	PIPEKID pk;
	char    *argv[4];
	char    *cmd;

	/*
	 * Doing it all by hand is too much bother when the shell already
	 * knows what to do.  Praise the unix approach!
	 */
	cmd = XtCalloc(strlen(compress) + 3 + strlen(filename) + 1, 1);
	sprintf(cmd, "%s > %s", compress, filename);
	argv[0] = "sh";
	argv[1] = "-c";
	argv[2] = cmd;
	argv[3] = NULL;

	memset((void *)&pk, '\0', sizeof(pk));
	pk.flags = PK_IN | PK_ERR;
	if(mgv_popen(&pk, *argv, argv) != 0) {
		XtFree(cmd);
		return NULL;
	}
	XtFree(cmd);

	XtAppAddInput(XtWidgetToApplicationContext(m->main),
					pk.err, (XtPointer)XtInputReadMask,
					comp_err, (XtPointer)m);

	return fdopen(pk.in, "w");
}
示例#5
0
XtEnum XmPrintToFile(Display *pdpy, 
		     char *file_name,
		     XPFinishProc finish_proc, 
		     XPointer client_data)
{
    FileCallbackRec *callback;
    int pid;
    XPContext pcontext ;
    String application_name, application_class, display_name;
    FILE *file;
    int filedes[2];
    
    /* make sure we can open the file for writing */
    if ((file = fopen(file_name, "w")) == NULL) {
      return False;
    }

    if ((pipe(filedes)) == -1) {
      return False;
    }

    /* its important to flush before we fork, to make sure that the
       XpStartJob gets through first in the parent */
    XFlush(pdpy);

    XtGetApplicationNameAndClass(pdpy,
				 &application_name, &application_class);

    display_name = XDisplayString(pdpy) ;
    pcontext = XpGetContext(pdpy) ;
    pid = fork();

    if (pid == 0) {
      ChildPrintToFile(display_name, pcontext, file, file_name, filedes[1],
		       application_name, application_class);
    }
    else if (pid < 0) {
      return False;
    }

    /* we are in the parent */

    fclose(file);
    close(filedes[1]);

    /* allocate the space for a callback */
    callback = (FileCallbackRec *) XtMalloc(sizeof(FileCallbackRec));
    callback->display = pdpy;
    callback->pipe = filedes[0];
    callback->finish_proc = finish_proc;
    callback->client_data = client_data;

    /* notification that the child has completed */
    callback->input_id = 
        XtAppAddInput(XtDisplayToApplicationContext(pdpy), 
		      callback->pipe, (XtPointer)XtInputReadMask,
		      FilePipeCB, callback);

    return True;
}
示例#6
0
    wxEventLoopSource *
    AddSourceForFD(int fd, wxEventLoopSourceHandler* handler, int flags)
    {
        wxCHECK_MSG( wxTheApp, NULL, "Must create wxTheApp first" );

        // The XtInputXXXMask values cannot be combined (hence "Mask" is a
        // complete misnomer), and supporting those would make the code more
        // complicated and we don't need them for now.
        wxCHECK_MSG( !(flags & (wxEVENT_SOURCE_OUTPUT |
                                wxEVENT_SOURCE_EXCEPTION)),
                     NULL,
                     "Monitoring FDs for output/errors not supported" );

        wxCHECK_MSG( flags & wxEVENT_SOURCE_INPUT,
                     NULL,
                     "Should be monitoring for input" );

        XtInputId inputId = XtAppAddInput
                            (
                                 (XtAppContext) wxTheApp->GetAppContext(),
                                 fd,
                                 (XtPointer) XtInputReadMask,
                                 wxMotifInputHandler,
                                 handler
                            );
        if ( inputId < 0 )
            return 0;

        return new wxMotifEventLoopSource(inputId, handler, flags);
    }
示例#7
0
void CFDMonitor::connectFD(int fd, void (*f)(void *), void * data) {

    cbdata * foo = new cbdata(fd,f,data);
    foo->inputID = XtAppAddInput(m_XtAppCtxt, fd,
                  (XtPointer) XtInputReadMask,
                  (XtInputCallbackProc) fdInputHandler,foo);
}
示例#8
0
/*! \reimp
 */
void QXtEventLoop::registerSocketNotifier( TQSocketNotifier *notifier )
{
    XtInputMask mask;
    switch ( notifier->type() ) {
    case TQSocketNotifier::Read:
	mask = XtInputReadMask;
	break;

    case TQSocketNotifier::Write:
	mask = XtInputWriteMask;
	break;

    case TQSocketNotifier::Exception:
	mask = XtInputExceptMask;
	break;

    default:
	tqWarning( "QXtEventLoopEventLoop: socket notifier has invalid type" );
	return;
    }

    XtInputId id = XtAppAddInput( d->appContext,
				  notifier->socket(), (XtPointer) mask,
				  qmotif_socknot_handler, this );
    d->socknotDict.insert( id, notifier );

    TQEventLoop::registerSocketNotifier( notifier );
}
示例#9
0
文件: SmWatch.c 项目: juddy/edcde
void
_XtIceWatchProc (
	IceConn			ice_conn,
	IcePointer		client_data,
	Bool			opening,
	IcePointer		*watch_data)
{
#ifdef DEBUG
    printf ("_XtIceWatchProc\n");
#endif /* DEBUG */

    if (opening)
    {
	XtAppContext appContext = (XtAppContext) client_data;

	*watch_data = (IcePointer) XtAppAddInput (
	    appContext,
	    IceConnectionNumber (ice_conn),
            (XtPointer) XtInputReadMask,
	    _XtProcessIceMsgProc,
	    (XtPointer) ice_conn);
    }
    else
    {
	XtRemoveInput ((XtInputId) *watch_data);
    }
}
示例#10
0
static void
launch_text_generator (state *s)
{
  char *oprogram = get_string_resource (s->dpy, "program", "Program");
  char *program = (char *) malloc (strlen (oprogram) + 10);
  strcpy (program, "( ");
  strcat (program, oprogram);
  strcat (program, " ) 2>&1");

  if (s->debug_p)
    fprintf (stderr, "%s: forking: %s\n", progname, program);

  if ((s->pipe = popen (program, "r")))
    {
      s->pipe_id =
        XtAppAddInput (XtDisplayToApplicationContext (s->dpy), 
                       fileno (s->pipe),
                       (XtPointer) (XtInputReadMask | XtInputExceptMask),
                       subproc_cb, (XtPointer) s);
    }
  else
    {
      char buf[255];
      sprintf (buf, "%.100s: %.100s", progname, program);
      perror (buf);
    }

  free(oprogram);
  free(program);
}
示例#11
0
bool qt_set_socket_handler( int sockfd, int type, TQObject *obj, bool enable )
{
  if ( sockfd < 0 || type < 0 || type > 2 || obj == 0 ) {
#if defined(CHECK_RANGE)
      tqWarning( "TQSocketNotifier: Internal error" );
#endif
      return FALSE;
  }

  XtPointer inpMask = 0;

  switch (type) {
  case TQSocketNotifier::Read:      inpMask = (XtPointer)XtInputReadMask; break;
  case TQSocketNotifier::Write:     inpMask = (XtPointer)XtInputWriteMask; break;
  case TQSocketNotifier::Exception: inpMask = (XtPointer)XtInputExceptMask; break;
  default: return FALSE;
  }

  if (enable) {
      SocketNot *sn = new SocketNot;
      sn->obj = obj;
      sn->fd = sockfd;

      if( _notifiers[type].isEmpty() ) {
          _notifiers[type].insert( 0, sn );
      } else {
          SocketNot *p = _notifiers[type].first();
          while ( p && p->fd > sockfd )
              p = _notifiers[type].next();

#if defined(CHECK_STATE)
          if ( p && p->fd==sockfd ) {
              static const char *t[] = { "read", "write", "exception" };
              tqWarning( "TQSocketNotifier: Multiple socket notifiers for "
                        "same socket %d and type %s", sockfd, t[type] );
          }
#endif
          if ( p )
              _notifiers[type].insert( _notifiers[type].at(), sn );
          else
              _notifiers[type].append( sn );
      }

      sn->id = XtAppAddInput( g_appcon, sockfd, inpMask, socketCallback, sn );

  } else {

      SocketNot *sn = _notifiers[type].first();
      while ( sn && !(sn->obj == obj && sn->fd == sockfd) )
          sn = _notifiers[type].next();
      if ( !sn )				// not found
          return FALSE;

      XtRemoveInput( sn->id );
      _notifiers[type].remove();
  }

  return TRUE;
}
示例#12
0
/**************************************************************************
 This function is called after the client succesfully
 has connected to the server
**************************************************************************/
void add_net_input(int sock)
{
  x_input_id = XtAppAddInput(app_context, sock,
			     (XtPointer) (XtInputReadMask |
					  XtInputExceptMask),
			     (XtInputCallbackProc) get_net_input, NULL);
  client.conn.notify_of_writable_data = set_wait_for_writable_socket;
}
示例#13
0
static void 
Run(SqueakPlugin *plugin)
{
  if (plugin->pid || !plugin->nswindow || !plugin->srcUrl ||plugin->failureUrl)
    return;

  
  plugin->pid= fork();
  
  if (plugin->pid == -1) {
    perror("Squeak fork() failed");
    plugin->pid= 0;
    return;
  }
  DPRINT("NP: fork() -> %i\n", plugin->pid);
  if (plugin->pid == 0) {
    char tmp1[16], tmp2[16];
    plugin->argv[2]= NPN_StrDup(DisplayString(plugin->display));
    sprintf(tmp1, "%i", plugin->pipes[SQUEAK_READ]);
    plugin->argv[4]= NPN_StrDup(tmp1);
    sprintf(tmp2, "%i", plugin->pipes[SQUEAK_WRITE]);
    plugin->argv[5]= NPN_StrDup(tmp2);
    DPRINT("NP(child): Running Squeak VM with arguments\n");
    {
      int i;
      for (i= 1; i<plugin->argc; i++)
	DPRINT("    %s\n", plugin->argv[i]);
    }
    /* this is from the XLib manual ... */
    if ((fcntl(ConnectionNumber(plugin->display), F_SETFD, FD_CLOEXEC)) == -1)
      DPRINT("NP: Cannot disinherit X connection fd\n");
    DPRINT("NP(child): trying %s\n", plugin->vmName);
    execv(plugin->vmName, plugin->argv);
    /* ~/.npsqueak/npsqueakrun could not be executed */
    strcpy(plugin->vmName, SYSTEM_BIN_DIR "/" NPSQUEAKRUN);
    NPN_MemFree(plugin->argv[0]);
    plugin->argv[0]= NPN_StrDup(plugin->vmName);
    DPRINT("NP(child): trying %s\n", plugin->vmName);
    execv(plugin->vmName, plugin->argv);
    /* npsqueakrun could not be executed either */
    fprintf(stderr, "Squeak Plugin: running \"%s\"\n", plugin->vmName);
    perror("Squeak execv() failed");
    _exit(1);
  } else {
    /* establish communication via command pipes */
    XtAppContext app= XtDisplayToApplicationContext(plugin->display);
    plugin->input= XtAppAddInput(app,
				 plugin->pipes[PLUGIN_READ],
				 (XtPointer) XtInputReadMask,
				 (XtInputCallbackProc) InputCallback,
				 plugin);
  
    /* send browser window */
    DPRINT("NP: Sending browser window=0x%X\n", plugin->nswindow);
    SendInt(plugin, plugin->nswindow);
  }
}
示例#14
0
static void ProcessXtEvents()
{
  rfbsockReady = False;
  XtAppAddInput(appContext, rfbsock, (XtPointer)XtInputReadMask,
                rfbsockReadyCallback, NULL);
  while (!rfbsockReady) {
    XtAppProcessEvent(appContext, XtIMAll);
  }
}
示例#15
0
文件: server.c 项目: rtoy/cmucl
void serve_client(int socket)
{
    XEvent event;

    XtToolkitInitialize();
    app_context = XtCreateApplicationContext();

    LispAction.string = "Lisp";
    LispAction.proc   = LispActionProc;
    XtAppAddActions(app_context, &LispAction, 1);

    string_token_tag = find_type_entry(ExtRStringToken);
    string_tag = find_type_entry(XtRString);
    xm_string_tag = find_type_entry(XmRXmString);
    enum_tag = find_type_entry(XtREnum);
    int_tag = find_type_entry(XtRInt);
    window_tag = find_type_entry(XtRWindow);
    boolean_tag = find_type_entry(XtRBoolean);
    widget_tag = find_type_entry(XtRWidget);
    function_tag = find_type_entry(XtRFunction);
    callback_reason_tag = find_type_entry(ExtRCallbackReason);
    event_tag = find_type_entry(ExtREvent);
    resource_list_tag = find_type_entry(ExtRResourceList);
    translation_table_tag = find_type_entry(XtRTranslationTable);
    accelerator_table_tag = find_type_entry(XtRAcceleratorTable);
    atom_tag = find_type_entry(XtRAtom);
    font_list_tag = find_type_entry(XmRFontList);
    string_table_tag = find_type_entry(XtRStringTable);
    xm_string_table_tag = find_type_entry(XmRXmStringTable);
    int_list_tag = find_type_entry(ExtRIntList);
    cursor_tag = find_type_entry(XtRCursor);

    client_socket = socket;
    greet_client(socket);

    XtAppAddInput(app_context, socket, (XtPointer)XtInputReadMask,
                  (XtInputCallbackProc)get_input, (XtPointer)NULL);

    XtAppSetErrorHandler(app_context, MyErrorHandler);
    XtAppSetWarningHandler(app_context, MyWarningHandler);

    /* Here is where we want to return on errors */
    if( setjmp(env) ) {
        printf("Attempting to recover from error.\n");
        fflush(stdout);
    }
    while( !terminate_server ) {
        XtAppNextEvent(app_context, &event);
        XtDispatchEvent(&event);
    }

    close(socket);
    XtDestroyApplicationContext(app_context);

    exit(0);
}
示例#16
0
文件: hello.c 项目: UlricE/SiagOffice
/* ---
*/
void mainloop(void)
{
	XtAppAddInput(XtWidgetToApplicationContext(topLevel),
		fileno(stdin), (XtPointer) XtInputReadMask,
		read_plugin_cmd, NULL);
	printf("220 Hello plugin\n");
	fflush(stdout);

	XtAppMainLoop(XtWidgetToApplicationContext(topLevel));
}
示例#17
0
int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
{
    XtInputId id = XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(),
                                 fd,
                                 (XtPointer *) XtInputReadMask,
                                 (XtInputCallbackProc) xt_notify_end_process,
                                 (XtPointer) proc_data);

    return (int)id;
}
示例#18
0
/********************************************************
 Callback to register file descriptors
********************************************************/
void registerCA(void *dummy, int fd, int opened)
{
	struct FDLIST *cur,*next;
	int found;
#ifdef WIN32
	#define alhInputMask XtInputReadWinsock
#else
	#define alhInputMask XtInputReadMask
#endif

	/* Branch depending on whether the fd is opened or closed */
	if(opened) {
		/* Look for a linked list structure for this fd */
		cur=lastFdInList;
		while(cur) {
			if(cur->fd == fd) {
				errMsg("Tried to add a second callback for file descriptor %d\n",fd);
				return;
			}
			cur=cur->prev;
		}
		/* Allocate and fill a linked list structure for this fd */
		cur=(struct FDLIST *)calloc(1,sizeof(struct FDLIST));
		if(cur == NULL) {
			errMsg("Could not allocate space to keep track of file descriptor %d\n",fd);
			return;
		}
		cur->prev=lastFdInList;
		cur->inpid=XtAppAddInput(appContext,fd,(XtPointer)alhInputMask,
		    alProcessCA,NULL);
		cur->fd=fd;
		lastFdInList=cur;
	} else {
		/* Find the linked list structure for this fd */
		found=0;
		cur=next=lastFdInList;
		while(cur) {
			if(cur->fd == fd) {
				found=1;
				break;
			}
			next=cur;
			cur=cur->prev;
		}
		/* Remove the callback */
		if(found) {
			XtRemoveInput(cur->inpid);
			if(cur == lastFdInList) lastFdInList=cur->prev;
			else next->prev=cur->prev;
			free(cur);
		} else {
			errMsg("Error removing callback for file descriptor %d\n",fd);
		}
	}
}
示例#19
0
void
ws_listen_socket(Socket s)
{ XtInputId id;

  id = XtAppAddInput(pceXtAppContext(NULL),
		     s->rdfd,
		     (XtPointer)(XtInputReadMask),
		     ws_accept, s);

  setXtInputIdStream((Stream) s, id);
}
示例#20
0
文件: xutil.c 项目: astrotycoon/grace
void xregister_rti(Input_buffer *ib)
{
    if (gapp->gui->inwin && ib) {
        /* the screen has been initialized : we can register the buffer */
        ib->id = (unsigned long) XtAppAddInput(app_con,
                                               ib->fd,
                                               (XtPointer) XtInputReadMask,
                                               xmonitor_rti,
                                               (XtPointer) ib);
    }
}
示例#21
0
文件: MwDialog.c 项目: UlricE/Mowitz
void MwStderrRedir(Widget pw)
{
	int fd[2];

	pipe(fd);
	XtAppAddInput(XtWidgetToApplicationContext(pw),
		fd[0], (XtPointer)XtInputReadMask,
		(XtInputCallbackProc)stderr_input, pw);
	dup2(fd[1], 2);
	close(fd[1]);
}
示例#22
0
void
InputMgrX::receive (WantInputReady &msg, void *client_data) {
    InputMgrData *newData = new InputMgrData;
    newData->fMsg = msg;
    newData->fObj = this;
    newData->fId = XtAppAddInput(window_system().app_context(), msg.fChannel, (XtPointer) XtInputReadMask,
                                 (XtInputCallbackProc) InputMgrX::inputHandler,
                                 (XtPointer) newData);
    fWantList.insert (newData);
    request(msg.fReceiver);
}
示例#23
0
int child_start(Widget top, char *cmd, void (*cb)(int) )
{
    int hc = child_init(cmd, 0);
    struct child_stat *child = mls(CLIST, hc);
    child->cb = cb;
    child_exec(hc);
    child->id = XtAppAddInput(XtWidgetToApplicationContext(top),
                              child_read_fd(hc),
                              (XtPointer)  (XtInputReadMask),
                              child_input_cb,(XtPointer) hc );
    return hc;
}
示例#24
0
static void
osx_load_image_file_async (Screen *screen, Window xwindow, Drawable drawable,
                           const char *dir,
                           void (*callback) (Screen *, Window, Drawable,
                                             const char *name,
                                             XRectangle *geom,
                                             void *closure),
                       void *closure)
{
# if 0	/* do it synchronously */

  FILE *pipe = open_image_name_pipe (dir);
  char buf[10240];
  *buf = 0;
  fgets (buf, sizeof(buf)-1, pipe);
  pclose (pipe);

  /* strip trailing newline */
  int L = strlen(buf);
  while (L > 0 && (buf[L-1] == '\r' || buf[L-1] == '\n'))
    buf[--L] = 0;

  XRectangle geom;
  if (! osx_load_image_file (screen, xwindow, drawable, buf, &geom)) {
    /* draw colorbars */
    abort();
  }
  callback (screen, xwindow, drawable, buf, &geom, closure);

# else	/* do it asynchronously */

  struct pipe_closure *clo2 = (struct pipe_closure *) calloc (1, sizeof(*clo2));

  clo2->screen = screen;
  clo2->xwindow = xwindow;
  clo2->drawable = drawable;
  clo2->callback = callback;
  clo2->closure = closure;

#  ifndef USE_IPHONE
  clo2->directory = strdup (dir);
  clo2->pipe = open_image_name_pipe (dir);
  clo2->id = XtAppAddInput (XtDisplayToApplicationContext (
                              DisplayOfScreen (screen)), 
                            fileno (clo2->pipe),
                            (XtPointer) (XtInputReadMask | XtInputExceptMask),
                            pipe_cb, (XtPointer) clo2);
#  else /* USE_IPHONE */
  ios_load_random_image (ios_load_random_image_cb, clo2);
#  endif /* USE_IPHONE */

# endif
}
示例#25
0
static int mcu_open(uint mcuid)
{
    struct mcu_comm *mcu = mcu_ptr(mcuid);
    mcu->fd  = sock_connect_service(mcu->host,mcu->service);
    if( mcu->fd < 0 ) return -1;
    mcu->inp_id = XtAppAddInput( mcu->app,mcu->fd,
                                 (XtPointer)  (XtInputReadMask),
                                 mcu_input_cb,
                                 (XtPointer) (intptr_t) mcuid  );
    mcu->state = OPEN;
    return 0;
}
示例#26
0
文件: sockmot.cpp 项目: beanhome/dev
 virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
 {
     return XtAppAddInput
            (
                 wxGetAppContext(),
                 fd,
                 (XtPointer)(d == OUTPUT ? XtInputWriteMask
                                         : XtInputReadMask),
                 d == OUTPUT ? wxSocket_Motif_Output
                             : wxSocket_Motif_Input,
                 handler
            );
 }
示例#27
0
文件: iluXt.c 项目: spchamp/ilu
static ilu_boolean 
  register_output (int fd,
		   ilu_IOHandler handler,
		   ilu_private rock)
{
  Rock r;
  XtAppContext app = _XtDefaultAppContext();

  DeleteRock (fd, Output);
  r = AddRock (fd, handler, rock, Output);
  r->id = XtAppAddInput (app, fd, (XtPointer)XtInputWriteMask,
			 (XtInputCallbackProc)callback_proc, r);
  return ((r->id != (XtInputId)NULL) ? ilu_TRUE : ilu_FALSE);
}
示例#28
0
int child_startv(Widget top, int cmd_m, void (*cb)(int) )
{
    int l = m_len(cmd_m);
    int i;
    int hc = child_init(STR(cmd_m,0), 0);
    struct child_stat *child = mls(CLIST, hc);
    child->cb = cb;
    for(i=1;i<l;i++) v_kset(child->args, STR(cmd_m, i), -1 );
    child_exec(hc);
    child->id = XtAppAddInput(XtWidgetToApplicationContext(top),
                              child_read_fd(hc),
                              (XtPointer)  (XtInputReadMask),
                              child_input_cb,(XtPointer) hc );
    return hc;
}
示例#29
0
void
ws_input_stream(Stream s)
{ if ( s->rdfd >= 0 )
  { XtInputId id;

    id = XtAppAddInput(pceXtAppContext(NULL),
		       s->rdfd,
		       (XtPointer)(XtInputReadMask),
		       ws_handle_stream_data, s);

    setXtInputIdStream(s, id);

    DEBUG(NAME_stream,
	  Cprintf("Registered %s for asynchronous input\n", pp(s)));
  }
}
示例#30
0
/**************************************************************************
...
**************************************************************************/
static void set_wait_for_writable_socket(struct connection *pc,
					 bool socket_writable)
{
  static bool previous_state = FALSE;

  if (previous_state == socket_writable)
    return;
  freelog(LOG_DEBUG, "set_wait_for_writable_socket(%d)", socket_writable);
  XtRemoveInput(x_input_id);
  x_input_id = XtAppAddInput(app_context, client.conn.sock,
			     (XtPointer) (XtInputReadMask |
					  (socket_writable ?
					   XtInputWriteMask : 0) |
					  XtInputExceptMask),
			     (XtInputCallbackProc) get_net_input, NULL);
  previous_state = socket_writable;
}