ModuleEffects::ModuleEffects(uint32 typeID) : m_typeID( typeID ), m_Cached( false ) { m_typeID = 0; m_HighPower = m_MediumPower = m_LowPower = m_Cached = false; _populate(typeID); }
static void _populate(char *base, int *cnt, int max) { char buf[64], *p; int fd; while (*cnt < max) { int i = rand() % (sizeof(selectors)/sizeof(selectors[0])); switch (selectors[i]) { case S_FILE: /* Create a file */ snprintf(buf,sizeof buf,"%x",rand()); p = mystrcat(base,"/",buf); fd = open(p,O_WRONLY|O_CREAT|O_EXCL,0666); free(p); if (fd == -1) continue; snprintf(buf,sizeof buf,"%d", rand() % CLUSTER); write(fd,buf,strlen(buf)); close(fd); ++(*cnt); break; case S_DIR: /* Create a directory */ snprintf(buf,sizeof buf,"%x",rand()); p = mystrcat(base,"/",buf); fd = mkdir(p,0777); if (fd == 0) { ++(*cnt); _populate(p, cnt, max); } free(p); break; case S_END: return; } } }
KBJobListViewItem::KBJobListViewItem(KBJobListView *parent, AB_JOB *j) : QTreeWidgetItem(parent) , _job(j) { assert(j); _populate(); }
KBAccountListViewItem::KBAccountListViewItem(KBAccountListView *parent, AB_ACCOUNT *acc) : QTreeWidgetItem(parent) , _account(acc) { assert(acc); _populate(); }
char *populate(char *base, int max) { int cnt = 0; strcpy(base,"tmpdirXXXXXXX"); base = mkdtemp(base); if (base == NULL) return NULL; while (cnt < max) _populate(base,&cnt,max); return base; }
static Eina_Bool _weather_cb_check(void *data) { Instance *inst = data; EWeather_Data *e_data = eweather_data_current_get(inst->weather); _populate(e_data, inst->count); _populate(eweather_data_get(inst->weather, 1), (inst->count+1)%15); _populate(eweather_data_get(inst->weather, 2), (inst->count+2)%15); inst->count++; if(inst->count>15) inst->count = 0; eweather_plugin_update(inst->weather); ecore_timer_interval_set(inst->check_timer, 5); return EINA_TRUE; }
static void _test_simple(void) { static struct citizen_s citizens[] = { {"/", "", 0400}, {"/", "plop", 0600}, {"/", "plip", 0600}, {"/", "plup", 0600}, {"/", "plap", 0600}, {NULL, NULL, 0} }; gchar *basedir = g_strdup_printf("%s/try-%u", global_base, _next_id()); if (0 != g_mkdir_with_parents(basedir, 0700)) g_error("Try failure [%s] : (%d) %s", basedir, errno, strerror(errno)); _populate(basedir, citizens); _crawl(basedir); g_free(basedir); }
zpt::RESTServer::RESTServer(std::string _name, zpt::json _options) : __name(_name), __emitter( new zpt::RESTEmitter(_options)), __poll(new zpt::ZMQPoll(_options, __emitter)), __options(_options) { assertz(this->__options["zmq"]->ok() && this->__options["zmq"]->type() == zpt::JSArray && this->__options["zmq"]->arr()->size() != 0, "zmq settings (bind, type) must be provided in the configuration file", 500, 0); ((zpt::RESTEmitter*) this->__emitter.get())->poll(this->__poll); for (auto _definition : this->__options["zmq"]->arr()) { short int _type = zpt::str2type(_definition["type"]->str()); switch(_type) { case ZMQ_ROUTER_DEALER : { this->__router_dealer.push_back(this->__poll->bind(ZMQ_ROUTER_DEALER, _definition["bind"]->str())); break; } case ZMQ_PUB_SUB : { this->__pub_sub.push_back(this->__poll->bind(ZMQ_XPUB_XSUB, _definition["bind"]->str())); /*std::string _connect(_definition["bind"]->str()); zpt::replace(_connect, "*", ((std::string) this->__options["host"])); this->__poll->bind(ZMQ_PUB_SUB, _connect)->in().setsockopt(ZMQ_SUBSCRIBE, "/", 1);*/ break; } default : { this->__poll->bind(_type, _definition["bind"]->str()); } } } if (this->__options["rest"]["modules"]->ok()) { for (auto _i : this->__options["rest"]["modules"]->arr()) { std::string _lib_file("lib"); _lib_file.append((std::string) _i); _lib_file.append(".so"); if (_lib_file.length() > 6) { zlog(std::string("loading module '") + _lib_file + std::string("'"), zpt::notice); void *hndl = dlopen(_lib_file.data(), RTLD_NOW); if (hndl == nullptr) { zlog(std::string(dlerror()), zpt::error); } else { void (*_populate)(zpt::ev::emitter); _populate = (void (*)(zpt::ev::emitter)) dlsym(hndl, "restify"); _populate(this->__emitter); } } } } if (!!this->__options["rest"]["uploads"]["upload_controller"]) { /* * definition of handlers for the file upload controller * registered as a Controller */ this->__emitter->on(zpt::ev::Post, zpt::rest::url_pattern({ this->__emitter->version(), "files" }), [] (zpt::ev::performative _performative, std::string _resource, zpt::json _payload, zpt::ev::emitter _pool) -> zpt::json { return zpt::undefined; } ); /* * definition of handlers for the file upload removal controller * registered as a Controller */ this->__emitter->on(zpt::ev::Delete, zpt::rest::url_pattern({ this->__emitter->version(), "files", "(.+)" }), [] (zpt::ev::performative _performative, std::string _resource, zpt::json _payload, zpt::ev::emitter _pool) -> zpt::json { return zpt::undefined; } ); } }
int main(int argc, char *argv[]) { app_t app; int i; Evas_Object *o; ecore_init(); ecore_app_args_set(argc, (const char **)argv); ecore_evas_init(); edje_init(); edje_frametime_set(1.0 / 30.0); memset(&app, 0, sizeof(app)); app.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, WIDTH, HEIGHT); ecore_evas_data_set(app.ee, "app", &app); ecore_evas_title_set(app.ee, TITLE); ecore_evas_name_class_set(app.ee, WM_NAME, WM_CLASS); app.theme = THEME; for (i=1; i < argc; i++) if (strcmp (argv[i], "-fs") == 0) ecore_evas_fullscreen_set(app.ee, 1); else if (strncmp (argv[i], "-theme=", sizeof("-theme=") - 1) == 0) app.theme = argv[i] + sizeof("-theme=") - 1; else if (argv[i][0] != '-') app.infile = argv[i]; app.evas = ecore_evas_get(app.ee); app.edje_main = edje_object_add(app.evas); evas_data_attach_set(app.evas, &app); if (!edje_object_file_set(app.edje_main, app.theme, THEME_GROUP)) { fprintf(stderr, "Failed to load file \"%s\", part \"%s\".\n", app.theme, THEME_GROUP); return 1; } evas_object_move(app.edje_main, 0, 0); evas_object_resize(app.edje_main, WIDTH, HEIGHT); app.e_box = e_box_add(app.evas); e_box_orientation_set(app.e_box, 0); e_box_homogenous_set(app.e_box, 0); e_box_align_set(app.e_box, 0.0, 0.5); edje_object_part_swallow(app.edje_main, "contents_swallow", app.e_box); evas_object_show(app.edje_main); evas_object_show(app.e_box); ecore_evas_show(app.ee); _populate(&app); app.scroll.initial_delay_ms = 750; app.scroll.accel_ms = 600; setup_gui_list(&app); ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL); ecore_evas_callback_resize_set(app.ee, resize_cb); evas_object_event_callback_add(app.edje_main, EVAS_CALLBACK_KEY_DOWN, key_down, &app); evas_object_focus_set(app.edje_main, 1); o = edje_object_part_object_get(app.edje_main, "back_button"); evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, mouse_down_back_button, &app); ecore_main_loop_begin(); return 0; }