Example #1
1
int
main(
	int  argc,
	char  *argv[]
)
{
	char  *getenv();
	int  i, file0;

	progname = argv[0];
	libpath[0] = "./";
	if ((libpath[i=1] = getenv("MDIR")) != NULL)
		i++;
	libpath[i++] = "/usr/local/lib/meta/";
	libpath[i] = NULL;

	for (file0 = 1; file0 < argc-1; file0 += 2)
		if (!isopt(argv[file0]))
			break;

	if (file0 >= argc)
		dofile(argc-1, argv+1, NULL);
	else
		for (i = file0; i < argc; i++)
			dofile(file0-1, argv+1, argv[i]);

	quit(0);
	return 0; /* pro forma return */
}
Example #2
0
/*
 *			M A I N
 */
int
main(int argc, char **argv)
{
    FILE	*fp=NULL;

    if ( !get_args( argc, argv ) )  {
	(void)fputs(usage, stderr);
	bu_exit (1, NULL);
    }

    if ( verbose )  {
	bn_mat_print("rmat", rmat);
    }

    if ( bu_optind < argc ) {
	while ( bu_optind < argc ) {
	    if ( fp != NULL && fp != stdin )
		fclose( fp );
	    if ( strcmp(argv[bu_optind], "-") == 0 )
		fp = stdin;
	    else if ( (fp = fopen(argv[bu_optind], "r")) == NULL ) {
		fprintf( stderr, "plrot: can't open \"%s\"\n", argv[bu_optind] );
		continue;
	    }
	    dofile( fp );
	    bu_optind++;
	}
    } else {
	dofile( stdin );
    }
    return 0;
}
Example #3
0
void main(int argc, char * argv[])	{
	int numfiles = 0;
 	struct find_t find;
	char * cp;
	char * cp1;

	setbuf(stdout, NULL);	// unbuffered output via printf

	argv++; argc--;
	for (;argc--;argv++)
	{
		if( !_dos_findfirst( *argv, 0xffff, &find ) )
		{
			dofile( find.name );
			numfiles++;
			while( !_dos_findnext( &find ) )	{
				numfiles++;
				dofile( find.name );
			}
	 	}
	}

	if ( numfiles < 1 )	{
		printf( "lbmcomp- this program compresses bbm files by removing\n");
		printf( "unused chunks. The command line is the file specs\n" );
		printf( "to convert. ie.. lbmcomp john*.bbm adam*.bbm\n\n" );
		exit(1);
	}


}
Example #4
0
int
main(
	int  argc,
	char  *argv[]
)
{
	char  *getenv();
	int  i, file0;
	progname = argv[0];
	libpath[0] = "";
	if ((libpath[i=1] = getenv("MDIR")) != NULL)
		i++;
	libpath[i++] = MDIR;
	libpath[i] = NULL;

	for (file0 = 1; file0 < argc; )
		if (istyp(argv[file0]))
			file0++;
		else if (isvar(argv[file0]) && file0 < argc-1)
			file0 += 2;
		else
			break;

	if (file0 >= argc)
		dofile(argc-1, argv+1, NULL);
	else
		for (i = file0; i < argc; i++)
			dofile(file0-1, argv+1, argv[i]);

	quit(0);
	return 0; /* pro forma return */
}
Example #5
0
int main(int argc, char *argv[])
{
    FILE *inf;
    int i = 1;

    if (1 == argc) {
        dofile(stdin, "stdin");
        return 0;
    }

    if (!strcmp(argv[1], "--")) {
        i = 2;
        goto loop;
    }

    if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
        printf("usage: %s [files...]\n", argv[0]);
        puts("Rotates Unicode codepoints (UTF-8 encoded only) such that they stay within their plane.");
        puts("Self-reversible, the same way rot13 is");
        return 0;
    }

    if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
        puts("rot32768 version 1.0");
        puts("Chris Barts, 2017. Released under the GPL Version 3.0 or later");
        return 0;
    }

  loop:
    for (; i < argc; i++) {
        if ((inf = fopen(argv[i], "rb")) == NULL) {
            handle_ferr(argv[i], "rot32768");
            continue;
        }

        dofile(inf, argv[i]);

        if (ferror(inf)) {
            handle_ferr(argv[i], "rot32768");
            fclose(inf);
            continue;
        }

        if (fclose(inf) == EOF)
            handle_ferr(argv[i], "rot32768");
    }

    return 0;
}
Example #6
0
int main (int argc, const char * argv[]) {
//
//	/* a bunch of json: */
//	char text1[]="{\n\"name\": \"Jack (\\\"Bee\\\") Nimble\", \n\"format\": {\"type\":       \"rect\", \n\"width\":      1920, \n\"height\":     1080, \n\"interlace\":  false,\"frame rate\": 24\n}\n}";	
//	char text2[]="[\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"]";
//	char text3[]="[\n    [0, -1, 0],\n    [1, 0, 0],\n    [0, 0, 1]\n	]\n";
//	char text4[]="{\n		\"Image\": {\n			\"Width\":  800,\n			\"Height\": 600,\n			\"Title\":  \"View from 15th Floor\",\n			\"Thumbnail\": {\n				\"Url\":    \"http:/*www.example.com/image/481989943\",\n				\"Height\": 125,\n				\"Width\":  \"100\"\n			},\n			\"IDs\": [116, 943, 234, 38793]\n		}\n	}";
//	char text5[]="[\n	 {\n	 \"precision\": \"zip\",\n	 \"Latitude\":  37.7668,\n	 \"Longitude\": -122.3959,\n	 \"Address\":   \"\",\n	 \"City\":      \"SAN FRANCISCO\",\n	 \"State\":     \"CA\",\n	 \"Zip\":       \"94107\",\n	 \"Country\":   \"US\"\n	 },\n	 {\n	 \"precision\": \"zip\",\n	 \"Latitude\":  37.371991,\n	 \"Longitude\": -122.026020,\n	 \"Address\":   \"\",\n	 \"City\":      \"SUNNYVALE\",\n	 \"State\":     \"CA\",\n	 \"Zip\":       \"94085\",\n	 \"Country\":   \"US\"\n	 }\n	 ]";
//
//	/* Process each json textblock by parsing, then rebuilding: */
//	doit(text1);
//	doit(text2);	
//	doit(text3);
//	doit(text4);
//	doit(text5);
//
//	/* Parse standard testfiles: */
///*	dofile("../../tests/test1"); */
///*	dofile("../../tests/test2"); */
///*	dofile("../../tests/test3"); */
///*	dofile("../../tests/test4"); */
///*	dofile("../../tests/test5"); */
//
//	/* Now some samplecode for building objects concisely: */
//	create_objects();
//	
//	return 0;
char filepath[] = "./main.json";
dofile(filepath);

}
int dodir(char *dirpath)
{
    int rc = 0;
    char path[256];
	DIR *dir;
	struct dirent *dire;
	struct stat statbuf;

    if((dir = opendir(dirpath)) == NULL) {
        fprintf(stderr, "Failed to scan directory %s\n", dirpath);
        return -1;
    }
    if(verbose)
        fprintf(stderr, "Scan %s\n", dirpath);
    while((dire = readdir(dir)) != NULL && rc == 0) {
        if(dire->d_name[0] == '.' || stricmp(dire->d_name, "cvs") == 0)
            continue;
        strcpy(path, dirpath);
        strcat(path, "/");
        strcat(path, dire->d_name);
        stat(path, &statbuf);
  
        if(statbuf.st_mode & S_IFDIR)
            rc = dodir(path);
        else if(statbuf.st_mode & S_IFREG) 
            rc = dofile(path);
    }
    closedir(dir);
    return rc;
}
Example #8
0
File: runq.c Project: 99years/plan9
/*
 *  run the current directory
 */
void
rundir(char *name)
{
	int fd;
	long i;

	if(aflag && sflag)
		fd = sysopenlocked(".", OREAD);
	else
		fd = open(".", OREAD);
	if(fd == -1){
		warning("reading %s", name);
		return;
	}
	nfiles = sysdirreadall(fd, &dirbuf);
	if(nfiles > 0){
		for(i=0; i<nfiles; i++){
			if(dirbuf[i].name[0]!='C' || dirbuf[i].name[1]!='.')
				continue;
			dofile(&dirbuf[i]);
		}
		free(dirbuf);
	}
	if(aflag && sflag)
		sysunlockfile(fd);
	else
		close(fd);
}
Example #9
0
/*
 * execute a series of commands in a file
 *
 * int f, n;		default flag and numeric arg to pass on to file
 */
int execfile(int f, int n)
{
	int status;	/* return status of name query */
	char *fname;	/* name of file to execute */
	char *fspec;		/* full file spec */

        fname = alloca(NSTRING * sizeof(char));
	if ((status =
	     mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE)
		return status;

#if	1
	/* look up the path for the file */
	fspec = flook(fname, FALSE);	/* used to by TRUE, P.K. */

	/* if it isn't around */
	if (fspec == NULL)
		return FALSE;

#endif
	/* otherwise, execute it */
	while (n-- > 0)
		if ((status = dofile(fspec)) != TRUE)
			return status;

	return TRUE;
}
Example #10
0
void LuaBase::boot() {
	dofile("_system.lua");

	lua_pushnil();		// resumeSave
	lua_pushnil();		// bootParam - not used in scripts
	lua_call("BOOT");
}
int main (int argc, char **argv) {

    struct Smain s;
    lua_State *L = lua_open();
    if (L == NULL) {
        l_message(argv[0], "cannot create state: not enough memory");
        return EXIT_FAILURE;
    }
    s.argc = argc;
    s.argv = argv;

    // Open tolua packages
    loadANLBindings(L);

#ifndef DEFAULT_FILE_EXECUTE
    luaL_openlibs(L);
    int status = lua_cpcall(L, &pmain, &s);
    report(L, status);
    lua_close(L);
    return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
#else
    lua_gc(L, LUA_GCSTOP, 0);
    luaL_openlibs(L);
    lua_gc(L, LUA_GCRESTART, 0);
    dofile(L, DEFAULT_FILE_EXECUTE);
    lua_close(L);


#endif

}
Example #12
0
static int pmain (lua_State *L) {
  struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
  char **argv = s->argv;
  int script;
  int has_i = 0, has_v = 0, has_e = 0;
  globalL = L;
  if (argv[0] && argv[0][0]) progname = argv[0];
  lua_gc(L, LUA_GCSTOP, 0);  /* stop collector during initialization */
  luaL_openlibs(L);  /* open libraries */
  lua_gc(L, LUA_GCRESTART, 0);
  s->status = handle_luainit(L);
  if (s->status != 0) return 0;
  script = collectargs(argv, &has_i, &has_v, &has_e);
  if (script < 0) {  /* invalid args? */
    print_usage();
    s->status = 1;
    return 0;
  }
  if (has_v) print_version();
  s->status = runargs(L, argv, (script > 0) ? script : s->argc);
  if (s->status != 0) return 0;
  if (script)
    s->status = handle_script(L, argv, script);
  if (s->status != 0) return 0;
  if (has_i)
    dotty(L);
  else if (script == 0 && !has_e && !has_v) {
    if (lua_stdin_is_tty()) {
      print_version();
      dotty(L);
    }
    else dofile(L, NULL);  /* executes stdin as a file */
  }
  return 0;
}
Example #13
0
static int pmain (lua_State *L) {
  int argc = (int)lua_tointeger(L, 1);
  char **argv = (char **)lua_touserdata(L, 2);
  int script;
  int has_i = 0, has_v = 0, has_e = 0;
  if (argv[0] && argv[0][0]) progname = argv[0];
  script = collectargs(argv, &has_i, &has_v, &has_e);
  if (script < 0) {  /* invalid arg? */
    print_usage(argv[-script]);
    return 0;
  }
  if (has_v) print_version();
  /* open standard libraries */
  luaL_checkversion(L);
  lua_gc(L, LUA_GCSTOP, 0);  /* stop collector during initialization */
  luaL_openlibs(L);  /* open libraries */
  lua_gc(L, LUA_GCRESTART, 0);
  /* run LUA_INIT */
  if (handle_luainit(L) != LUA_OK) return 0;
  /* execute arguments -e and -l */
  if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;
  /* execute main script (if there is one) */
  if (script && handle_script(L, argv, script) != LUA_OK) return 0;
  if (has_i)  /* -i option? */
    dotty(L);
  else if (script == 0 && !has_e && !has_v) {  /* no arguments? */
    if (lua_stdin_is_tty()) {
      print_version();
      dotty(L);
    }
    else dofile(L, NULL);  /* executes stdin as a file */
  }
  lua_pushboolean(L, 1);  /* signal no errors */
  return 1;
}
Example #14
0
void
main(int argc, char *argv[])
{
	int i;
	Biobuf	*bin;

	Binit(&bout, 1, OWRITE);
	argv0 = argv[0];
	ARGBEGIN {
	case 'a':	aflag = 1; break;
	case 'g':	gflag = 1; break;
	case 'h':	hflag = 1; break;
	case 'n':	nflag = 1; break;
	case 's':	sflag = 1; break;
	case 'u':	uflag = 1; break;
	} ARGEND
	if (argc > 1)
		multifile++;
	for(i=0; i<argc; i++){
		filename = argv[i];
		bin = Bopen(filename, OREAD);
		if(bin == 0){
			error("cannot open %s", filename);
			continue;
		}
		if (isar(bin))
			doar(bin);
		else{
			Bseek(bin, 0, 0);
			dofile(bin);
		}
		Bterm(bin);
	}
	exits(errs);
}
Example #15
0
static int pmain(lua_State *L)
{
    int  argc   = (int)lua_tointeger(L, 1);
    char **argv = (char**)lua_touserdata(L, 2);
    int  script;
    int  args[num_has];

    args[has_i] = args[has_v] = args[has_e] = args[has_E] = 0;
    if (argv[0] && argv[0][0])
        progname = argv[0];

    script = collectargs(argv, args);
    if (script < 0)  /* invalid arg? */
    {
        print_usage(argv[-script]);
        return 0;
    }

    if (args[has_v])
        print_version();

    if (args[has_E])  /* option '-E'? */
    {
        lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
        lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
    }

    /* open standard libraries */
    luaL_checkversion(L);
    lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
    luaL_openlibs(L); /* open libraries */
    lua_gc(L, LUA_GCRESTART, 0);
    if (!args[has_E] && handle_luainit(L) != LUA_OK)
        return 0; /* error running LUA_INIT */

    /* execute arguments -e and -l */
    if (!runargs(L, argv, (script > 0) ? script : argc))
        return 0;

    /* execute main script (if there is one) */
    if (script && handle_script(L, argv, script) != LUA_OK)
        return 0;

    if (args[has_i]) /* -i option? */
        dotty(L);
    else if (script == 0 && !args[has_e] && !args[has_v])  /* no arguments? */
    {
        if (lua_stdin_is_tty())
        {
            print_version();
            dotty(L);
        }
        else
            dofile(L, NULL); /* executes stdin as a file */
    }

    lua_pushboolean(L, 1); /* signal no errors */
    return 1;
}
Example #16
0
File: main.c Project: lzubiaur/woot
static int pmain(lua_State *L)
{
    /* Load Lua libraries */
    luaL_openlibs(L);
    l_version();

    return dofile(L,LUA_INIT_SCRIPT);
}
Example #17
0
int
main(int argc, char **argv)
{
    FILE *fp=NULL;

    static char opts[] = "\
   -x# -y# -z#    Rotation about axis in degrees\n\
   -X# -Y# -Z#    Translation along axis\n\
   -s#            Scale factor\n\
   -a# -e#        Azimuth/Elevation from front view\n\
		  (usually first, in this order, implies -M)\n\
   -g             MGED front view to display coordinates (usually last)\n\
   -M             Autoscale space command like RT model RPP\n\
   -m#            Takes a 4X4 matrix as an argument\n\
   -v             Verbose\n\
   -S#            Space: takes a quoted string of six floats\n";

    if (!get_args(argc, argv)) {
	fputs("Usage: plot3rot [options] [file1 ... fileN] > file.plot3\n", stderr);

	(void)fputs(opts, stderr);
	bu_exit (1, NULL);
    }

    if (verbose) {
	bn_mat_print("rmat", rmat);
    }

    if (bu_optind < argc) {
	while (bu_optind < argc) {
	    if (fp != NULL && fp != stdin)
		fclose(fp);
	    if (BU_STR_EQUAL(argv[bu_optind], "-"))
		fp = stdin;
	    else if ((fp = fopen(argv[bu_optind], "r")) == NULL) {
		bu_log("plot3rot: can't open \"%s\"\n", argv[bu_optind]);
		continue;
	    }
	    dofile(fp);
	    bu_optind++;
	}
    } else {
	dofile(stdin);
    }
    return 0;
}
Example #18
0
static int handle_luainit (lua_State *L) {
  const char *init = getenv(LUA_INIT);
  if (init == NULL) return 0;  /* status OK */
  else if (init[0] == '@')
    return dofile(L, init+1);
  else
    return dostring(L, init, "=" LUA_INIT);
}
Example #19
0
static int pmain(lua_State *L)
{
  struct Smain *s = &smain;
  char **argv = s->argv;
  int script;
  int flags = 0;
  globalL = L;
  if (argv[0] && argv[0][0]) progname = argv[0];
  LUAJIT_VERSION_SYM();  /* linker-enforced version check */
  script = collectargs(argv, &flags);
  if (script < 0) {  /* invalid args? */
    print_usage();
    s->status = 1;
    return 0;
  }
  if ((flags & FLAGS_NOENV)) {
    lua_pushboolean(L, 1);
    lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
  }
  lua_gc(L, LUA_GCSTOP, 0);  /* stop collector during initialization */
  luaL_openlibs(L);  /* open libraries */
  s->status = tvm_loadbufferx(L, luaJIT_BC_op, luaJIT_BC_op_SIZE, "op", "b")
           || docall(L, 0, 1);
  if (s->status != 0) return 0;
  s->status = tvm_loadbufferx(L, luaJIT_BC_parse, luaJIT_BC_parse_SIZE, "parse", "b")
           || docall(L, 0, 1);
  if (s->status != 0) return 0;
  s->status = tvm_loadbufferx(L, luaJIT_BC_lunokhod, luaJIT_BC_lunokhod_SIZE, "lunokhod", "b")
           || docall(L, 0, 1);
  if (s->status != 0) return 0;
  lua_gc(L, LUA_GCRESTART, -1);
  if (!(flags & FLAGS_NOENV)) {
    s->status = handle_luainit(L);
    if (s->status != 0) return 0;
  }
  if ((flags & FLAGS_VERSION)) print_version();
  s->status = runargs(L, argv, (script > 0) ? script : s->argc);
  if (s->status != 0) return 0;
  if (script) {
    s->status = handle_script(L, argv, script);
    if (s->status != 0) return 0;
  }
  if ((flags & FLAGS_INTERACTIVE)) {
    print_jit_status(L);
    dotty(L);
  } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
    if (lua_stdin_is_tty()) {
      print_version();
      print_jit_status(L);
      dotty(L);
    } else {
      dofile(L, NULL);  /* executes stdin as a file */
    }
  }
  return 0;
}
Example #20
0
int main (int argc, const char * argv[]) {

  if (argc != 2) {
    printf("Usage: %s filename\n",argv[0]);
    return 1;
  }

  dofile(argv[1]);

  return 0;
}
Example #21
0
int
main(int argc, char **argv)
{
  freopen("/tmp/scylla.log", "a+", stderr);

  if (argc<3 || argc>4)
    {
      printf("Usage: %s directory password [ssl-key]\n"
	     "\tRun Scylla (this here) from inetd.\n"
	     "\tScylla assumes that Charybdis feeds a file [with SSL].\n"
	     "\tScylla writes the file into the given directory.\n"
	     "\tMissing sub-directories are created as needed.\n"
	     "\tExisting files are renamed.\n", argv[0]);
      return 1;
    }

  if (chdir(argv[1]))
    ex("chdir");

  sock	= 0;

#ifndef NO_SSL
  tino_ssl_server((argc>3 ? argv[3] : "/etc/scylla.pem"));
#endif

  alarm_init(30,10);

  if (sread_match(argv[2], 0))
    ex("auth fail");

  swrite("scylla " VERSION);

  do
    {
      char	*name;

      name	= sread();
      if (!strcmp(name, "..") || !strncmp(name, "../", 3) ||
	  *name=='/' || strstr(name, "/../"))
	ex("- illegal filename");

      dofile(name);
      free(name);

    }
  while (!sread_match("m", 0));

#ifndef NO_SSL
  tino_ssl_close();
#endif
  return 0;
}
Example #22
0
static int handle_luainit (lua_State *L) {
  const char *name = "=" LUA_INITVERSION;
  const char *init = getenv(name + 1);
  if (init == NULL) {
    name = "=" LUA_INIT;
    init = getenv(name + 1);  /* try alternative name */
  }
  if (init == NULL) return LUA_OK;
  else if (init[0] == '@')
    return dofile(L, init+1);
  else
    return dostring(L, init, name);
}
Example #23
0
bool ScriptBase::defaultInti( const char *path )
{
    _L = luaL_newstate();
    if (_L == NULL)
      return false;
    luaL_openlibs( _L );

    lua_tinker::init(_L); //support 64
    _path = path;
    dofile(path);

    return true;
}
Example #24
0
static int handle_luainit (lua_State *L) {
  const char *name = "=" LUA_INITVERSION;
  const char *init = NULL;
  if (init == NULL) {
    name = "=" LUA_INIT;
	init = NULL;
  }
  if (init == NULL) return LUA_OK;
  else if (init[0] == '@')
    return dofile(L, init+1);
  else
    return dostring(L, init, name);
}
Example #25
0
int main(int argc, char *argv[])
{
	if(argc<2)
		return 0;
	l = lua_newstate(&alloc, NULL);
	lua_atpanic(l, &panic);
	luaL_openlibs(l);
	luaL_dostring(l,"math.randomseed(os.time())\n\
			 dofile('derp.lua')\n\
			 dofile('tableSave.lua')\n\
			 cashList = table.load('plugins/gameUsers.txt')\n\
			 table.load, table.save = nil\n\
			 debug,loadfile,module,require,dofile,package,os.remove,os.tmpname,os.rename,os.execute,os.getenv,string.dump=nil\n\
			 io={write=io.write}\n\
		");
	const char *h = argv[1];
	char *code = (char*)malloc(strlen(h)/2+1);
	char *c = code;
	for(;*h && h[1];h+=2)
	{
		*(c++) = (*h - 'A') * 16 + (h[1] - 'A');
	}
	*c = 0;
	if (luaL_loadbuffer(l, code, strlen(code), "@bot"))
	{
		printf("syntax error: %s\n", lua_tostring(l, -1));
		return 0;
	}
	pthread_t th;
	pthread_create(&th, NULL, &thread, NULL);
#ifdef WIN32
	Sleep(500);
#else
	sleep(1);
#endif
	pthread_cancel(th);
	printf("time limit exceeded\n");
}
Example #26
0
static int handle_luainit(lua_State *L)
{
#if LJ_TARGET_CONSOLE
  const char *init = NULL;
#else
  const char *init = getenv(LUA_INIT);
#endif
  if (init == NULL)
    return 0;  /* status OK */
  else if (init[0] == '@')
    return dofile(L, init+1);
  else
    return dostring(L, init, "=" LUA_INIT);
}
Example #27
0
File: elua.c Project: indie21/elua
static ERL_NIF_TERM
evaluate_msg(msg_t *msg, worker_t *w)
{
    switch(msg->type) {
    case msg_newstate:
        return newstate(msg->env, msg->hold_env);
    case msg_dofile:
        return dofile(msg->env, msg->res->L, msg->arg1);
    case msg_gencall:
        return gencall(msg->env, msg->res->L, msg->arg1, msg->arg2, msg->arg3);
    default:
        return make_error_tuple(msg->env, "invalid_command");
    }
}
Example #28
0
File: elua.c Project: indie21/elua
static ERL_NIF_TERM
elua_dofile_sync(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    elua_t *res;

    if(argc != 2) {
        return enif_make_badarg(env);
    }

    // first arg: res
    if(!enif_get_resource(env, argv[0], RES_SYNC, (void**) &res)) {
        return enif_make_badarg(env);
    }

    return dofile(env,res->L, argv[1]);
}
Example #29
0
static int handle_luainit (lua_State *L) {
  const char *name = "=" LUA_INITVERSION;
  // getenv not supported on Windows Store
  //const char *init = getenv(name + 1);
  const char *init = NULL;
  if (init == NULL) {
    name = "=" LUA_INIT;
	// getenv not supported on Windows Store
	//init = getenv(name + 1);  /* try alternative name */
    init = NULL;  /* try alternative name */
  }
  if (init == NULL) return LUA_OK;
  else if (init[0] == '@')
    return dofile(L, init+1);
  else
    return dostring(L, init, name);
}
Example #30
0
void
main(int argc, char **argv)
{
    struct status st;

    signal(SIGPIPE, SIG_IGN);
    signal(SIGALRM, timeout);

    if (argc < 2) {
        printf("checkweb, copyright (c) 1997  Dustin Sallings\n"
               "$Id: checkweb.c,v 1.9 1998/11/10 18:35:38 dustin Exp $\n");
        printf("Error, argument required.  Usage:\n%s filename\n"
               "Where filename is the file containing the url list.\n",
               argv[0]);
        exit(0);
    }
    dofile(argv[1]);
}