Ejemplo n.º 1
0
CreateWellKnownSockets ()
{
    struct sockaddr_in	sock_addr;
    char		*name, *localHostname();

    if (request_port == 0)
	    return;
    Debug ("creating socket %d\n", request_port);
    xdmcpFd = socket (AF_INET, SOCK_DGRAM, 0);
    if (xdmcpFd == -1) {
	LogError (ReadCatalog(MC_LOG_SET,MC_LOG_FAIL_SOCK,MC_DEF_LOG_FAIL_SOCK),
		  request_port);
	return;
    }
    name = localHostname ();
    registerHostname (name, strlen (name));
    RegisterCloseOnFork (xdmcpFd);
    /* zero out the entire structure; this avoids 4.4 incompatibilities */
    bzero ((char *) &sock_addr, sizeof (sock_addr));
#ifdef BSD44SOCKETS
    sock_addr.sin_len = sizeof(sock_addr);
#endif
    sock_addr.sin_family = AF_INET;
    sock_addr.sin_port = htons ((short) request_port);
    sock_addr.sin_addr.s_addr = htonl (INADDR_ANY);
    if (bind (xdmcpFd, (struct sockaddr *)&sock_addr, sizeof (sock_addr)) == -1)
    {
	LogError (ReadCatalog(MC_LOG_SET,MC_LOG_ERR_BIND,MC_DEF_LOG_ERR_BIND),
		  request_port, errno);
	close (xdmcpFd);
	xdmcpFd = -1;
	return;
    }
    WellKnownSocketsMax = xdmcpFd;
    FD_SET (xdmcpFd, &WellKnownSocketsMask);

    chooserFd = socket (AF_INET, SOCK_STREAM, 0);
    Debug ("Created chooser socket %d\n", chooserFd);
    if (chooserFd == -1)
    {
	LogError ((unsigned char *)"chooser socket creation failed, errno %d\n", errno);
	return;
    }
    listen (chooserFd, 5);
    if (chooserFd > WellKnownSocketsMax)
	WellKnownSocketsMax = chooserFd;
    FD_SET (chooserFd, &WellKnownSocketsMask);
}
Ejemplo n.º 2
0
Archivo: reset.c Proyecto: juddy/edcde
void 
pseudoReset( Display *dpy )
{
	Window	root;
	int	screen;

	if (setjmp (resetJmp)) {
		LogError(
		  ReadCatalog(MC_LOG_SET,MC_LOG_PSEUDO,MC_DEF_LOG_PSEUDO));
	} else {
		signal (SIGALRM, abortReset);
		alarm (30);
		XSetErrorHandler (ignoreErrors);
		for (screen = 0; screen < ScreenCount (dpy); screen++) {
			Debug ("Pseudo reset screen %d\n", screen);
			root = RootWindow (dpy, screen);
			killWindows (dpy, root);
		}
		Debug ("Before XSync\n");
		XSync (dpy, False);
		(void) alarm (0);
	}
	signal (SIGALRM, SIG_DFL);
	XSetErrorHandler ((int (*)()) 0);
	Debug ("pseudoReset() done\n");
}
Ejemplo n.º 3
0
int 
PingServer( void )
{
    int	    (*oldError)();
    SIGVAL  (*oldSig)();
    int	    oldAlarm;

    oldError = XSetIOErrorHandler ((XIOErrorHandler)PingLost);
    oldAlarm = alarm (0);
    oldSig = signal (SIGALRM, PingBlocked);
    alarm (pingTimeout * 60);
    if (!setjmp (pingTime))
    {
	XSync (dpyinfo.dpy, 0);
    }
    else
    {
	if ( serverDead ) {
	    LogError(ReadCatalog(
                                 MC_LOG_SET,MC_LOG_DEADSRV,MC_DEF_LOG_DEADSRV),
		dpyinfo.name);
	    alarm (0);
	    signal (SIGALRM, SIG_DFL);
	    XSetIOErrorHandler (oldError);
	    return 0;
	}
    }
    alarm (0);
    signal (SIGALRM, oldSig);
    alarm (oldAlarm);
    XSetIOErrorHandler (oldError);
    return 1;
}
Ejemplo n.º 4
0
void
InitErrorLog( void )
{
	int	i;

	static	char tz[32];
	
	
	/*
	 *  add TimeZone to our environment so error message time stamps
	 *  have the correct value...
	 */
	 
	if (timeZone != NULL && strlen(timeZone) < 29) {
	    strcpy(tz,"TZ=");
	    strcat(tz,timeZone);
	    putenv(tz);
	}


	if (errorLogFile && errorLogFile[0]) {
		i = creat (errorLogFile, 0666);
		if (i != -1) {
			if (i != 2) {
				dup2 (i, 2);
				close (i);
			}
		} else
			LogError(ReadCatalog(
			  MC_LOG_SET,MC_LOG_NO_ERRLOG,MC_DEF_LOG_NO_ERRLOG),
			  errorLogFile);
	}
}
Ejemplo n.º 5
0
/****************************************************************************
 *
 * CheckErrorFile
 *
 * Just a quick check to verify that we can open an error log.
 * Do this before we do BecomeDeamon.
 *
 ****************************************************************************/
void
CheckErrorFile( void )
{
        int     i;

        if (errorLogFile && errorLogFile[0]) {
                i = creat (errorLogFile, 0666);
                if (i != -1) {
                	close (i);
                } else {
                	fprintf(stderr, (char *)ReadCatalog(
                              MC_LOG_SET,MC_LOG_NO_ERRLOG,MC_DEF_LOG_NO_ERRLOG),
                              errorLogFile);
		}
        } else {
		fprintf(stderr, (char *)ReadCatalog(
                        MC_LOG_SET,MC_LOG_NO_ERRLOG,MC_DEF_LOG_NO_ERRLOG),
			"\"\"");
	}
}
Ejemplo n.º 6
0
void PoeditListCtrl::CatalogChanged(Catalog* catalog)
{
    wxWindowUpdateLocker no_updates(this);

    // this is to prevent crashes (wxMac at least) when shortening virtual
    // listctrl when its scrolled to the bottom:
    m_catalog = NULL;
    SetItemCount(0);

    // now read the new catalog:
    m_catalog = catalog;
    ReadCatalog();
}
Ejemplo n.º 7
0
int Language::ReadCatalog( const char *catalog ) {
  File file( catalog );
  int rc = -1;

  if ( file.Open( "rb" ) &&
       (file.Read32() == FID_CATALOG) &&
       (file.Read8() == CF_CATALOG_VERSION) ) {
    unsigned char len = file.Read8();
    name = file.ReadS( len );

    rc = ReadCatalog( file );
  }
  return rc;
}
Ejemplo n.º 8
0
void 
LogOutOfMem( unsigned char *fmt, ...)
{
    va_list  args;

    Va_start(args,fmt);

    if ( SyncErrorFile(1) ) {
	fprintf(stderr,(char *)ReadCatalog(MC_ERROR_SET,MC_NO_MEMORY,MC_DEF_NO_MEMORY));
	vfprintf (stderr, (char *)fmt, args);
	fflush (stderr);
    }

    va_end(args);
}
Ejemplo n.º 9
0
Archivo: apollo.c Proyecto: juddy/edcde
int
DoLogin( char *user, char *passwd, char *host )
{
	ios_$id_t		logid;
	login_$opt_set_t	opts;
		status_$t		status;
        error_$string_t         subsystem, module, error;
        short                   sslen, modlen, errlen;
	char			buf[BUFSIZ];
      
	Debug("DoLogin(): for %s\n", user);
	login_$set_host(host, strlen(host));

	opts = login_$no_prompt_name_sm | 
	       login_$no_prompt_pass_sm | 
	       login_$addut_sm		|
	       login_$chown_tty_sm;

	Debug("DoLogin(): before calling login_$chk_login()\n");
	if ((!login_$chk_login(opts, STRING(user), STRING(passwd),
	                       (login_$open_log_p) NULL, STRING(""),
			       &logid, &status)) 
	    && (status.all != status_$ok)) {

	    Debug("DoLogin(): login_$chk_login() failed\n");
       	    error_$get_text(status, subsystem, &sslen, module, &modlen, 
	    		    error, &errlen);
            STRNULL(error, errlen);
	    STRNULL(module, modlen);
       	    STRNULL(subsystem, sslen);
            sprintf(buf,ReadCatalog(MC_LOG_SET,MC_LOG_DOMAIN,MC_DEF_LOG_DOMAIN),
		error, subsystem, module);
	    LogError (buf);

	    bzero (passwd, strlen(passwd)); 

	    return (false);
	}

	Debug("DoLogin(): login_$chk_login() succeeded\n");

	/* 
	 * clear password...
	 */
	bzero (passwd, strlen(passwd)); 

	return (true);
}     
Ejemplo n.º 10
0
void PoeditListCtrl::CatalogChanged(Catalog* catalog)
{
    wxWindowUpdateLocker no_updates(this);

    const bool isSameCatalog = (catalog == m_catalog);

    // this is to prevent crashes (wxMac at least) when shortening virtual
    // listctrl when its scrolled to the bottom:
    m_catalog = nullptr;
    SetItemCount(0);

    std::vector<int> selection;
    if (isSameCatalog)
        selection = GetSelectedCatalogItems();

    // now read the new catalog:
    m_catalog = catalog;
    ReadCatalog();

    if (isSameCatalog && !selection.empty())
        SetSelectedCatalogItems(selection);
}
Ejemplo n.º 11
0
void PoeditListCtrl::CatalogChanged(const CatalogPtr& catalog)
{
    wxWindowUpdateLocker no_updates(this);

    const bool isSameCatalog = (catalog == m_catalog);
    const bool sizeChanged = (catalog && (int)catalog->GetCount() != GetItemCount());

    SelectionPreserver preserve(isSameCatalog ? this : nullptr);

    // this is to prevent crashes (wxMac at least) when shortening virtual
    // listctrl when its scrolled to the bottom:
    if (sizeChanged)
    {
        m_catalog.reset();
        SetItemCount(0);
    }

    // now read the new catalog:
    m_catalog = catalog;
    CreateColumns();
    ReadCatalog(/*resetSizeAndSelection=*/sizeChanged);
}
Ejemplo n.º 12
0
void 
MakeDialog( DialogType dtype )
{
    register int i, j;

    int		width;
    
    FILE	*fp, *fopen();
    char	buffer[128];
    char	*str;

    Widget	w, text;
    Dimension	txt_width, txt_height;
    XmString	ok, cancel, nw, sv;

    Widget      tlev;

    /*
     *  do things common to all dialogs...
     */

    ok     = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
    cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);

    i = InitArg(MessageBox);
    XtSetArg(argt[i], XmNmarginHeight,		MBOX_MARGIN_HEIGHT	); i++;
    XtSetArg(argt[i], XmNmarginWidth,		MBOX_MARGIN_WIDTH	); i++;
    XtSetArg(argt[i], XmNshadowThickness,	SHADOW_THICKNESS	); i++;
    XtSetArg(argt[i], XmNokLabelString,		ok			); i++;
    XtSetArg(argt[i], XmNcancelLabelString,	cancel			); i++;
    XtSetArg(argt[i], XmNnoResize,		False			); i++;
    XtSetArg(argt[i], XmNresizePolicy,		XmRESIZE_ANY		); i++;

    /*
     *  create the various dialogs...
     */

    /* JET - check the matte widget, and if non-null, well use that as
     * the parent for dialogs.  Otherwise use table (the original
     * toplevel widget for this func).  This is useful for Xinerama so
     * that child dialogs are centered on the matte, and not the whole
     * SLS screen.
     */
    if (matte != (Widget)NULL)
      tlev = matte;
    else
      tlev = table;


    switch (dtype) {

    case error:
	xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateErrorDialog(tlev, "error_message", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	error_message = w;
	break;


    case help:
	xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;
	w = XmCreateInformationDialog(tlev, "help_message", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

        txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_width = (txt_width > 850) ? 800 : txt_width - 50;
        txt_height = (txt_height > 900) ? 750 : txt_height - 150;
        i = InitArg(Text);
        XtSetArg(argt[i], XmNheight, txt_height); i++;
        XtSetArg(argt[i], XmNwidth, txt_width); i++;
        XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
        XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
        XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
        XtSetArg(argt[i], XmNeditable, False); i++;
	str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
        XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
        text = XmCreateScrolledText(w, "help_message_text", argt, i);

        XtManageChild(text);
        XtManageChild(w);
        help_message = w;
	break;


    case copyright:
	if ((fp = fopen(COPYRIGHT,"r")) == NULL)
#if defined( __hp_osf )
	    xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
				XmFONTLIST_DEFAULT_TAG);
#else
	    xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
				XmFONTLIST_DEFAULT_TAG);
#endif
	else {
	    xmstr = (XmString) NULL;
	
	    while (fgets(buffer, 128, fp) != NULL) {
		j = strlen(buffer);
		if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
	    
		if ( xmstr != NULL )
		    xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());

		xmstr = XmStringConcat(xmstr,
	    			       XmStringCreate(buffer,
				       XmFONTLIST_DEFAULT_TAG));
	    }	    
	}

	fclose(fp);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
	
	XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);    

	copyright_msg = w;
	break;
    

    case hostname:
	    
	nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL,  MC_DEF_NW_LABEL);
	sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);

	xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;
	XtSetArg(argt[i], XmNokLabelString,		nw		); i++;
	XtSetArg(argt[i], XmNcancelLabelString,		sv		); i++;

	w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);

	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	XmStringFree(nw);
	XmStringFree(sv);

	hostname_message = w;
	break;


    case expassword:

	xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED, 
			    MC_DEF_PASSWD_EXPIRED);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);

	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	passwd_message = w;
	break;


    case help_chooser:
	xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);

	w = XmCreateInformationDialog(tlev, "help_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

        txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_width = (txt_width > 850) ? 800 : txt_width - 50;
        txt_height = (txt_height > 900) ? 750 : txt_height - 150;
        i = InitArg(Text);
        XtSetArg(argt[i], XmNheight, txt_height); i++;
        XtSetArg(argt[i], XmNwidth, txt_width); i++;
        XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
        XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
        XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
        XtSetArg(argt[i], XmNeditable, False); i++;
        str = (char*)
	      ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
        XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
        text = XmCreateScrolledText(w, "help_message_text", argt, i);

        XtManageChild(text);
        XtManageChild(w);
        help_message = w;
        break;
    }
Ejemplo n.º 13
0
void 
MenuItemCB( Widget w, XtPointer client_data, XtPointer call_data )
{
	int i;
    	char     *logoFile;
    	char     *logoName;
	char 	*temp_p;
	char 	temp[MAXPATHLEN];

#ifdef VG_TRACE
    vg_TRACE_EXECUTION("main:  entered MenuItemCB ...");
#endif /* VG_TRACE */

    session_selected = True;

    switch ( (int) client_data) {

    case OB_RESTART_SERVER:
	CleanupAndExit(NULL, NOTIFY_RESTART);
	break;

    case OB_NO_WINDOWS:
	CleanupAndExit(NULL, NOTIFY_NO_WINDOWS);
	break;

    case OB_COPYRIGHT:
	_DtShowDialog(copyright, NULL);
	break;

    case OB_ALT_DTS:
    case OB_FAILSAFE:
    case OB_DTLITE:
    case OB_DT: 
    case OB_LAST_DT:
	/*
	 * set the label on the dt_label widget..
	 */ 

	if(w != options_last_dt) {
          XtSetArg(argt[0], XmNlabelString, &xmstr);
          XtGetValues(w, argt, 1);

          XtSetArg(argt[0], XmNlabelString, xmstr);
          XtSetValues(dt_label, argt, 1);
	}
	else
	  ClearDtlabel();

        i = 0;
        XtSetArg(argt[i], XmNuserData,          &logoFile          ); i++;
        XtGetValues(w, argt, i);

        /* 
	 * remove trailing spaces 
	 */
	if(strchr(logoFile,' '))
            temp_p = strtok(logoFile," ");	
	else
	    temp_p = logoFile;
 
        logoName = _DtGetIconFileName(DefaultScreenOfDisplay(dpyinfo.dpy),
                          temp_p, NULL, NULL, 0);
 
        if (logoName == NULL) {
           LogError( 
	     ReadCatalog(MC_LOG_SET,MC_LOG_NO_LOGOBIT,MC_DEF_LOG_NO_LOGOBIT),
                             logoFile);
           logoFile = NULL;
        }
        i = 0;
        XtSetArg(argt[i], XmNimageName, logoName); i++;
        XtSetValues(logo_pixmap, argt, i);

	/*
	 *  Clear Dt toggles...
	 */
	ClearDtButtons();

	/* 
	 * set the selected toggle button...
	 */
        XtSetArg(argt[0], XmNset, True);
        XtSetValues(w, argt, 1);

        SetDefaultDt(w);

	/*
	 *  return focus to name/password widgets...
	 */
	 
	if ( focusWidget != NULL)
	    ProcessTraversal(focusWidget, XmTRAVERSE_CURRENT);

	break;
    }

}
Ejemplo n.º 14
0
/***************************************************************************
 *
 *  SetDtLabelAndIcon
 *
 *  label to display in the dt_label widget and 
 *  the logo to display in logo_pixmap 
 **************************************************************************/
void
SetDtLabelAndIcon()
{
  static XmString	blanks = NULL;
  int			i;
  char           	*logoFile;
  char           	*logoName;
  char 			*temp_p;
   
#ifdef VG_TRACE
  vg_TRACE_EXECUTION("main:  entered SetDtLabelAndIcon ...");
#endif /* VG_TRACE */

  if (NULL == blanks)
    blanks = XmStringCreateLocalized("       ");

  /*
   *  if user is logging in, set dt_label desired. No more than
   *  one desktop  can be selected at a time ...
   */
  i = 0;
  XtSetArg(argt[0], XmNset, FALSE); i++;
 
  XtSetValues(options_failsafe, argt, i);
  XtSetValues(options_dtlite, argt, i);
  XtSetValues(options_dt, argt, i);
  if (options_last_dt != NULL)
    XtSetValues(options_last_dt, argt, i);
 
  for(i = 0; i<appInfo.altDts ; ++i)
    if(alt_dts[i] != NULL)
      XtSetValues(alt_dts[i], argt, i);

  if (NULL != default_dt) {
      i = 0;
      XtSetArg(argt[i], XmNset, True); i++;
      XtSetValues(default_dt, argt, i);

      if(default_dt == options_last_dt)
        xmstr = blanks;
      else
      {
         i = 0;
         XtSetArg(argt[i], XmNlabelString, &xmstr); i++;
         XtGetValues(default_dt, argt, i);  
      }
      
      i = 0;
      XtSetArg(argt[i], XmNuserData, &logoFile); i++;
      XtGetValues(default_dt, argt, i);
  }
  else {
      xmstr = blanks;
      logoFile = logoInfo.bitmapFile;
  }

#ifdef FIX_FOR_DEFECT_CDExc19307
  /*
   *  This code causes the Session toggle buttons to be reset
   *  to the default setting when the user commits a typing error.
   *  NOT very user friendly.
   *
   *  As for setting the defaults after the user is done entering
   *  the we could do the same thing by passing in an argument.  For
   *  now, I'm not convinced that it is required.
   */

  /*
   * to set the defaults  after the user is done			 
   * entering the login .. 
   */
   if (strcmp(userName,"\0") != 0)
     strcpy(userName,"\0");  
#endif

  i = 0;
  XtSetArg(argt[i], XmNlabelString, xmstr); i++;
  XtSetValues(dt_label, argt, i); 

  /* 
   * remove trailing spaces 
   */
  if(strchr(logoFile,' '))
     temp_p = strtok(logoFile," ");
  else
     temp_p = logoFile;
 
  logoName = _DtGetIconFileName(
			DefaultScreenOfDisplay(dpyinfo.dpy),
                        temp_p, NULL, NULL, 0);
 
  if (logoName == NULL) {
        LogError(
	ReadCatalog(MC_LOG_SET,MC_LOG_NO_LOGOBIT,MC_DEF_LOG_NO_LOGOBIT),
                             logoFile);
        logoFile = NULL;
  }

  i = 0;
  XtSetArg(argt[i], XmNimageName, logoName); i++;
  XtSetValues(logo_pixmap, argt, i);
}
Ejemplo n.º 15
0
void
TrimErrorFile( void )
{

    int  f1, f2;
    int  deleteBytes;
    
    char buf[BUFSIZ];
    char *p;
    int  n;

    off_t status;
    struct stat	statb;


    /*
     *  convert user-specified units of 1Kb to bytes...
     *  put an upper cap of 200Kb on the file...
     */

    if (errorLogSize < 1024) errorLogSize *= 1024;
         
    if (errorLogSize > (200*1024) ) {
	errorLogSize = 200*1024;
	LogError(ReadCatalog(
		MC_LOG_SET,MC_LOG_MAX_LOGFILE,MC_DEF_LOG_MAX_LOGFILE));
    }
	    
    if ( errorLogFile && errorLogFile[0]  && 
        (stat(errorLogFile, &statb) == 0) && 
	(statb.st_size > errorLogSize)		 ) {
    
	deleteBytes = (statb.st_size - errorLogSize) + (errorLogSize / 4);

	Debug("TrimErrorLog(): discarding oldest %d bytes from logfile %s\n",
	         deleteBytes, errorLogFile);


	/*
	 *  get two pointers to the file...
	 */
	 
	if ( (f1 = open(errorLogFile, O_RDWR)) < 0 ||
	     (f2 = open(errorLogFile, O_RDWR)) < 0    ) {
	    Debug("TrimErrorLog(): Cannot open file %s, error number = %d\n",
	    	   errorLogFile, errno);
	    return;
	}
	    		    

	/*
	 *  position read pointer to the first full line after the trim
	 *  point...
	 */
	 	 
	if ( (status = lseek(f2, deleteBytes, SEEK_SET)) < 0 ) {
	    Debug("TrimErrorLog(): Cannot lseek() in file %s, error number = %d\n",
	    	   errorLogFile, errno);
	    return;
	}

	n = read(f2, buf, BUFSIZ);

	if ( (p = strchr(buf,'\n')) != NULL ) {
	    p++; 
	    n -= p - buf;
	    deleteBytes += p - buf;
	}	    
	else {
	    p = buf;
	}
	

	/*
	 *  shift bytes to be saved to the beginning of the file...
	 */
	 
	write (f1, p, n);
	
	while ( (n = read(f2, buf, BUFSIZ)) > 0 )
	    write(f1, buf, n);

	/*
	 *  truncate file to new length and close file pointers...
	 */
	 
	truncate(errorLogFile, statb.st_size - deleteBytes);
	close(f1);
	close(f2);
    }

}
Ejemplo n.º 16
0
Archivo: vglogo.c Proyecto: juddy/edcde
void 
MakeLogo( void )
{
    register int i;

    char	*logoFile;		/* name of logo bitmap file	   */
    
    Pixmap	logoPixmap;		/* logo pixmap			   */
    char	*logoName;		/* logo name			   */

    int		logoWidth, logoHeight;	/* width, height of logo	   */
    Pixel	fg, bg;			/* foreground, background colors   */

    Pixmap	dsPixmap;		/* drop shadow pixmap		   */
    int		dsWidth, dsHeight;	/* width, height of drop shadow    */

    Pixmap		pixmap;			/* scratch pixmap	   */
    GC		gc;			/* scratch GC		   */
    XGCValues	gcval;			/* GC values		   */
    unsigned int	width, height;		/* width, height of bitmap */
    int		x_hot, y_hot;		/* bitmap hot spot (if any)*/

    
    /*
     *  get the user's logo preferences...
     */
     
    XtGetSubresources(table, &logoInfo, "logo", "Logo",
	logoResources, XtNumber(logoResources), NULL, 0);

    /*
     *  create the logo frame...
     */

    i = InitArg(Frame);
	XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
    XtSetArg(argt[i], XmNshadowThickness, 2); i++; 
    XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
    XtSetArg(argt[i], XmNtopOffset, 15); i++;
    XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
    XtSetArg(argt[i], XmNbottomOffset, 15); i++;
	XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
	XtSetArg(argt[i], XmNrightOffset, 15); i++;
    XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
    XtSetArg(argt[i], XmNleftWidget, matteFrame); i++;
    logo1 = XmCreateFrame(matte, "logo", argt, i); 
    XtManageChild(logo1);


    /*
     *  get the colors of the frame...
     */

    XtSetArg(argt[0], XmNforeground, &fg);
    XtSetArg(argt[1], XmNbackground, &bg);
    XtGetValues(logo1, argt, 2);
    

    /*
     *  create the logo pixmap...
     */

    logoFile = logoInfo.bitmapFile;

#if defined (_AIX) && defined (_POWER)
/*
 * On AIX4 we have a Dtlogo.s.pm
 */
# define LOGO_TYPE (LOWRES ? DtSMALL : 0)
#else 
# define LOGO_TYPE 0
#endif
    
    logoName = _DtGetIconFileName(DefaultScreenOfDisplay(dpyinfo.dpy), 
        logoFile, NULL, NULL, LOGO_TYPE);

    if (logoName == NULL)
    {
	LogError(
		ReadCatalog(MC_LOG_SET,MC_LOG_NO_LOGOBIT,MC_DEF_LOG_NO_LOGOBIT),
		logoFile);
	logoFile = NULL;
    }


    /*
     *  create the logo control...
     */

    i = InitArg(LabelG);
    XtSetArg(argt[i], XmNmarginWidth, 0); i++;
    XtSetArg(argt[i], XmNmarginHeight, 0); i++;
    XtSetArg(argt[i], XmNhighlightThickness, 0); i++;
    XtSetArg(argt[i], XmNbehavior, XmICON_LABEL); i++;
    XtSetArg(argt[i], XmNfillMode, XmFILL_TRANSPARENT); i++;
    XtSetArg(argt[i], XmNstring, NULL); i++;
    if (logoName != NULL)
    {
        XtSetArg(argt[i], XmNpixmapForeground, fg); i++;
        XtSetArg(argt[i], XmNpixmapBackground, bg); i++;
        XtSetArg(argt[i], XmNimageName, logoName); i++;
    }
    else
    {
        /*
         *  use built-in logo if no logo was not found
         */
     
        logoPixmap = XCreatePixmapFromBitmapData(
                                dpyinfo.dpy,		/* display	   */
                                dpyinfo.root,		/* drawable	   */
                                (char *)dt_logo_bits,	/* data		   */
				dt_logo_width,          /* width	   */
                                dt_logo_height,	        /* height	   */
                                fg,			/* foreground	   */
                                bg,			/* background	   */
                                dpyinfo.depth);		/* depth	   */

        logoWidth  = dt_logo_width;
        logoHeight = dt_logo_height;

        XtSetArg(argt[i], XmNpixmap, logoPixmap); i++;
    }

    	logo_pixmap = _DtCreateIcon(logo1, "logo_pixmap", argt, i);
    	XtManageChild(logo_pixmap);

        XtSetArg(argt[0], XmNheight,  245); /* keeps dialog a consistent height and width */
        XtSetArg(argt[1], XmNwidth,   245);
        XtSetValues(logo1, argt, 2);
}