Пример #1
0
OsStatus LogNotifier::init(TiXmlElement* element, TiXmlElement* dummy)
{
   UtlString alarmFile;
   textContentShallow(alarmFile, element->FirstChildElement("file"));
   initLogfile(alarmFile);
   return OS_SUCCESS;
}
Пример #2
0
/* Initialize all of the logfiles */
static void logmerge::initLogfiles(log_queue& queue, int argc, char **argv)
{
    if(argc>1) {
        for(int i=1; i<argc; i++) {
            initLogfile(queue, argv[i]);
        }
    } else {
        char buf[8192];
        if (isatty(STDIN_FILENO)) {
            std::cerr << "No logfiles given, accepting list from stdin"
                      << std::endl;
        }
        while(fgets((char*)&buf, sizeof(buf)-1, stdin)) {
            buf[strlen(buf)-1]=0x00;
            initLogfile(queue, buf);
        }
    }
}
Пример #3
0
static retCode setLogFile(char *option, logical enable, void *cl) {
  return initLogfile(option);
}
Пример #4
0
/*
 * Go evaluator main program
 */
int main(int argc, char **argv) {
  int narg;

#ifdef HAVE_LOCALECONV
  setlocale(LC_ALL,"");		/* set up locale */
#endif

#ifdef LOCALEDIR
  bindtextdomain(PACKAGE,LOCALEDIR);
  textdomain(PACKAGE);
#endif

  initLogfile((char *) "-");
  initFileIo();        /* Set up special file handling */

  strMsg(entryPoint, NumberOf(entryPoint), "lo.boot@__boot"); /* standard entry point */

  if ((narg = getOptions(argc, argv)) < 0) {
    outMsg(logFile, _("usage: %s [-v] [-L log] [-g host:port] [-V] [-b boot:ver] [-m entry] [-r repo] [-d wd]"
                        " [-h sizeK] [-s sizeK] [-d rootdir] args ...\n"), argv[0]);
    exit(1);
  }

  // Set up repository directory
  if (uniIsLit(repoDir, "")) { // overridden?
    char *dir = getenv("LO_DIR"); /* pick up the installation directory */
    if (dir == NULL)
      dir = LODIR;                  /* Default installation path */
    uniCpy(repoDir, NumberOf(repoDir), dir);
  }

  // set up working directory
  if (uniIsLit(loCWD, "")) {
    char cbuff[MAXPATHLEN];
    char *cwd = getcwd(cbuff, NumberOf(cbuff)); /* compute current starting directory */
    if (cwd == NULL)
      syserr("cant determine current directory");
    else
      strMsg(loCWD, NumberOf(loCWD), "%s/", cwd);
  }

  if (loadManifest(repoDir) != Ok) {
    outMsg(logFile, "error in loading repository from %s", repoDir);
    exit(99);
  }

  /* IMPORTANT -- Keep the order of these set up calls */
  initGlobal(initHeapSize);    /* start up the global space */
  initClass();        /* Initialize the class handlers */
  initPrograms();      /* Initialize program handling */
  initDict();        /* Start up the dictionaries */
  install_escapes();      /* Initialize the escape table */
  initFiles();        /* initialize file tables */
  init_args(argv, argc, narg);    /* Initialize the argument list */
  init_time();        /* Initialize time stuff */

  setupSignals();

#ifdef EXECTRACE
  if (traceCount)
    atexit(dumpInsCount);
#endif

  bootstrap(entryPoint, bootPkg, bootVer);

  return EXIT_SUCCEED;          /* exit the lo system cleanly */
}
Пример #5
0
int getOptions(int argc, char **argv) {
  int opt;
  extern char *optarg;
  extern int optind;

  splitFirstArg(argc, argv, &argc, &argv);

  for (; optCount < NumberOf(Options) &&
         (opt = getopt(argc, argv, GNU_GETOPT_NOPERMUTE "m:D:d:gG:vVh:s:L:r:b:R:")) >= 0; optCount++) {
    Options[optCount].option = (codePoint) opt;     /* store the option */

    if (optarg != NULL) {
      strncpy(Options[optCount].value, optarg, NumberOf(Options[optCount].value));
    } else
      Options[optCount].value[0] = '\0';

    switch (opt) {
      case 'D': {      /* turn on various debugging options */
        char *c = optarg;

        while (*c) {
          switch (*c++) {
            case 'e':    /* Escape call tracing */
#ifdef EXECTRACE
              traceCalls = True;
              continue;
#else
            logMsg(logFile,"Escape tracing not enabled\n");
            return -1;
#endif

            case 'd':    /* single step instruction tracing */
#ifdef EXECTRACE
              debugging = True;
              continue;
#else
            logMsg(logFile,"Instruction-level debugging not enabled\n");
            return -1;
#endif

            case 'v':    /* turn on verify tracing */
#ifdef VERIFYTRACE
              traceVerify = True;
              continue;
#else
            logMsg(logFile,"code verification not enabled\n");
            return -1;
#endif

            case 'm':    /* trace memory allocations  */
#ifdef MEMTRACE
              if (traceMemory)
                stressMemory = True;
              else
                traceMemory = True;
              continue;
#else
            logMsg(logFile,"memory tracing not enabled");
            return -1;
#endif

            case 'l':    /* trace synch locks */
#ifdef LOCKTRACE
              traceLock = True;
              continue;
#else
            logMsg(logFile,"sync tracing not enabled");
            return -1;
#endif

            case 'p':    /* trace put-style operations */
#ifdef EXECTRACE
              tracePut = True;
              continue;
#else
            logMsg(logFile,"put tracing not enabled");
            return -1;
#endif

            case 'G':    /* Internal symbolic tracing */
#ifdef EXECTRACE
              SymbolDebug = True;
              interactive = False;
              continue;
#else
            logMsg(logFile,"tracing not enabled");
            return -1;
#endif

            case 'g':    /* Internal symbolic debugging */
              SymbolDebug = True;
              interactive = True;
              continue;

            case 'I':
#ifdef STATSTRACE
#ifdef EXECTRACE
              traceCount = True;
              atexit(dumpInsCount);
              break;
#endif
#else
            logMsg(logFile,"instruction counting not enabled");
            return -1;
#endif

            case 'r':     /* Trace resource mgt */
#ifdef RESOURCETRACE
              traceResource = True;
#else
            logMsg(logFile,"Resource tracing not enabled\n");
            return -1;
#endif
            case '*':    /* trace everything */
#ifdef ALLTRACE
              traceCalls = True;
              debugging = True;
              interactive = True;
              traceVerify = True;
              traceCount = True;
              traceMessage = True;
              if (traceMemory)
                stressMemory = True;
              else
                traceMemory = True;
              tracePut = True;              /* term freeze */
              traceResource = True;
#else
            logMsg(logFile,"debugging not enabled\n");
            return -1;
#endif
            default:;
          }
        }
        break;
      }

      case 'g': {
        SymbolDebug = True;  /* turn on symbolic debugging */
        interactive = True;       // Initially its also interactive
        break;
      }

      case 'G': {        /* non-default debugging package */
        strMsg(debugPkg, NumberOf(debugPkg), "%s", optarg);
        break;
      }

      case 'm': {                          /* modify the entry point */
        uniCpy(entryPoint, NumberOf(entryPoint), optarg);
        break;
      }

      case 'r': {
        strMsg(repoDir, NumberOf(repoDir), "%s", optarg);
        break;
      }

      case 'd': {                      /* non-standard initial working directory */
        strMsg(loCWD, NumberOf(loCWD), "%s", optarg);
        break;
      }

      case 'b': {
        parsePkgOpt(optarg, bootPkg, NumberOf(bootPkg), bootVer, NumberOf(bootVer));
        break;
      }

      case 'R': {                          /* fix the random seed */
        srand((unsigned int) atoi(optarg));
        break;
      }

      case 'L': {
        char fn[MAX_MSG_LEN];
        strncpy((char *) fn, optarg, NumberOf(fn));

        if (initLogfile(fn) != Ok) {
          logMsg(logFile, "log file %s not found", optarg);
          return -1;
        }
        break;
      }

      case 'v':                           /* Display version ID */
        outMsg(logFile, "%s", version);
        outMsg(logFile, "%s", copyRight);
        break;

      case 'V':                      /* Turn on (will be off) code verification */
        enableVerify = (logical) !enableVerify;
        break;

      case 'h':                           /* set up heap size */
        initHeapSize = atoi(optarg) * 1024;
        break;

      case 's':                           /* set up initial size of a thread */
        initStackHeapSize = atoi(optarg) * 1024;
        break;

      default:
        break;                            /* ignore options we dont understand */
    }
  }
  return optind;
}