Ejemplo n.º 1
0
void SqliteMerge::mergeFiles()
{

  // If there is only one file, we are done.
  if (m_files.size() == 1)
  {
    sqlite3 *main_db = openDatabase(m_files[0]);
    createABUPS(main_db);
    closeDatabase(main_db);
    renameFinalDatabase( m_files[0]);
  } else {
    // Otherwise, there are more files..
    sqlite3 *main_db = openDatabase(m_files[0]);

    //summary(main_db);
    //m_primaryKeyBase = sqlite3_last_insert_rowid(main_db);  
    //std::sort(m_files.begin(),m_files.end()); 

    for (size_t i = 1; i < m_files.size(); ++i)
    {
      //m_primaryKeyBase = i*1000;
      //m_primaryKeyBase = sqlite3_last_insert_rowid(main_db);  
      mergeDatabases(main_db,m_files[i]);
    }

    //summary(main_db);

    //printMeterData(main_db);
    //CreateView 
    //CreateView(main_db);  //for testing purposes
    // create ABUPS table in main database 
    //
    begin(main_db); 

    //meaningless is the tabular data now
    dropTabularData(main_db);
    createABUPS(main_db); 
    commit(main_db); 
    closeDatabase(main_db);
    renameFinalDatabase( m_files[0]);
  }
}
Ejemplo n.º 2
0
static void
ingItColors_and_fonts(void)
{
    char property[256];
    char *prop = &property[0];
    char *str_type[50];
    XrmValue value;
    Colormap cmap;
    int ts;

    /** get the color map for the display **/
/*    fprintf(stderr,"initx:ingItColors_and_fonts:entered\n");*/

/*    fprintf(stderr,"initx:ingItColors_and_fonts:DefaultColorMap\n");*/
    cmap = DefaultColormap(gXDisplay, gXScreenNumber);

/*    fprintf(stderr,"initx:ingItColors_and_fonts:init_group_stack\n");*/
    init_group_stack();


    /** then start getting the fonts **/

/*    fprintf(stderr,"initx:ingItColors_and_fonts:mergeDatabases\n");*/
    mergeDatabases();

/*    fprintf(stderr,"initx:ingItColors_and_fonts:XrmGetResource\n");*/
    if (XrmGetResource(rDB, "FriCAS.hyperdoc.RmFont",
                       "FriCAS.hyperdoc.Font", str_type, &value) == True) {
        (void) strncpy(prop, value.addr, (int) value.size);
    } else {
        (void) strcpy(prop, RmFontDefault);
    }

/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 1\n");*/
    load_font(&gRmFont, prop);
/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 2\n");*/
    load_font(&gInputFont, prop);


/*    fprintf(stderr,"initx:ingItColors_and_fonts:XrmGetResource 2\n");*/
    if (XrmGetResource(rDB, "FriCAS.hyperdoc.TtFont",
                       "FriCAS.hyperdoc.Font", str_type, &value) == True) {
        (void) strncpy(prop, value.addr, (int) value.size);
    } else {
        (void) strcpy(prop, TtFontDefault);
    }
/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 3\n");*/
    load_font(&gTtFont, prop);
/*    fprintf(stderr,"initx:ingItColors_and_fonts:is_it_850\n");*/
    gTtFontIs850=is_it_850(gTtFont);

/*    fprintf(stderr,"initx:ingItColors_and_fonts:XrmGetResource 5\n");*/
    if (XrmGetResource(rDB, "FriCAS.hyperdoc.ActiveFont",
                       "FriCAS.hyperdoc.Font", str_type, &value) == True) {
        (void) strncpy(prop, value.addr, (int) value.size);
    } else {
        (void) strcpy(prop, ActiveFontDefault);
    }
/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 4\n");*/
    load_font(&gActiveFont, prop);

    /* maintain backwards compatibility */

/*    fprintf(stderr,"initx:ingItColors_and_fonts:XrmGetResource 6\n");*/
    if (XrmGetResource(rDB, "FriCAS.hyperdoc.FriCASFont",
                       "FriCAS.hyperdoc.Font", str_type, &value) == True) {
        (void) strncpy(prop, value.addr, (int) value.size);
    } else {
        if (XrmGetResource(rDB, "FriCAS.hyperdoc.SpadFont",
                        "FriCAS.hyperdoc.Font", str_type, &value) == True) {
            (void) strncpy(prop, value.addr, (int) value.size);
        } else {
            (void) strcpy(prop, fricas_font_default);
        }
    }

/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 5\n");*/
    load_font(&fricas_font, prop);

/*    fprintf(stderr,"initx:ingItColors_and_fonts:XrmGetResource 7\n");*/
    if (XrmGetResource(rDB, "FriCAS.hyperdoc.EmphasizeFont",
                       "FriCAS.hyperdoc.Font", str_type, &value) == True) {
        (void) strncpy(prop, value.addr, (int) value.size);
    } else {
        (void) strcpy(prop, EmphasizeFontDefault);
    }
/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 6\n");*/
    load_font(&gEmFont, prop);

/*    fprintf(stderr,"initx:ingItColors_and_fonts:XrmGetResource 8\n");*/
    if (XrmGetResource(rDB, "FriCAS.hyperdoc.BoldFont",
                       "FriCAS.hyperdoc.Font", str_type, &value) == True) {
        (void) strncpy(prop, value.addr, (int) value.size);
    } else {
        (void) strcpy(prop, BoldFontDefault);
    }
/*    fprintf(stderr,"initx:ingItColors_and_fonts:load_font 7\n");*/
    load_font(&gBfFont, prop);


    /*
     * If we are on a monochrome screen, then we ignore user preferences, and
     * set the foreground and background as I wish
     */

/*    fprintf(stderr,"initx:ingItColors_and_fonts:DisplayPlanes\n");*/
    if (DisplayPlanes(gXDisplay, gXScreenNumber) == 1) {
        gActiveColor       = fricas_color
                            = gControlBackgroundColor
                            = gInputBackgroundColor
                            = gBfColor
                            = gEmColor
                            = gRmColor
                            = gSlColor
                            = gTtColor
                            = BlackPixel(gXDisplay, gXScreenNumber);

        gBackgroundColor   = gInputForegroundColor
                            = gControlForegroundColor
                            = WhitePixel(gXDisplay, gXScreenNumber);
    }
    else {

        /*
         * If I have gotten here, then we must be on a color screen, so see
         * what the user likes, and set it up
         */

/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 1\n");*/
        gRmColor =
            get_color("RmColor", "Foreground",
                      BlackPixel(gXDisplay, gXScreenNumber), &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 2\n");*/
        gBackgroundColor =
            get_color("Background", "Background",
                      WhitePixel(gXDisplay, gXScreenNumber), &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 3\n");*/
        gActiveColor =
            get_color("ActiveColor", "Foreground",
                       BlackPixel(gXDisplay, gXScreenNumber), &cmap);

        /*
         * for next two, I want name arg = class arg, ie do not want
         * Background and Foreground.
         */

/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 4\n");*/
        gControlBackgroundColor = get_color("ControlBackground",
            "ControlBackground", WhitePixel(gXDisplay, gXScreenNumber), &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 5\n");*/
        gControlForegroundColor = get_color("ControlForeground",
            "ControlForeground", BlackPixel(gXDisplay, gXScreenNumber), &cmap);

        /* maintain backwards compatibility */

/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 6\n");*/
        fricas_color = get_color("FriCASColor", "Foreground", 0, &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 7\n");*/
        if (fricas_color == 0)
            fricas_color = get_color("SpadColor", "Foreground",
                BlackPixel(gXDisplay, gXScreenNumber), &cmap);

/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 8\n");*/
        gInputBackgroundColor =
            get_color("InputBackground", "Foreground", gRmColor, &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 9\n");*/
        gInputForegroundColor =
           get_color("InputForeground", "Background", gBackgroundColor, &cmap);

/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 10\n");*/
        gEmColor =
            get_color("EmphasizeColor", "Foreground", gRmColor, &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 11\n");*/
        gTtColor =
            get_color("TtColor", "Foreground", gRmColor, &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 12\n");*/
        gSlColor =
            get_color("EmphasizeColor", "Foreground", gRmColor, &cmap);
/*        fprintf(stderr,"initx:ingItColors_and_fonts:get_color 13\n");*/
        gBfColor =
            get_color("BoldColor", "Foreground", gRmColor, &cmap);
    }

/*    fprintf(stderr,"initx:ingItColors_and_fonts:makeColors\n");*/
    makeColors(gXDisplay, gXScreenNumber, &cmap, &spadColors, &ts);
    /*
     * Now set the current color and font, so I never have to do it again
     */

    gTopOfGroupStack->cur_color = gRmColor;
    gTopOfGroupStack->cur_font = gRmFont;
/*    fprintf(stderr,"initx:ingItColors_and_fonts:exited\n");*/
}
Ejemplo n.º 3
0
int
main(void)
{

  XGCValues       controlGCVals;
  int             i,code;
  view2DStruct    viewData;

  char property[256];
  char *prop = &property[0];
  char *str_type[20];
  XrmValue value;


  /**** Set up display ****/
  if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL)
    fprintf(stderr,"Could not open the display.\n");
  scrn  = DefaultScreen(dsply);
  rtWindow  = RootWindow(dsply,scrn);

  /**** link Xwindows to viewports - X10 feature ****/
  table        = XCreateAssocTable(nbuckets);

  /**** Create FriCAS color map ****/
  totalColors = XInitSpadFill(dsply,scrn,&colorMap,
                              &totalHues,&totalSolidShades,
                              &totalDitheredAndSolids,&totalShades);

  if (totalColors < 0) {
    fprintf(stderr,">>Error: Could not allocate all the necessary colors.\n");
    exitWithAck(RootWindow(dsply,scrn),Window,-1);
  }

  mergeDatabases();


  /*** Determine whether monochrome or color is used ***/
  if (XrmGetResource(rDB,"Axiom.2D.monochrome","",str_type,&value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop, "off");

  mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0));

  if (XrmGetResource(rDB,"Axiom.2D.inverse","",str_type,&value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop, "off");

  if (mono)
    if (strcmp(prop,"on") == 0) {             /* 0 if equal (inverse video) */
      foregroundColor = WhitePixel(dsply,scrn);
      backgroundColor = BlackPixel(dsply,scrn);
    } else {                                  /* off (no inverse video) */
      foregroundColor = BlackPixel(dsply,scrn);
      backgroundColor = WhitePixel(dsply,scrn);
    }
  else   /* inverse of inverse in color (for some strange reason) */
    if (strcmp(prop,"on") == 0) {         /* 0 if equal (inverse video) */
      foregroundColor = WhitePixel(dsply,scrn);
      backgroundColor = BlackPixel(dsply,scrn);
    } else {                                  /* off (no inverse video) */
      foregroundColor = BlackPixel(dsply,scrn);
      backgroundColor = WhitePixel(dsply,scrn);
    }


  /* read default file name for postScript output */
  if (XrmGetResource(rDB,
                     "Axiom.2D.postscriptFile",
                     "",
                     str_type, &value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop, "axiom2D.ps");

  PSfilename = (char *)malloc(strlen(prop)+1);
  strcpy(PSfilename,prop);



  /**** Open global fonts ****/
  serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn)));

  if (XrmGetResource(rDB,
                     "Axiom.2D.messageFont",
                     "Axiom.2D.Font",
                     str_type, &value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop,messageFontDefault);
  if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) {
    fprintf(stderr,
            "Warning:  could not get the %s font for messageFont\n",prop);
    globalFont = serverFont;
  }

  if (XrmGetResource(rDB,
                     "Axiom.2D.buttonFont",
                     "Axiom.2D.Font",
                     str_type, &value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop,buttonFontDefault);
  if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) {
    fprintf(stderr,
            "Warning:  could not get the %s font for buttonFont\n",prop);
    buttonFont = serverFont;
  }

  if (XrmGetResource(rDB,
                     "Axiom.2D.headerFont",
                     "Axiom.2D.Font",
                     str_type, &value) == True)
     (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop,headerFontDefault);

  if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) {
    fprintf(stderr,
            "Warning:  could not get the %s font for headerFont\n",prop);
    headerFont = serverFont;
  }

  if (XrmGetResource(rDB,
                     "Axiom.2D.titleFont",
                     "Axiom.2D.Font",
                     str_type,&value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop,titleFontDefault);

  if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) {
    fprintf(stderr,
            "Warning:  could not get the %s font for titleFont\n",prop);
    titleFont = serverFont;
  }

  if (XrmGetResource(rDB,
                     "Axiom.2D.graphFont",
                     "Axiom.2D.Font",
                     str_type,&value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop,graphFontDefault);

  if ((graphFont = XLoadQueryFont(dsply, prop)) == NULL) {
    fprintf(stderr,
            "Warning:  could not get the %s font for graphFont\n",prop);
    graphFont = serverFont;
  }

  if (XrmGetResource(rDB,
                     "Axiom.2D.unitFont",
                     "Axiom.2D.Font",
                     str_type,&value) == True)
    (void) strncpy(prop,value.addr,(int)value.size);
  else
    (void) strcpy(prop,unitFontDefault);

  if ((unitFont = XLoadQueryFont(dsply, prop)) == NULL) {
     fprintf(stderr,
             "Warning:  could not get the %s font for unitFont\n",prop);
     unitFont = serverFont;
  }


  /**** Create widely used Graphic Contexts ****/
  PSGlobalInit();
  /* must initiate before using any G/PS functions
     need character name: used as postscript GC variable
     need to create ps GCs for all GCs used by drawings in viewWindow */

  /* globalGC1 */

  controlGCVals.foreground = monoColor(axesColorDefault);
  controlGCVals.background = backgroundColor;
  globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground ,
                        &controlGCVals);
  carefullySetFont(globalGC1,globalFont);


  /* create the equivalent GCs for ps */
  PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /* controlMessageGC */

  controlGCVals.foreground = controlMessageColor;
  controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground
                               ,&controlGCVals);
  carefullySetFont(controlMessageGC,globalFont);

  /* globalGC2 */

  controlGCVals.foreground = monoColor(labelColor);
  controlGCVals.background = backgroundColor;
  globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground,
                        &controlGCVals);
  carefullySetFont(globalGC2,buttonFont);
  PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /* trashGC  */

  trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
  carefullySetFont(trashGC,buttonFont);
  PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /* globGC */

  globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals);
  carefullySetFont(globGC,headerFont);
  PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /* anotherGC  */

  controlGCVals.line_width = colorWidth;
  anotherGC  = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals);
  carefullySetFont(anotherGC,titleFont);
  PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /* processGC */

  gcVals.background = backgroundColor;
  processGC         = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals);
  carefullySetFont(processGC,buttonFont);

  /* graphGC */

  graphGC           = XCreateGC(dsply,rtWindow,GCBackground,&gcVals);
  carefullySetFont(graphGC,graphFont);
  PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /* unitGC */

  unitGC            = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals);
  carefullySetFont(unitGC,unitFont);
  PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap,
                  psMiterJoin, psWhite, psBlack);

  /**** Initialize Graph States ****/

  for (i=0; i<maxGraphs; i++) {
    graphStateArray[i].scaleX = 0.9;
    graphStateArray[i].scaleY = 0.9;
    graphStateArray[i].deltaX = 0.0;
    graphStateArray[i].deltaY = 0.0;
    graphStateArray[i].centerX = 0.0;
    graphStateArray[i].centerY = 0.0;
    graphStateArray[i].pointsOn  = yes;
    graphStateArray[i].connectOn = yes;
    graphStateArray[i].splineOn  = no;
    graphStateArray[i].axesOn    = yes;
    graphStateArray[i].unitsOn   = no;
    graphStateArray[i].showing   = no;
    graphStateArray[i].selected  = no;
    graphStateBackupArray[i] = graphStateArray[i];
  }

  /**** Get Data from the Viewport Manager ****/

  i = 123;
  code=check(write(Socket,&i,intSize));

  /* Check if I am getting stuff from FriCAS or, if I am viewAlone. */
  readViewman(&viewAloned,intSize);
  readViewman(&viewData,sizeof(view2DStruct));
  readViewman(&i,intSize);

  if (!(viewData.title = (char *)malloc(i))) {
    fprintf(stderr,
            "ERROR: Ran out of memory trying to receive the title.\n");
    exitWithAck(RootWindow(dsply,scrn),Window,-1);
  }
  readViewman(viewData.title,i);

  for (i=0; i<maxGraphs; i++) {
    readViewman(&(graphArray[i].key),intSize);
    if (graphArray[i].key) {            /** this graph slot has data **/
      getGraphFromViewman(i);
    } /* if graph exists (graphArray[i].key is not zero) */
  } /* for i in graphs */

  viewport = makeView2D(&viewData);
  control = viewport->controlPanel;

  bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls);

  /* send acknowledgement to viewport manager */
  i = 345;
  check(write(Socket,&(viewport->viewWindow),sizeof(Window)));

  processEvents();

  goodbye(-1);
  return(0);  /* control never reaches here but compiler complains */
} /* main() */