u_long setjobdirectorysticky( const char *value) /* I */ { int enable; if ((enable = setbool(value)) != -1) MOMJobDirStickySet = enable; return(1); }
/* Subroutine for setting and displaying bit values */ int bitcmd( uint *bits, uint mask, char *label, int argc, char *argv[]) { int doing = (*bits & mask); int result = setbool( &doing, label, argc, argv ); if ( !result ) { if ( doing ) *bits |= mask; else *bits &= ~mask; } return result; }
bool Config::getbool( std::string item, bool defaultvalue, bool add ) { bool returnvalue = defaultvalue; dictionaryiterator itemiterator = m_dictionary.find( item ); if( itemiterator == m_dictionary.end()) { if( add ) setbool( item, defaultvalue ); } else { trim( itemiterator->second ); if( iequals( itemiterator->second, std::string( "true" )) || iequals( itemiterator->second, std::string( "yes" )) || iequals( itemiterator->second, std::string( "1" ))) { returnvalue = true; } else if( iequals( itemiterator->second, std::string( "false" )) || iequals( itemiterator->second, std::string( "no" )) || iequals( itemiterator->second, std::string( "0" ))) { returnvalue = false; } else { returnvalue = defaultvalue; } } return( returnvalue ); }
int Canvas::_flush(lua_State *l) { if (!lua_istable(l, 1)) return luaL_error(l, "canvas expected as first argument"); // clear key events keys_down.clear(); keys_up.clear(); glfwSwapBuffers(); glfwSleep(0.005); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // if (!_canvas->view.is2d) glLoadIdentity(); // set the game time double time = glfwGetTime(); lua_getfield(l, 1, "time"); double old = luaL_checknumber(l, -1); lua_pop(l, 1); setnumber("time" , time); setnumber("dt" , time - old); int x, y; double cx, cy; // canvas mouse coordinates glfwGetMousePos(&x, &y); Viewport &view = _canvas->view; if (view.is2d) { double vwidth = view.right - view.left; double vheight = view.bottom - view.top; cx = view.left + (x * vwidth / _canvas->width()); cy = view.top + (y * vheight / _canvas->height()); } else { cx = (double)x; cy = (double)y; } // update the mouse point lua_getfield(l, 1, "mouse"); setnumber("x", cx); setnumber("y", cy); setbool("left", glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT)); setbool("right", glfwGetMouseButton(GLFW_MOUSE_BUTTON_RIGHT)); lua_getfield(l, 1, "input"); float axis[2]; glfwGetJoystickPos(GLFW_JOYSTICK_1, axis, 2); setnumber("xaxis", axis[0]); setnumber("yaxis", axis[1]); setbool("left", glfwGetKey(GLFW_KEY_LEFT)); setbool("right", glfwGetKey(GLFW_KEY_RIGHT)); setbool("up", glfwGetKey(GLFW_KEY_UP)); setbool("down", glfwGetKey(GLFW_KEY_DOWN)); setbool("a", glfwGetKey('Q')); setbool("b", glfwGetKey('W')); lua_pushboolean(l, glfwGetWindowParam(GLFW_OPENED) > 0); return 1; }
/** * create a new canvas * args: width, height, [title] */ int Canvas::_new(lua_State *l) { const char *title = "Aroma"; int width = luaL_checkint(l, 2); int height = luaL_checkint(l, 3); if (lua_gettop(l) > 3) { title = luaL_checkstring(l, 4); } GLContext* context = new GLFWContext(width, height, title); if (!context->make_current()) { return luaL_error(l, "fatal error: failed to open window"); } _canvas = new Canvas(context); Viewport &view = _canvas->view; lua_newtable(l); // functions setfunction("run", Canvas::_run); setfunction("rect", Canvas::_rect); setfunction("line", Canvas::_line); setfunction("viewport", Canvas::_viewport); setfunction("view3d", Canvas::_view3d); setfunction("look", Canvas::_look); setfunction("strip", Canvas::_strip); setfunction("rotate", Canvas::_rotate); setfunction("scale", Canvas::_scale); setfunction("translate", Canvas::_translate); setfunction("noise", Canvas::_noise); setfunction("save", Canvas::_save); setfunction("restore", Canvas::_restore); setfunction("getTime", Canvas::_getTime); setfunction("clear_color", Canvas::_clearColor); setfunction("clear", Canvas::_clear); setfunction("flush", Canvas::_flush); setfunction("set_mouse", Canvas::_setMouse); setfunction("hide_mouse", Canvas::_hideMouse); setfunction("show_mouse", Canvas::_showMouse); setfunction("key", Canvas::_key); setfunction("key_up", Canvas::_key_up); setfunction("key_down", Canvas::_key_down); // load libraries AromaRegister *lib = aroma_libs; while (*lib) { (*lib++)(l); } // properties setnumber("dt", 0); setnumber("time", glfwGetTime()); setnumber("width", view.getWidth()); setnumber("height", view.getHeight()); // mouse input lua_newtable(l); setint("x", 0); setint("y", 0); setbool("left", false); setbool("right", false); lua_setfield(l, -2, "mouse"); // create the input table lua_newtable(l); setnumber("xaxis", 0); setnumber("yaxis", 0); setbool("left", false); setbool("right", false); setbool("up", false); setbool("down", false); setbool("a", false); setbool("b", false); setbool("c", false); setbool("d", false); setbool("start", false); setbool("select", false); setbool("l", false); setbool("r", false); lua_setfield(l, -2, "input"); // the keys push_key_table(l); lua_setfield(l, -2, "keys"); // create meta table lua_newtable(l); setfunction("__call", _call); lua_setmetatable(l, -2); return 1; }
int main(int argc, char **argv) { size_t rc; int clflag; /* holds codes for command line flags */ if (argc < 2) usage(); if (is_selinux_enabled() <= 0) { fputs("setsebool: SELinux is disabled.\n", stderr); return 1; } while (1) { clflag = getopt(argc, argv, "PN"); if (clflag == -1) break; switch (clflag) { case 'P': permanent = 1; break; case 'N': reload = 0; break; default: usage(); break; } } if (argc - optind < 1) { fprintf(stderr, "Error: boolean name required\n"); usage(); } /* Check to see which way we are being called. If a '=' is passed, we'll enforce the list syntax. If not we'll enforce the original syntax for backward compatibility. */ if (strchr(argv[optind], '=') == 0) { int len; char *bool_list[1]; if ((argc - optind) != 2) usage(); /* Add 1 for the '=' */ len = strlen(argv[optind]) + strlen(argv[optind + 1]) + 2; bool_list[0] = (char *)malloc(len); if (bool_list[0] == 0) { fputs("Out of memory - aborting\n", stderr); return 1; } snprintf(bool_list[0], len, "%s=%s", argv[optind], argv[optind + 1]); rc = setbool(bool_list, 0, 1); free(bool_list[0]); } else rc = setbool(argv, optind, argc); return rc; }