本文整理汇总了C++中dolibrary函数的典型用法代码示例。如果您正苦于以下问题:C++ dolibrary函数的具体用法?C++ dolibrary怎么用?C++ dolibrary使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dolibrary函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runargs
static int runargs (lua_State *L, char **argv, int n) {
int i;
for (i = 1; i < n; i++) {
if (argv[i] == NULL) continue;
lua_assert(argv[i][0] == '-');
switch (argv[i][1]) { /* option */
case 'e': {
const char *chunk = argv[i] + 2;
if (*chunk == '\0') chunk = argv[++i];
lua_assert(chunk != NULL);
if (dostring(L, chunk, "=(command line)") != 0)
return 1;
break;
}
case 'l': {
const char *filename = argv[i] + 2;
if (*filename == '\0') filename = argv[++i];
lua_assert(filename != NULL);
if (dolibrary(L, filename))
return 1; /* stop if file fails */
break;
}
default: break;
}
}
return 0;
}
示例2: runargs
static int runargs (LUA_State *L, char **argv, int n) {
int i;
for (i = 1; i < n; i++) {
LUA_assert(argv[i][0] == '-');
switch (argv[i][1]) { /* option */
case 'e': {
const char *chunk = argv[i] + 2;
if (*chunk == '\0') chunk = argv[++i];
LUA_assert(chunk != NULL);
if (dostring(L, chunk, "=(COMMAND LINE)") != LUA_OK)
return 0;
break;
}
case 'l': {
const char *filename = argv[i] + 2;
if (*filename == '\0') filename = argv[++i];
LUA_assert(filename != NULL);
if (dolibrary(L, filename) != LUA_OK)
return 0; /* stop if file fails */
break;
}
default: break;
}
}
return 1;
}
示例3: pmain
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 */
gsl_shell_openlibs(L);
lua_gc(L, LUA_GCRESTART, -1);
dolibrary (L, "gslext");
s->keep_windows = 1;
if (!(flags & FLAGS_NOENV)) {
s->status = handle_luainit(L);
if (s->status != 0) return 0;
}
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);
s->keep_windows = 0;
} else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
if (lua_stdin_is_tty()) {
print_version();
print_jit_status(L);
print_help_message();
dotty(L);
s->keep_windows = 0;
} else {
dofile(L, NULL); /* executes stdin as a file */
}
}
return 0;
}
示例4: runargs
/*
** Processes options 'e' and 'l', which involve running Lua code.
** Returns 0 if some code raises an error.
*/
static int runargs (lua_State *L, char **argv, int n) {
int i;
for (i = 1; i < n; i++) {
int option = argv[i][1];
lua_assert(argv[i][0] == '-'); /* already checked */
if (option == 'e' || option == 'l') {
int status;
const char *extra = argv[i] + 2; /* both options need an argument */
if (*extra == '\0') extra = argv[++i];
lua_assert(extra != NULL);
status = (option == 'e')
? dostring(L, extra, "=(command line)")
: dolibrary(L, extra);
if (status != LUA_OK) return 0;
}
}
return 1;
}
示例5: runargs
static int runargs(lua_State *L, char **argv, int n)
{
int i;
for (i = 1; i < n; i++) {
if (argv[i] == NULL) continue;
lua_assert(argv[i][0] == '-');
switch (argv[i][1]) { /* option */
case 'e': {
const char *chunk = argv[i] + 2;
if (*chunk == '\0') chunk = argv[++i];
lua_assert(chunk != NULL);
if (dostring(L, chunk, "=(command line)") != 0)
return 1;
break;
}
case 'l': {
const char *filename = argv[i] + 2;
if (*filename == '\0') filename = argv[++i];
lua_assert(filename != NULL);
if (dolibrary(L, filename))
return 1; /* stop if file fails */
break;
}
case 'j': { /* LuaJIT extension */
const char *cmd = argv[i] + 2;
if (*cmd == '\0') cmd = argv[++i];
lua_assert(cmd != NULL);
if (dojitcmd(L, cmd))
return 1;
break;
}
case 'O': /* LuaJIT extension */
if (dojitopt(L, argv[i] + 2))
return 1;
break;
case 'b': /* LuaJIT extension */
return dobytecode(L, argv+i);
default:
break;
}
}
return 0;
}
示例6: pmain
static int pmain(lua_State *L)
{
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
globalL = L;
lua_gc(L, LUA_GCSTOP, 0);
luaL_openlibs(L);
lua_gc(L, LUA_GCRESTART, 0);
find_local_libbcc(L);
s->status = dolibrary(L, "bcc", 0);
if (s->status)
return 0;
lua_pushstring(L, progname);
lua_setglobal(L, "BCC_STANDALONE_NAME");
pushargv(L, s->argv, s->argc, 1);
lua_setglobal(L, "arg");
s->status = report(L, docall(L, 0, 1));
return 0;
}
示例7: pmain
static int pmain(lua_State *L)
{
struct Smain *s = &smain;
char **argv = s->argv;
int argn;
int flags = 0;
globalL = L;
if (argv[0] && argv[0][0]) progname = argv[0];
LUAJIT_VERSION_SYM(); /* Linker-enforced version check. */
argn = collectargs(argv, &flags);
if (argn < 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");
}
/* Set MAD env _before_ libraries are open. */
mad_setenv(L, flags & FLAGS_NOENV);
/* Stop collector during library initialization. */
lua_gc(L, LUA_GCSTOP, 0);
luaL_openlibs(L);
mad_openlibs(L);
lua_gc(L, LUA_GCRESTART, -1);
createargtable(L, argv, s->argc, argn);
if (!(flags & FLAGS_NOENV)) {
s->status = handle_luainit(L);
if (s->status != LUA_OK) return 0;
}
/* MAD section. */
mad_setsig();
mad_regfunc();
if ((flags & FLAGS_MADENV))
dolibrary(L, "madl_main");
if (!(flags & FLAGS_NOENV)) {
s->status = handle_madinit(L);
if (s->status != LUA_OK) return 0;
}
if ((flags & FLAGS_VERSION)) print_version();
s->status = runargs(L, argv, argn);
if (s->status != LUA_OK) return 0;
if (s->argc > argn) {
s->status = handle_script(L, argv + argn);
if (s->status != LUA_OK) return 0;
}
if ((flags & FLAGS_INTERACTIVE)) {
(void)print_jit_status;
dotty(L);
} else if (s->argc == argn && !(flags & FLAGS_EXEC)) {
if (lua_stdin_is_tty()) {
(void)print_version;
(void)print_jit_status;
dotty(L);
} else {
dofile(L, NULL); /* Executes stdin as a file. */
}
}
return 0;
}
示例8: handle_argv
static int handle_argv (lua_State *L, int argc, char **argv, int *interactive) {
if (argv[1] == NULL) { /* no arguments? */
*interactive = 0;
if (lua_stdin_is_tty())
dotty(L);
else
dofile(L, NULL); /* executes stdin as a file */
}
else { /* other arguments; loop over them */
int i;
for (i = 1; argv[i] != NULL; i++) {
if (argv[i][0] != '-') break; /* not an option? */
switch (argv[i][1]) { /* option */
case '-': { /* `--' */
if (argv[i][2] != '\0') {
print_usage();
return 1;
}
i++; /* skip this argument */
goto endloop; /* stop handling arguments */
}
case '\0': {
clearinteractive(interactive);
dofile(L, NULL); /* executes stdin as a file */
break;
}
case 'i': {
*interactive = 2; /* force interactive mode after arguments */
break;
}
case 'v': {
clearinteractive(interactive);
print_version();
break;
}
case 'e': {
const char *chunk = argv[i] + 2;
clearinteractive(interactive);
if (*chunk == '\0') chunk = argv[++i];
if (chunk == NULL) {
print_usage();
return 1;
}
if (dostring(L, chunk, "=(command line)") != 0)
return 1;
break;
}
case 'l': {
const char *filename = argv[i] + 2;
if (*filename == '\0') filename = argv[++i];
if (filename == NULL) {
print_usage();
return 1;
}
if (dolibrary(L, filename))
return 1; /* stop if file fails */
break;
}
default: {
clearinteractive(interactive);
print_usage();
return 1;
}
}
} endloop:
if (argv[i] != NULL) {
int status;
const char *filename = argv[i];
int narg = getargs(L, argc, argv, i); /* collect arguments */
lua_setglobal(L, "arg");
clearinteractive(interactive);
status = luaL_loadfile(L, filename);
lua_insert(L, -(narg+1));
if (status == 0)
status = docall(L, narg, 0);
else
lua_pop(L, narg);
return report(L, status);
}
}
return 0;
}