本文整理汇总了C++中setpath函数的典型用法代码示例。如果您正苦于以下问题:C++ setpath函数的具体用法?C++ setpath怎么用?C++ setpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: luaopen_package
LUALIB_API int luaopen_package(lua_State *L)
{
int i;
int noenv;
luaL_newmetatable(L, "_LOADLIB");
lj_lib_pushcf(L, lj_cf_package_unloadlib, 1);
lua_setfield(L, -2, "__gc");
luaL_register(L, LUA_LOADLIBNAME, package_lib);
lua_pushvalue(L, -1);
lua_replace(L, LUA_ENVIRONINDEX);
lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0);
for (i = 0; package_loaders[i] != NULL; i++) {
lj_lib_pushcf(L, package_loaders[i], 1);
lua_rawseti(L, -2, i+1);
}
lua_setfield(L, -2, "loaders");
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
noenv = lua_toboolean(L, -1);
lua_pop(L, 1);
setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT, noenv);
setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT, noenv);
lua_pushliteral(L, LUA_PATH_CONFIG);
lua_setfield(L, -2, "config");
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16);
lua_setfield(L, -2, "loaded");
luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 4);
lua_setfield(L, -2, "preload");
lua_pushvalue(L, LUA_GLOBALSINDEX);
luaL_register(L, NULL, package_global);
lua_pop(L, 1);
return 1;
}
示例2: luaopen_package
LUAMOD_API int luaopen_package (lua_State *L) {
/* create table CLIBS to keep track of loaded C libraries */
luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS);
lua_createtable(L, 0, 1); /* metatable for CLIBS */
lua_pushcfunction(L, gctm);
lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */
lua_setmetatable(L, -2);
/* create `package' table */
luaL_newlib(L, pk_funcs);
createsearcherstable(L);
#if defined(LUA_COMPAT_LOADERS)
lua_pushvalue(L, -1); /* make a copy of 'searchers' table */
lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */
#endif
lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */
/* set field 'path' */
setpath(L, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT);
/* set field 'cpath' */
setpath(L, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT);
/* store config information */
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
lua_setfield(L, -2, "config");
/* set field `loaded' */
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
lua_setfield(L, -2, "loaded");
/* set field `preload' */
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
lua_setfield(L, -2, "preload");
lua_pushglobaltable(L);
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
lua_pop(L, 1); /* pop global table */
return 1; /* return 'package' table */
}
示例3: ngx_http_lua_new_state
lua_State *
ngx_http_lua_new_state(ngx_conf_t *cf, ngx_http_lua_main_conf_t *lmcf)
{
lua_State *L = luaL_newstate();
if(L == NULL) {
return NULL;
}
luaL_openlibs(L);
lua_getglobal(L, "package");
if (! lua_istable(L, -1)) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"the \"package\" table does not exist");
return NULL;
}
if (lmcf->lua_path.len != 0) {
const char *old_path;
const char *new_path;
lua_getfield(L, -1, "path"); /* get original package.path */
old_path = lua_tostring(L, -1);
lua_pushlstring(L, (char *) lmcf->lua_path.data, lmcf->lua_path.len);
new_path = lua_tostring(L, -1);
setpath(L, -3, "path", new_path, old_path);
lua_pop(L, 2);
}
if (lmcf->lua_cpath.len != 0) {
const char *old_cpath;
const char *new_cpath;
lua_getfield(L, -1, "cpath"); /* get original package.cpath */
old_cpath = lua_tostring(L, -1);
lua_pushlstring(L, (char *) lmcf->lua_cpath.data, lmcf->lua_cpath.len);
new_cpath = lua_tostring(L, -1);
setpath(L, -3, "cpath", new_cpath, old_cpath);
lua_pop(L, 2);
}
lua_remove(L, -1); /* remove the "package" table */
init_ngx_lua_registry(L);
init_ngx_lua_globals(L);
return L;
}
示例4: getlistevalue
char *iscommande(t_env **env, char *cmd)
{
char *path;
char **tab_path;
int freepath;
char *value;
freepath = 0;
path = NULL;
value = NULL;
tab_path = NULL;
path = getlistevalue(env, "PATH");
if (path)
tab_path = ft_strsplit(path, ':');
else
{
tab_path = setdefaultpath();
freepath = 1;
}
value = setpath(tab_path, cmd);
if (freepath == 0)
ft_freetab(tab_path);
else if (freepath == 1)
free(tab_path);
return (value);
}
示例5: switch
int myclianttest::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: readyRead(); break;
case 1: bytesWritten((*reinterpret_cast< qint64(*)>(_a[1]))); break;
case 2: disconnected(); break;
case 3: list((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 4: connected(); break;
case 5: test(); break;
case 6: mycomputer((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 7: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
case 8: doubleClickedServer((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
case 9: setpath((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 10: getpath(); break;
case 11: servercomputer((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
case 12: serverfiledown((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
case 13: getserverpath(); break;
case 14: download(); break;
case 15: Serverclicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
case 16: gotomotherpath(); break;
case 17: gotoservermotherpath(); break;
default: ;
}
_id -= 18;
}
return _id;
}
示例6: luaopen_package
LUALIB_API int luaopen_package (lua_State *L) {
int i;
#if 0
/* create new type _LOADLIB */
luaL_newmetatable(L, "_LOADLIB");
lua_pushcfunction(L, gctm);
lua_setfield(L, -2, "__gc");
#endif
/* create `package' table */
luaL_register(L, LUA_LOADLIBNAME, pk_funcs);
#if 0
#if defined(LUA_COMPAT_LOADLIB)
lua_getfield(L, -1, "loadlib");
lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
#endif
#endif
lua_pushvalue(L, -1);
lua_replace(L, LUA_ENVIRONINDEX);
/* create `loaders' table */
lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
/* fill it with pre-defined loaders */
for (i=0; loaders[i] != NULL; i++) {
lua_pushcfunction(L, loaders[i]);
lua_rawseti(L, -2, i+1);
}
lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */
#if 0
setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */
setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
/* store config information */
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
LUA_EXECDIR "\n" LUA_IGMARK);
lua_setfield(L, -2, "config");
#endif
/* set field `loaded' */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2);
lua_setfield(L, -2, "loaded");
/* set field `preload' */
lua_newtable(L);
lua_setfield(L, -2, "preload");
lua_pushvalue(L, LUA_GLOBALSINDEX);
luaL_register(L, NULL, ll_funcs); /* open lib into global table */
lua_pop(L, 1);
return 1; /* return 'package' table */
}
示例7: luaopen_upackage
LUAMOD_API int luaopen_upackage(lua_State *L)
{
int i;
/* create new type _LOADLIB */
luaL_newmetatable(L, "_LOADLIB");
lua_pushcfunction(L, gctm);
lua_setfield(L, -2, "__gc");
/* create `package' table */
luaL_newlib(L, pk_funcs);
/* create 'searchers' table */
lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0);
/* fill it with pre-defined searchers */
for(i=0; searchers[i] != NULL; i++)
{
lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */
lua_pushcclosure(L, searchers[i], 1);
lua_rawseti(L, -2, i+1);
}
#if defined(LUA_COMPAT_LOADERS)
lua_pushvalue(L, -1); /* make a copy of 'searchers' table */
lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */
#endif
lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */
/* set field 'path' */
setpath(L, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT);
/* set field 'cpath' */
setpath(L, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT);
/* store config information */
push_utf8_string(L, LUA_DIRSEP L"\n" LUA_PATH_SEP L"\n" LUA_PATH_MARK L"\n"
LUA_EXEC_DIR L"\n" LUA_IGMARK L"\n", -1);
lua_setfield(L, -2, "config");
/* set field `loaded' */
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
lua_setfield(L, -2, "loaded");
/* set field `preload' */
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
lua_setfield(L, -2, "preload");
lua_pushglobaltable(L);
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
lua_pop(L, 1); /* pop global table */
return 1; /* return 'package' table */
}
示例8: pbap_reset_path
/* should only be called inside pbap_set_path */
static void pbap_reset_path(struct pbap_data *pbap)
{
GObex *obex = obc_session_get_obex(pbap->session);
if (!pbap->path)
return;
setpath(obex, pbap->path, 3, NULL, NULL);
}
示例9: luaopen_package
LUAMOD_API int luaopen_package (lua_State *L) {
createclibstable(L);
luaL_newlib(L, pk_funcs); /* create 'package' table */
createsearcherstable(L);
/* set paths */
setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
/* store config information */
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
lua_setfield(L, -2, "config");
/* set field 'loaded' */
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
lua_setfield(L, -2, "loaded");
/* set field 'preload' */
luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
lua_setfield(L, -2, "preload");
lua_pushglobaltable(L);
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
lua_pop(L, 1); /* pop global table */
return 1; /* return 'package' table */
}
示例10: luaopen_package
LUAMOD_API int luaopen_package (lua_State *L) {
int i;
/* create new type _LOADLIB */
luaL_newmetatable(L, "_LOADLIB");
lua_pushcfunction(L, gctm);
lua_setfield(L, -2, "__gc");
/* create `package' table */
luaL_newlib(L, pk_funcs);
/* create `loaders' table */
lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
/* fill it with pre-defined loaders */
for (i=0; loaders[i] != NULL; i++) {
lua_pushvalue(L, -2); /* set 'package' as upvalue for all loaders */
lua_pushcclosure(L, loaders[i], 1);
lua_rawseti(L, -2, i+1);
}
lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */
/* set field 'path' */
setpath(L, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT);
/* set field 'cpath' */
setpath(L, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT);
/* store config information */
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
lua_setfield(L, -2, "config");
/* set field `loaded' */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED");
lua_setfield(L, -2, "loaded");
/* set field `preload' */
luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
lua_setfield(L, -2, "preload");
lua_pushglobaltable(L);
lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */
luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */
lua_pop(L, 1); /* pop global table */
return 1; /* return 'package' table */
}
示例11: pbap_set_path
static int pbap_set_path(struct pbap_data *pbap, const char *path)
{
GObex *obex = obc_session_get_obex(pbap->session);
if (!path)
return G_OBEX_RSP_BAD_REQUEST;
if (pbap->path != NULL && g_str_equal(pbap->path, path))
return 0;
if (!setpath(obex, path, 3, pbap_setpath_cb, pbap))
return G_OBEX_RSP_INTERNAL_SERVER_ERROR;
g_free(pbap->path);
pbap->path = g_strdup(path);
return G_OBEX_RSP_SUCCESS;
}
示例12: setpath
int Skin::load(char *name, bool quiet) {
char d[512];
setpath(name);
makepath(d,"colors.conf");
if (!Colors.load(d)) {
sprintf(d, "Skin[%s]: Cannot load colors.conf", name);
if (!quiet) MessageBox(NULL,d,"Error",MB_ICONERROR | MB_OK);
return 0;
}
SDL_Surface *s;
pngLoad("toolbar.png");
bmToolbar = new Bitmap( s , true );
pngLoad("load.png");
bmLoad = new Bitmap( s , true );
pngLoad("save.png");
bmSave = new Bitmap( s , true );
pngLoad("buttons.png");
bmButtons = new Bitmap( s , true );
pngLoad("about.png");
bmAbout = new Bitmap( s , true );
if (640 != CONSOLE_WIDTH && 480 != CONSOLE_HEIGHT) {
double xscale = (double)CONSOLE_WIDTH / 640;
double yscale = (double)CONSOLE_HEIGHT / 480;
Drawable ss( zoomSurface(bmAbout->surface, xscale, yscale ,SMOOTHING_ON) , false );
// S->copy(&ss,5,row(12));
SDL_FreeSurface( bmAbout->surface );
bmAbout->surface = ss.surface;
}
pngLoad("logo.png");
SDL_FreeSurface(s);
bmLogo = NULL;
makepath(d,"font.fnt");
if (font_load(d)) {
sprintf(d, "Skin[%s]: Cannot load font.fnt", name);
if (!quiet) MessageBox(NULL,d,"Error",MB_ICONERROR | MB_OK);
return 0;
}
return 1;
}
示例13: luaopen_fileio
int luaopen_fileio(lua_State *L, const char *parent) {
luaL_register(L, parent, fileiolib);
lua_pushcfunction(L, Lua_FS_dofile);
lua_setglobal(L, "dofile");
/* insert the custom PhysFS loader into the loaders table */
lua_getglobal(L, "table");
lua_getfield(L, -1, "insert");
lua_remove(L, -2);
lua_getglobal(L, "package");
lua_getfield(L, -1, "loaders");
lua_remove(L, -2);
lua_pushinteger(L, 2);
lua_pushcfunction(L, loader_PhysFS);
lua_call(L, 3, 0);
/* set field `scrupppath' */
lua_getglobal(L, "package");
setpath(L, "scrupppath", SCRUPP_PATH, SCRUPP_PATH_DEFAULT);
lua_remove(L, -1);
return 1;
}
示例14: setpath
Obstacle::Obstacle(SDL_Rect rect)
{
setpath(rect);
setpath2(rect);
setobstacle(rect);
}
示例15: dosetpath
/*ARGSUSED*/
void
dosetpath(Char **arglist, struct command *c)
{
extern char *getenv();
Char **pathvars, **cmdargs;
char **spaths, **cpaths, **cmds;
char *tcp;
unsigned int npaths, ncmds;
int i, sysflag;
pintr_disabled++;
cleanup_push(&pintr_disabled, disabled_cleanup);
/*
* setpath(3) uses stdio and we want 0, 1, 2 to work...
*/
if (!didfds) {
(void) dcopy(SHIN, 0);
(void) dcopy(SHOUT, 1);
(void) dcopy(SHDIAG, 2);
didfds = 1;
}
for (i = 1; arglist[i] && (arglist[i][0] != '-'); i++);
npaths = i - 1;
cmdargs = &arglist[i];
for (; arglist[i]; i++);
ncmds = i - npaths - 1;
if (npaths) {
sysflag = 0;
pathvars = &arglist[1];
}
else {
sysflag = 1;
npaths = (sizeof syspaths / sizeof *syspaths) - 1;
pathvars = syspaths;
}
/* note that npaths != 0 */
spaths = xmalloc(npaths * sizeof *spaths);
setzero(spaths, npaths * sizeof *spaths);
cpaths = xmalloc((npaths + 1) * sizeof *cpaths);
setzero(cpaths, (npaths + 1) * sizeof *cpaths);
cmds = xmalloc((ncmds + 1) * sizeof *cmds);
setzero(cmds, (ncmds + 1) * sizeof *cmds);
for (i = 0; i < npaths; i++) {
char *val = getenv(short2str(pathvars[i]));
if (val == NULL)
val = "";
spaths[i] = xmalloc((Strlen(pathvars[i]) + strlen(val) + 2) *
sizeof **spaths);
(void) strcpy(spaths[i], short2str(pathvars[i]));
(void) strcat(spaths[i], "=");
(void) strcat(spaths[i], val);
cpaths[i] = spaths[i];
}
for (i = 0; i < ncmds; i++) {
Char *val = globone(cmdargs[i], G_ERROR);/*FIXRESET*/
if (val == NULL)
goto abortpath;
cmds[i] = strsave(short2str(val));
}
if (setpath(cpaths, cmds, LOCALSYSPATH, sysflag, 1) < 0) {
abortpath:
if (spaths) {
for (i = 0; i < npaths; i++)
xfree(spaths[i]);
xfree(spaths);
}
xfree(cpaths);
if (cmds) {
for (i = 0; i < ncmds; i++)
xfree(cmds[i]);
xfree(cmds);
}
cleanup_until(&pintr_disabled);
donefds();
return;
}
for (i = 0; i < npaths; i++) {
Char *val, *name;
name = str2short(cpaths[i]);
for (val = str2short(cpaths[i]); val && *val && *val != '='; val++);
if (val && *val == '=') {
*val++ = '\0';
tsetenv(name, val);/*FIXRESET*/
//.........这里部分代码省略.........