コード例 #1
0
ファイル: main.cpp プロジェクト: boban-dj/cameradar
int
main(int argc, char* argv[]) {
    etix::tool::logger::get_instance("cameradar");
    auto args = parse_cmdline(argc, argv);
    if (not args.first) return EXIT_FAILURE;

    print_version();
    // configure file configuration path
    auto conf_path = std::string{};
    if (not args.second.exist("-c")) {
        conf_path = etix::cameradar::default_configuration_path;
        LOG_WARN_("No custom path set, trying to use default path: " + conf_path, "main");
    } else {
        conf_path = args.second["-c"];
    }

    if (not args.second.exist("-l")) {
        etix::tool::logger::get_instance("cameradar").set_level(etix::tool::loglevel::INFO);
        LOG_INFO_("No log level set, using log level 2 (ignoring DEBUG)", "main");
    } else {
        try {
            int level = std::stoi(args.second["-l"]);
            etix::tool::logger::get_instance("cameradar")
                .set_level(static_cast<etix::tool::loglevel>(level));
        } catch (...) {
            LOG_ERR_("Invalid log level format, log level should be 1, 2, 4, 5 or 6", "main");
            return EXIT_FAILURE;
        }
    }

    // Try to load the configuration
    auto conf = cmrdr::load(conf_path);
    if (not conf.first) { return EXIT_FAILURE; }

    LOG_INFO_("Configuration successfully loaded", "main");

    // If one of the path is invalid, exit
    auto paths_ok = check_storage_path(conf.second.thumbnail_storage_path);
    if (not paths_ok) { return EXIT_FAILURE; }

    // Here we should get the cache manager but for now we will juste
    // make a dumb cache manager
    auto plug = std::make_shared<etix::cameradar::cache_manager>(conf.second.cache_manager_path,
                                                                 conf.second.cache_manager_name);

    if (not plug->make_instance()) {
        LOG_ERR_(std::string("Invalid cache manager "), "cameradar");
        return false;
    }

    LOG_INFO_("Launching Cameradar, press CTRL+C to gracefully stop", "main");

    etix::cameradar::dispatcher disp(conf.second, plug, args);

    disp.run();

    LOG_WARN_("See ya !", "cameradar");
    return EXIT_SUCCESS;
}
コード例 #2
0
TransformInstance SceneGraph::get(UnitId id)
{
	return make_instance(_map[id.index]);
}
コード例 #3
0
ファイル: INIT.CPP プロジェクト: longbai/MSW-Logo
void init()
   {
   //    extern long time();
   int i /* = 0 */;
   NODE *proc = NIL, *pname = NIL, *cnd = NIL;

   fill_reserve_tank();
   Unbound = newnode(PUNBOUND);

#ifdef bsd
   srandom((int) time((long *) NULL));
#else
   //    srand((int)time((long *)NULL));
   //    srand((int)12345);
#endif
#ifdef ecma
   for (i = 0; i < 128; i++)
      ecma_array[i] = i;
   for (i = 0; i < ecma_size; i++)
      ecma_array[special_chars[i]] = ecma_begin+i;
#endif

   //    logolib = getenv("LOGOLIB");
   //    if (logolib == NULL) logolib = libloc;
   //    editor = getenv("EDITOR");
   //    if (editor == NULL) editor = "jove";

   editor = "jove";
   editorname = strrchr(editor, (int) '/');
   editorname = (editorname ? editorname + 1 : editor);

   i = 0;
   while (prims[i].name) 
      {
      if (prims[i].priority == MACRO_PRIORITY)
         proc = reref(proc, newnode(MACRO));
      else if (prims[i].priority == TAIL_PRIORITY)
         proc = reref(proc, newnode(TAILFORM));
      else if ((prims[i].priority & ~4) == PREFIX_PRIORITY)
         proc = reref(proc, newnode(PRIM));/* incl. --                        */
      else
         proc = reref(proc, newnode(INFIX));
      if (prims[i].priority < PREFIX_PRIORITY)
         setprimpri(proc, PREFIX_PRIORITY);
      else
         setprimpri(proc, prims[i].priority);
      setprimfun(proc, (lexzer) prims[i].prim);
      setprimdflt(proc, prims[i].defargs);
      setprimmax(proc, prims[i].maxargs);
      setprimmin(proc, prims[i].minargs);
      pname = reref(pname, make_static_strnode(prims[i].name));
      cnd = reref(cnd, make_instance(pname, pname));
      setprocnode__caseobj(cnd, proc);
      if (nodetype(proc) == MACRO)
         setflag__caseobj(cnd, PROC_MACRO);
      i++; 
      }
   deref(proc);
   deref(cnd);
   deref(pname);
   Truex = intern(make_static_strnode("true"));
   Falsex = intern(make_static_strnode("false"));
   Left_Paren = intern(make_static_strnode("("));
   Right_Paren = intern(make_static_strnode(")"));
   Minus_Sign = intern(make_static_strnode("-"));
   Minus_Tight = intern(make_static_strnode("--"));
   Query = intern(make_static_strnode("?"));
   Null_Word = intern(make_static_strnode("\0"));
   To = intern(make_static_strnode("to"));
   Macro = intern(make_static_strnode(".macro"));
   Toplevel = intern(make_static_strnode("toplevel"));
   System = intern(make_static_strnode("system"));
   Error = intern(make_static_strnode("error"));
   End = intern(make_static_strnode("end"));
   If = intern(make_static_strnode("if"));
   Ifelse = intern(make_static_strnode("ifelse"));
   Redefp = intern(make_static_strnode("redefp"));
   Caseignoredp = intern(make_static_strnode("caseignoredp"));
   setvalnode__caseobj(Caseignoredp, Truex);
   setflag__caseobj(Caseignoredp, VAL_BURIED);
   Erract = intern(make_static_strnode("erract"));
   Printdepthlimit = intern(make_static_strnode("printdepthlimit"));
   Printwidthlimit = intern(make_static_strnode("printwidthlimit"));
   Pause = intern(make_static_strnode("pause"));
   Startup = intern(make_static_strnode("startup"));
   Output = intern(make_static_strnode("output"));
   Op = intern(make_static_strnode("op"));
   Stop = intern(make_static_strnode("stop"));
   Goto = intern(make_static_strnode("goto"));
   Tag = intern(make_static_strnode("Tag"));
   the_generation = valref(cons(NIL, NIL));
   Not_Enough_Node = valref(cons(NIL, NIL));

   }
コード例 #4
0
ファイル: init.c プロジェクト: Distrotech/ucblogo
void init(void) {
    int i = 0;
    NODE *iproc = NIL, *pname = NIL, *cnd = NIL;
    FILE *fp;
    char linebuf[100];
    char *sugar;
    static char sugarlib[100], sugarhelp[100], sugarcsls[100];
#ifdef WIN32
    HKEY regKey1, regKey2, regKey3;
    int got_hklm = 0;
    char buf[200];
    unsigned long int bufsiz;
    char *envp;
#endif

    readstream = stdin;
    writestream = stdout;
    loadstream = stdin;

    fill_reserve_tank();
    oldyoungs = Unbound = newnode(PUNBOUND);

#ifdef HAVE_SRANDOM
    srandom((int)time((time_t *)NULL));
#else
    srand((int)time((time_t *)NULL));
#endif
#ifdef ecma
    for (i=0; i<128; i++)
	ecma_array[i] = i;
    for (i=0; i<ecma_size; i++)
	ecma_array[(int)special_chars[i]] = ecma_begin+i;
    i = 0;
#endif

    sugar = getenv("SUGAR_BUNDLE_PATH");
    if (sugar != NULL) {
	strcpy(sugarlib,sugar);
	strcat(sugarlib,"/logolib");
	logolib = sugarlib;
	fp = fopen(logolib,"r");
	if (fp == NULL) goto nosugar;
	fclose(fp);
	chdir(getenv("SUGAR_ACTIVITY_ROOT"));
	chdir("data");
	strcpy(sugarhelp,sugar);
	strcat(sugarhelp,"/helpfiles");
	helpfiles = sugarhelp;
	strcpy(sugarcsls,sugar);
	strcat(sugarcsls,"/csls");
	csls = sugarcsls;
    } else {
nosugar:
	logolib = getenv("LOGOLIB");
	helpfiles = getenv("LOGOHELP");
	csls = getenv("CSLS");
    }
    editor = getenv("EDITOR");
#ifdef WIN32
    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software", 0,
		     KEY_READ, &regKey1) == ERROR_SUCCESS) {
	if (RegOpenKeyEx(regKey1, "UCB", 0, 
			 KEY_READ, &regKey2) == ERROR_SUCCESS) {
	    if (RegOpenKeyEx(regKey2, "UCBLogo", 0,
			     KEY_READ, &regKey3) == ERROR_SUCCESS) {
		got_hklm = 1;
	/*	logolib = getenv("LOGOLIB"); */
		if (logolib == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "LOGOLIB", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
					    logolib = malloc(bufsiz);
					    strcpy(logolib, buf);
		    }
		}
	/*	helpfiles = getenv("LOGOHELP"); */
		if (helpfiles == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "HELPFILE", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			helpfiles = malloc(bufsiz);
			strcpy(helpfiles, buf);
		    }
		}
	/*	csls = getenv("CSLS"); */
		if (csls == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "CSLS", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			csls = malloc(bufsiz);
			strcpy(csls, buf);
		    }
		}
	/*	editor = getenv("EDITOR"); */
		if (editor == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "EDITOR", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			editor = malloc(bufsiz);
			strcpy(editor, buf);
		    }
		}
		RegCloseKey(regKey3);
	    }
	    RegCloseKey(regKey2);
	}
	RegCloseKey(regKey1);
    }
    if (!got_hklm && RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0,
				  KEY_READ, &regKey1) == ERROR_SUCCESS) {
	if (RegOpenKeyEx(regKey1, "UCB", 0, 
			 KEY_READ, &regKey2) == ERROR_SUCCESS) {
	    if (RegOpenKeyEx(regKey2, "UCBLogo", 0,
			     KEY_READ, &regKey3) == ERROR_SUCCESS) {
		got_hklm = 1;
	/*	logolib = getenv("LOGOLIB"); */
		if (logolib == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "LOGOLIB", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
					    logolib = malloc(bufsiz);
					    strcpy(logolib, buf);
		    }
		}
	/*	helpfiles = getenv("LOGOHELP"); */
		if (helpfiles == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "HELPFILE", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			helpfiles = malloc(bufsiz);
			strcpy(helpfiles, buf);
		    }
		}
	/*	csls = getenv("CSLS"); */
		if (csls == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "CSLS", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			csls = malloc(bufsiz);
			strcpy(csls, buf);
		    }
		}
	/*	editor = getenv("EDITOR"); */
		if (editor == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "EDITOR", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			editor = malloc(bufsiz);
			strcpy(editor, buf);
		    }
		}
		RegCloseKey(regKey3);
	    }
	    RegCloseKey(regKey2);
	}
	RegCloseKey(regKey1);
    }
#endif
	
    if (logolib == NULL) logolib = libloc;
    if (helpfiles == NULL) helpfiles = helploc;
    if (csls == NULL) csls = cslsloc;
	
#ifdef HAVE_WX
#ifndef __WXMSW__
	// have to do this because we don't have __WXMAC__ in C
	const char* wxMacGetCslsloc();
	const char* wxMacGetHelploc();
	const char* wxMacGetLibloc();
	char* newlib;
	char* newcsls;
	char* newhelp;
	// check if we are running wxMac
	newlib = wxMacGetLibloc();
	if(newlib)
		logolib=newlib; 
    //if (helpfiles == NULL) helpfiles = wxMacGetHelploc();
    newcsls = wxMacGetCslsloc();
	if(newcsls)
		csls = newcsls;
	newhelp = wxMacGetHelploc();
    if(newhelp)
		helpfiles = newhelp;
#endif
#endif
	
#ifdef unix
    if (editor == NULL) editor = "emacs";
#else
    if (editor == NULL) editor = "jove";
#endif
    editorname = strrchr(editor, (int)'/');
    if (editorname == NULL) editorname = strrchr(editor, (int)'\\');
#ifdef WIN32
    if (editorname == NULL) {
	putenv("DESCRIBE=CMDS.DOC");
	putenv("JOVERC=JOVE.RC");
    } else {
	bufsiz = sprintf(buf, "DESCRIBE=%.*s\\CMDS.DOC", editorname-editor, editor);
	envp = malloc(bufsiz+1);
	strcpy(envp, buf);
	putenv(envp);
	bufsiz = sprintf(buf, "JOVERC=%.*s\\JOVE.RC", editorname-editor, editor);
	envp = malloc(bufsiz+1);
	strcpy(envp, buf);
	putenv(envp);
    }
#endif
    if (editorname == NULL) editorname = strrchr(editor, (int)':');
    editorname = (editorname ? editorname+1 : editor);
    tempdir = getenv("TEMP");
    if (tempdir == NULL) tempdir = temploc;
    while (prims[i].name) {
	if (prims[i].priority == MACRO_PRIORITY)
	    iproc = newnode(MACRO);
	else if (prims[i].priority <= TAIL_PRIORITY)
	    iproc = newnode(TAILFORM);
	else if ((prims[i].priority & ~4) == (PREFIX_PRIORITY & ~4))
	    iproc = newnode(PRIM); /* incl. -- */
	else
	    iproc = newnode(INFIX);
	setprimpri(iproc, prims[i].priority);
	setprimfun(iproc, prims[i].prim);
	setprimdflt(iproc, prims[i].defargs);
	setprimmax(iproc, prims[i].maxargs);
	setprimmin(iproc, prims[i].minargs);
	pname = make_static_strnode(prims[i].name);
	cnd = make_instance(pname, pname);
	setprocnode__caseobj(cnd, iproc);
	if (nodetype(iproc) == MACRO)
	    setflag__caseobj(cnd, PROC_MACRO);
	if (prims[i].minargs < 0)
	    setflag__caseobj(cnd, PROC_SPECFORM);
	setflag__caseobj(cnd, PERMANENT);
	i++;
    }
    Left_Paren = intern_p(make_static_strnode("("));
    Right_Paren = intern_p(make_static_strnode(")"));
    Minus_Sign = intern_p(make_static_strnode("-"));
    Minus_Tight = intern_p(make_static_strnode("--"));
    Query = intern_p(make_static_strnode("?"));
    Null_Word = intern_p(make_static_strnode("\0"));
    Redefp = intern_p(make_static_strnode("redefp"));
    Caseignoredp = intern_p(make_static_strnode("caseignoredp"));
    Erract = intern_p(make_static_strnode("erract"));
    Buttonact = intern_p(make_static_strnode("buttonact"));
    Keyact = intern_p(make_static_strnode("Keyact"));
    Printdepthlimit = intern_p(make_static_strnode("printdepthlimit"));
    Printwidthlimit = intern_p(make_static_strnode("printwidthlimit"));
    LoadNoisily = intern_p(make_static_strnode("loadnoisily"));
    AllowGetSet = intern_p(make_static_strnode("allowgetset"));
    Fullprintp = intern_p(make_static_strnode("fullprintp"));
    UnburyOnEdit = intern_p(make_static_strnode("unburyonedit"));
    UseAlternateNames = intern_p(make_static_strnode("usealternatenames"));
    Make = intern_p(make_static_strnode("make"));
    Listvalue = cons(intern_p(make_static_strnode("value")),NIL);
    Dotsvalue = make_colon(car(Listvalue));
    Pause = intern_p(make_static_strnode("pause"));
    Startup = intern_p(make_static_strnode("startup"));
    Startuplg = intern_p(make_static_strnode("startup.lg"));
    LogoVersion = intern_p(make_static_strnode("logoversion"));
    LogoPlatform = intern_p(make_static_strnode("logoplatform"));
    LogoLogo = intern_p(make_static_strnode("logo-logo"));
    CommandLine = intern_p(make_static_strnode("command.line"));
    setflag__caseobj(CommandLine, VAL_BURIED);
    the_generation = cons(NIL, NIL);
    Not_Enough_Node = cons(NIL, NIL);

    sprintf(linebuf,"%s%sMessages", logolib, separator);
    fp = fopen("Messages", "r");
    if (fp == NULL)
	fp = fopen(linebuf, "r");
    if (fp == NULL)
	fp = fopen("C:\\cygwin\\usr\\local\\lib\\logo\\logolib\\Messages", "r");
    if (fp == NULL) {
	printf("Error -- Can't read Messages file.\n");
	exit(1);
    }

    for (i=0; i<(MAX_MESSAGE+NUM_WORDS); i++) {
	while (fgets(linebuf, 99, fp) != NULL && linebuf[0] == ';') ;
	linebuf[strlen(linebuf)-1] = '\0';
	message_texts[i] = (char *) malloc(1+strlen(linebuf));
	strcpy(message_texts[i], linebuf);
    }

    fclose(fp);

#define wd_copy(x) \
    translations[Name_ ## x].English = intern_p(make_static_strnode(#x)); \
    translations[Name_ ## x].Alt = \
	intern_p(make_static_strnode(message_texts[MAX_MESSAGE + Name_ ## x]));

    do_trans(wd_copy);

    translations[Name_macro].English = intern_p(make_static_strnode(".macro"));

#define True translations[Name_true].English
#define False translations[Name_false].English

    setvalnode__caseobj(Caseignoredp, True);
    setflag__caseobj(Caseignoredp, VAL_BURIED);
    setvalnode__caseobj(AllowGetSet, True);
    setflag__caseobj(AllowGetSet, VAL_BURIED);
    setvalnode__caseobj(Fullprintp, False);
    setflag__caseobj(Fullprintp, VAL_BURIED);
    setvalnode__caseobj(UnburyOnEdit, True);
    setflag__caseobj(UnburyOnEdit, VAL_BURIED);
    setvalnode__caseobj(UseAlternateNames, False);
    setflag__caseobj(UseAlternateNames, VAL_BURIED);

    setvalnode__caseobj(LogoPlatform, make_static_strnode(LogoPlatformName));
    setflag__caseobj(LogoPlatform, VAL_BURIED);

    user_repcount = -1;
    ift_iff_flag = -1;

    num_saved_nodes = (NODE **)(&(val_status)) - (NODE **)(&(proc));
    Regs_Node = newnode(STACK);
    Regs_Node->n_car = (NODE *)&regs;

//hist_inptr = hist_outptr = cmdHistory;

#ifdef OBJECTS
    obj_init();
#endif

/*  Uncomment these to print debugging messages right away! */
/*
    setvalnode__caseobj(Redefp, True);
    setflag__caseobj(Redefp, VAL_BURIED);
 */
}
コード例 #5
0
ファイル: script_world.cpp プロジェクト: neuroradiology/crown
	static void unit_destroyed_callback_bridge(UnitId unit, void* user_ptr)
	{
		unit_destroyed_callback(*((ScriptWorld*)user_ptr), unit, make_instance(UINT32_MAX));
	}