예제 #1
0
void
DtMailEnv::logError(DtMailBoolean criticalError, const char *format, ...) const
{
  const int MessageBufferSize = 8192;
  char *messageBuffer = new char[MessageBufferSize+1];
  
  if (!_syslog_open) {
    //
    // Open the log device and:
    // LOG_PIG - log the pid number of process.
    // LOG_CONS - log to the console, if the log device can not be opened.
    // LOG_NOWAIT - Do not wait for syslog to finish, avoids the use of SIGCHLD
    //
    openlog("libDtMail", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_MAIL);
  }

  va_list	var_args;

  va_start(var_args, format);
  (void) vsprintf(messageBuffer, format, var_args);
  assert(strlen(messageBuffer) < MessageBufferSize);
  va_end(var_args);

  syslog(criticalError == DTM_TRUE ? LOG_CRIT|LOG_ERR : LOG_ERR,
	 messageBuffer);
  
  _DtSimpleError("libDtMail", criticalError  == DTM_TRUE ? DtError : DtWarning,
		NULL, messageBuffer);
  delete [] messageBuffer;
}
예제 #2
0
파일: Main.c 프로젝트: juddy/edcde
/************************************************************************
 *
 *  ErrorHandler
 *
 ************************************************************************/
static int
ErrorHandler(
        Display *disp,
        XErrorEvent *event )

{
  #define _DTSTYLE_BUFSIZE 1024
  char errmsg[_DTSTYLE_BUFSIZE];

  _DtPrintDefaultErrorSafe(disp, event, errmsg, _DTSTYLE_BUFSIZE);
  _DtSimpleError(progName, DtWarning, NULL, errmsg, NULL);

   /* We do not want to exit here lets try to continue... */
  return 1;
}
예제 #3
0
/************************************************************************
 * restoreMain()
 *
 * restore any state information saved with saveMain.
 * This is called from restoreSession with the application
 * shell and the special xrm database retrieved for restore.
 ************************************************************************/
void 
restoreMain(
        Widget shell,
        XrmDatabase db )
{
    XrmName xrm_name[5];
    XrmRepresentation rep_type;
    XrmValue value;

    xrm_name [0] = XrmStringToQuark ("mainWindow");
    xrm_name [1] = XrmStringToQuark ("ismapped");
    xrm_name [2] = NULL;

    if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) {
      /* Are we supposed to be mapped? */
      if (strcmp(value.addr, "True") == 0) {
        save.poscnt = 0;

        /* get x position */
        xrm_name [1] = XrmStringToQuark ("x");
        if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) {
          XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr));
	  save.poscnt++;
        }

        /* get y position */
        xrm_name [1] = XrmStringToQuark ("y");
        if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) {
          XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr));
	  save.poscnt++;
        }

	save.restoreFlag = True;
        init_mainWindow(shell);
      }
    }
    else
      _DtSimpleError (progName, DtWarning, NULL, ((char *)GETMESSAGE(4,36,
	"No Dtstyle restore information available for current session")), NULL);
}
예제 #4
0
파일: Main.c 프로젝트: juddy/edcde
/*++++++++++++++++++++++++++++++++++++++*/
int 
main(
        int argc,
        char **argv )
{
    int             n;
    Arg             args[MAX_ARGS];
    XEvent          event;
    XPropertyEvent *pEvent=(XPropertyEvent *)&event;
    long            mwmFunc;
    Boolean         useMaskRtn, useIconFileCacheRtn;    
    char           *dirs = NULL;
    char           *string;
	Visual         *visual;

#ifdef USERHELP
malloc_check(1);
malloc_trace(0);
#endif

    XtSetLanguageProc(NULL, NULL, NULL);
    _DtEnvControl(DT_ENV_SET); 
    

    /* Initialize the toolkit and open the display */
    style.shell = 
        XtInitialize(argv[0], XMCLASS, option_list, 1, (int *)&argc, argv);

#ifdef __osf__
    _XmColorObjCreate(style.shell, NULL, NULL);
#endif

    /* Allow all WS manipulation functions except resize and maximize */
    mwmFunc = MWM_FUNC_ALL ^ (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); 

    n = 0;
    XtSetArg(args[n], XmNmwmFunctions, mwmFunc); n++;
    XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
    XtSetValues(style.shell, args, n);

    /* initialize global style data */

    style.display    = XtDisplay(style.shell);
    style.screen     = DefaultScreenOfDisplay(style.display);
    style.screenNum  = DefaultScreen(style.display);
    style.colormap   = DefaultColormap(style.display, style.screenNum);
    style.root       = DefaultRootWindow(style.display);
    style.execName   = argv[0];
    style.errDialog  = NULL;
    style.tmpXmStr   = NULL;
    style.home = (char *) XtMalloc(strlen((char *) getenv("HOME")) + 1);
    strcpy(style.home, (char *) getenv("HOME"));
    style.colorDialog = NULL;
    style.backdropDialog = NULL;
    style.fontDialog = NULL;
    style.kbdDialog = NULL;
    style.mouseDialog = NULL;
    style.audioDialog = NULL;
    style.screenDialog = NULL;
    style.startupDialog = NULL;
    style.dtwmDialog = NULL;
    style.i18nDialog = NULL;
	visual = XDefaultVisual(style.display,style.screenNum);
	style.visualClass = visual->class;
    
    if (progName = DtStrrchr(argv[0], '/')) progName++;
    else progName = argv[0];

    /* Get the lock established to ensure only one dtstyle process
     * is running per screen .. first malloc enough space*/

    if (_DtGetLock (style.display, STYLE_LOCK) == 0)
    {
        _DtSimpleError (progName, DtError, NULL, "%s",
	     ((char *)GETMESSAGE(2, 5, "Style Manager is already running, second attempt aborted.")));
        exit(1);
    }

    InitDtstyleProtocol();
    SetWindowProperties();

    /* Register error handlers */
    XSetErrorHandler(ErrorHandler);
    XSetIOErrorHandler(IOErrorHandler);
    XtAppSetErrorHandler(XtWidgetToApplicationContext(style.shell),
                         ToolkitErrorHandler);
    XtAddEventHandler(style.shell, StructureNotifyMask, 0,
                         (XtEventHandler)MwmReparentNotify, NULL);

    /* set up resolution dependent layout variables */
    switch (_DtGetDisplayResolution(style.display, style.screenNum))
    {
        case LOW_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 3;
            break;
            
        case MED_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 5;
            break;
            
        case HIGH_RES_DISPLAY:
            style.horizontalSpacing = 
            style.verticalSpacing = 8;
            break;
    }
    
    GetApplicationResources();
    
    XmeGetIconControlInfo(style.screen, &useMaskRtn,
			  &style.useMultiColorIcons, &useIconFileCacheRtn);
    
    
    /* add the directory $HOME/.dt/backdrops */
    
    string = (char *)XtMalloc(strlen(style.home) + strlen("/.dt/backdrops:") + 1);
    sprintf(string, "%s/.dt/backdrops:", style.home);

    dirs = (char *)XtCalloc(1, strlen("/etc/dt/backdrops:/usr/dt/backdrops") + 
			    (style.xrdb.backdropDir == NULL ? 2 :
			    strlen(style.xrdb.backdropDir)) + 
			    strlen(string) + 2);
  

    strcpy(dirs, string);
    if (style.xrdb.backdropDir) 
      {
	strcat(dirs, style.xrdb.backdropDir);
	strcat(dirs, ":"); 
      }
    strcat(dirs, "/etc/dt/backdrops:/usr/dt/backdrops");

    _DtWsmSetBackdropSearchPath(style.screen, dirs, style.useMultiColorIcons);

    if (string != NULL)
      XtFree((char *)string);
    
    if (dirs != NULL)
      XtFree((char *)dirs); 
    
    

    style.count = 0;
    /* if this is started from save session we need to set up the BMS
       first, otherwise do it after making the window. (for user perception
       for how long it takes for the dtstyle to come up) */
    if(style.xrdb.session != NULL) {
      DtInitialize (style.display, style.shell, progName, progName);
      /*Restore a session or build and display the main Window.*/
      if(!restoreSession(style.shell,style.xrdb.session))
	init_mainWindow(style.shell);
    }
    else {
      init_mainWindow(style.shell);
      DtInitialize (style.display, style.shell, progName, progName);
      InitializeAtoms();
      CheckMonitor(style.shell);
      GetDefaultPal(style.shell);
    }
    
    signal(SIGINT,(void (*)())activateCB_exitBtn); 
    signal(SIGTERM,(void (*)())activateCB_exitBtn); 

    /* to avoid defunct screen saver processes */    
    signal(SIGCHLD, (void (*)())WaitChildDeath);

    /* backdrop dialog  needs to know when the workspace changes to recolor 
       the bitmap displayed in the dialog */
    ListenForWorkspaceChange();

    /* if using COLOR builtin, style.workProcs is True */

    if ((XmeUseColorObj() != FALSE) && style.workProcs)

        XtAppAddWorkProc(XtWidgetToApplicationContext(style.shell), 
                        NewCreateD, style.shell);

    XtAppMainLoop(XtWidgetToApplicationContext(style.shell));

    return 0;
}
예제 #5
0
/***************************************************************************
 *
 * ReadPaletteFile - this routines reads and parses the palette file.
 *    It fills in the pCurrentPalette structure for the screen_number
 *    that was passed in. 
 *
 *************************************************************************/
static struct _palette * 
ReadPaletteFile(
        Display *dpy,
        int     screen_number,
        char *palettePath,
        char *palette )
{
   struct _palette *new_palette;
   int             fd, nbytes;
   char            buf[BUFSIZE];
   char            tmpPalette[BUFSIZE];
   char            *token1;
   char            *tmpStr2;
   char            *tmpStr;
   char            *fullPath;

   /* 
    * create full path, don't forget to add 1 for the NULL byte
    * and 1 for the slash in the format string for sprintf.
    */
   fullPath = (char *) SRV_MALLOC (strlen(palettePath) + strlen(palette) + 2);
   sprintf(fullPath,"%s/%s", palettePath, palette); 

   if( (fd = open( fullPath, O_RDONLY)) == -1)
   { /* open failed */
        printf("error opening %s\n",fullPath);
        SRV_FREE(fullPath);
        return((struct _palette *) NULL);
   }
      
   /*
   **  Read a buffer of data ... BUFSIZE == 1024, as long as 
   **  screen < MAX_NUM_SCREENS (5) then we should never need more. 
   */
   nbytes = read(fd, buf, BUFSIZE);
   if(nbytes == 0 || nbytes == BUFSIZE)  /* A bogus number of bytes */
   { /* read failed */
       /*
	* Don't forget to add 1 for the NULL byte and 2 for the 
	* period and the newline in the format string for sprintf
	*/
       tmpStr = (char *)SRV_MALLOC(strlen(MSG2) + strlen(fullPath) + 3);
       sprintf(tmpStr,"%s%s.\n", MSG2, palettePath); 
       _DtSimpleError(XmSCOLOR_SRV_NAME, DtWarning, NULL, tmpStr, NULL); 
       SRV_FREE(tmpStr);
       SRV_FREE(fullPath);
       close(fd);
       return((struct _palette *) NULL);
   }
   else 
   { /* read suceeded */
      /* Allocate space for this new palette. */
      new_palette = (palettes *)SRV_MALLOC( sizeof(struct _palette) + 1 );

      /*  allocate enough space for the name */
      strcpy(tmpPalette, palette); 
      for (token1=tmpPalette; *token1; token1++);
      while (token1!=tmpPalette && *token1!='.') token1--;
      if (!strcmp(token1,PALETTE_SUFFIX)) *token1 = '\0';
      new_palette->name = (char *)SRV_MALLOC(strlen(tmpPalette) + 1);
      strcpy(new_palette->name, (char *) tmpPalette);

      new_palette->converted = NULL;
      new_palette->converted_len = 0L;

      /* set the next pointer to NULL*/
      new_palette->next = NULL;

      if (ParsePaletteInfo(dpy, screen_number, buf, nbytes, new_palette) == -1)
      {
        /* palette file is bad */
         tmpStr = (char *)SRV_MALLOC(strlen(MSG3) + strlen(MSG3a) + strlen(palettePath) +1);
         tmpStr2 = (char *)SRV_MALLOC(strlen(MSG3)+1);
         sprintf(tmpStr2,"%s", MSG3); 
         sprintf(tmpStr,"%s%s%s", tmpStr2, palettePath, MSG3a); 
         _DtSimpleError(XmSCOLOR_SRV_NAME, DtWarning, NULL, tmpStr, NULL); 
         SRV_FREE(tmpStr);
         SRV_FREE(tmpStr2);
         error_value = 1;
         unlink(palettePath);
         SRV_FREE(fullPath);
         return((struct _palette *) NULL);
      }
   }

   /* close the file */
   close(fd);
   SRV_FREE(fullPath);

   return(new_palette);
}