Exemple #1
0
void 
PingServerCB( XtPointer call_data, XtIntervalId *id )
{

    char *t;
    

    /*
     *  get ping values from the environment...
     */

    if ( pingInterval == 0 ) {
	pingInterval  = ((t = (char *)getenv(PINGINTERVAL)) == NULL ? 0 : atoi(t));
	pingTimeout   = ((t = (char *)getenv(PINGTIMEOUT))  == NULL ? 0 : atoi(t));
    }

    
    /*
     *  ping the server. If successful, set a timer for the next ping,
     *  otherwise cleanup and exit...
     */

    if ( pingInterval != 0 ) {
	if (PingServer())
	    XtAddTimeOut((unsigned long) pingInterval * 60 * 1000, 
	    		  PingServerCB, NULL);
	else
	    exit(NOTIFY_RESTART);
    }
}
Exemple #2
0
static void
lock_timer_init(double timsec, void (*funccall)() )
{
    unsigned long  msec;

    if(lock_timer_id != 0)
    {
	XtRemoveTimeOut(lock_timer_id);
	lock_timer_id = 0;
    }
    lock_timer_func = funccall;
    if(funccall != NULL)
    {
	msec = timsec * 1000;  /* milliseconds */
	lock_timer_id = XtAddTimeOut(msec, lock_timer_proc, NULL);
    }
}
void
print_statusline(STATUS_TIMER timeout, _Xconst char *fmt, ...)
{
    va_list argp;
    char buf[MAX_LEN + 1];
    
    va_start(argp, fmt);

#ifdef STATUSLINE
    if (!XtIsRealized(top_level) || !initialized || !resource.statusline) {
	if (!resource._hush_stdout && strlen(fmt) > 0) {
	    fprintf(stdout, "xdvi: ");
	    (void)vfprintf(stdout, fmt, argp);
	    fprintf(stdout, "\n");
	    fflush(stdout);
	}
    }
    else {
	VSNPRINTF(buf, MAX_LEN, fmt, argp);	/* just trow away strings longer than MAX_LEN */
	/*
	 * save current contents of statusline so that toggling the statusline
	 * on and off will display the same text again
	 */
	Strcpy(g_string_savebuf, buf);
	XtVaSetValues(statusline, XtNlabel, buf, NULL);
	if (timeout > 0) {
	    timeout *= 1000;	/* convert to miliseconds */
	    statusline_timer = XtAddTimeOut(timeout,
					    clear_statusline,
					    (XtPointer) NULL);
	}
    }
#else /* STATUSLINE */
    if (strlen(fmt) > 0 && !resource._hush_stdout) {
	(void)vfprintf(stdout, fmt, argp);
	(void)fprintf(stdout, "\n");
    }
#endif /* STATUSLINE */
    va_end(argp);
}