static void dumpOutput(const char *prefix, Display *dpy, int screen_idx, XRRScreenResources *resources, int outputIdx, RROutput output) { int i, j, primIdx=0; Window root = RootWindow(dpy, screen_idx); RROutput pxid = XRRGetOutputPrimary (dpy, root); int isPrim =0; if ( None != pxid && pxid == output ) { primIdx = i; isPrim = 1; } XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); fprintf(stderr, "%s: Output[%d]: id %#lx, crtx 0x%lX, name %s (%d), %lux%lu, ncrtc %d, nclone %d, nmode %d (preferred %d), primary %d\n", prefix, outputIdx, output, xrrOutputInfo->crtc, SAFE_STRING(xrrOutputInfo->name), xrrOutputInfo->nameLen, xrrOutputInfo->mm_width, xrrOutputInfo->mm_height, xrrOutputInfo->ncrtc, xrrOutputInfo->nclone, xrrOutputInfo->nmode, xrrOutputInfo->npreferred, isPrim); for(j=0; j<xrrOutputInfo->ncrtc; j++) { fprintf(stderr, "%s: Output[%d].Crtc[%d].id %#lx\n", prefix, i, j, xrrOutputInfo->crtcs[j]); } for(j=0; j<xrrOutputInfo->nclone; j++) { fprintf(stderr, "%s: Output[%d].Clones[%d].id %#lx\n", prefix, i, j, xrrOutputInfo->clones[j]); } for(j=0; j<xrrOutputInfo->nmode; j++) { fprintf(stderr, "%s: Output[%d].Mode[%d].id %#lx\n", prefix, i, j, xrrOutputInfo->modes[j]); } XRRFreeOutputInfo (xrrOutputInfo); }
static void dumpOutputs(const char *prefix, Display *dpy, XRRScreenResources *resources, int noutput, RROutput * outputs) { int i, j; fprintf(stderr, "%s %p: Output count %d\n", prefix, resources, noutput); for(i=0; i<noutput; i++) { RROutput output = outputs[i]; XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); fprintf(stderr, " Output[%d]: id %#lx, crtx 0x%X, name %s (%d), %lux%lu, ncrtc %d, .., nmode %d (preferred %d)\n", i, output, xrrOutputInfo->crtc, SAFE_STRING(xrrOutputInfo->name), xrrOutputInfo->nameLen, xrrOutputInfo->mm_width, xrrOutputInfo->mm_height, xrrOutputInfo->ncrtc, xrrOutputInfo->nmode, xrrOutputInfo->npreferred); for(j=0; j<xrrOutputInfo->nmode; j++) { fprintf(stderr, " Output[%d].Mode[%d].id %#lx\n", i, j, xrrOutputInfo->modes[j]); } XRRFreeOutputInfo (xrrOutputInfo); } }
VOID PrintSecurityObject( PLSA_SECURITY_OBJECT pObject, DWORD dwObjectNumber, DWORD dwObjectTotal, BOOLEAN bPBOutputMode ) { switch (pObject->type) { case LSA_OBJECT_TYPE_GROUP: if (!bPBOutputMode) { if (dwObjectTotal) { printf("Group object [%u of %u] (%s)\n", dwObjectNumber+1, dwObjectTotal, SAFE_STRING(pObject->pszObjectSid)); } else { printf("Group object [%u] (%s)\n", dwObjectNumber+1, SAFE_STRING(pObject->pszObjectSid)); } printf("============\n"); printf("Enabled: %s\n", pObject->enabled ? "yes" : "no"); printf("Distinguished name: %s\n", SAFE_STRING(pObject->pszDN)); printf("SAM account name: %s\n", SAFE_STRING(pObject->pszSamAccountName)); printf("NetBIOS domain name: %s\n", SAFE_STRING(pObject->pszNetbiosDomainName)); printf("Alias: %s\n", SAFE_STRING(pObject->groupInfo.pszAliasName)); printf("UNIX name: %s\n", SAFE_STRING(pObject->groupInfo.pszUnixName)); printf("GID: %lu\n", (unsigned long) pObject->groupInfo.gid); } else { if (dwObjectTotal && dwObjectNumber+1 < dwObjectTotal) { printf("%s\\%s, ", SAFE_STRING(pObject->pszNetbiosDomainName), SAFE_STRING(pObject->pszSamAccountName)); } else { printf("%s\\%s\n\n", SAFE_STRING(pObject->pszNetbiosDomainName), SAFE_STRING(pObject->pszSamAccountName)); } } break; case LSA_OBJECT_TYPE_USER: if (!bPBOutputMode) { if (dwObjectTotal) { printf("User object [%u of %u] (%s)\n", dwObjectNumber+1, dwObjectTotal, SAFE_STRING(pObject->pszObjectSid)); } else { printf("User object [%u] (%s)\n", dwObjectNumber+1, SAFE_STRING(pObject->pszObjectSid)); } printf("============\n"); printf("Enabled: %s\n", pObject->enabled ? "yes" : "no"); printf("Distinguished name: %s\n", SAFE_STRING(pObject->pszDN)); printf("SAM account name: %s\n", SAFE_STRING(pObject->pszSamAccountName)); printf("NetBIOS domain name: %s\n", SAFE_STRING(pObject->pszNetbiosDomainName)); if (pObject->userInfo.bIsGeneratedUPN) { printf("UPN (generated): %s\n", SAFE_STRING(pObject->userInfo.pszUPN)); } else { printf("UPN: %s\n", SAFE_STRING(pObject->userInfo.pszUPN)); } printf("Display Name: %s\n", SAFE_STRING(pObject->userInfo.pszDisplayName)); printf("Alias: %s\n", SAFE_STRING(pObject->userInfo.pszAliasName)); printf("UNIX name: %s\n", SAFE_STRING(pObject->userInfo.pszUnixName)); printf("GECOS: %s\n", SAFE_STRING(pObject->userInfo.pszGecos)); printf("Shell: %s\n", SAFE_STRING(pObject->userInfo.pszShell)); printf("Home directory: %s\n", SAFE_STRING(pObject->userInfo.pszHomedir)); printf("Windows home directory: %s\n", SAFE_STRING(pObject->userInfo.pszWindowsHomeFolder)); printf("Local windows home directory: %s\n", SAFE_STRING(pObject->userInfo.pszLocalWindowsHomeFolder)); printf("UID: %lu\n", (unsigned long) pObject->userInfo.uid); printf("Primary group SID: %s\n", SAFE_STRING(pObject->userInfo.pszPrimaryGroupSid)); printf("Primary GID: %lu\n", (unsigned long) pObject->userInfo.gid); if (pObject->userInfo.bIsAccountInfoKnown) { printf("Password expired: %s\n", pObject->userInfo.bPasswordExpired ? "yes" : "no"); printf("Password never expires: %s\n", pObject->userInfo.bPasswordNeverExpires ? "yes" : "no"); printf("Change password on next logon: %s\n", pObject->userInfo.bPromptPasswordChange ? "yes" : "no"); printf("User can change password: %s\n", pObject->userInfo.bUserCanChangePassword ? "yes" : "no"); printf("Account disabled: %s\n", pObject->userInfo.bAccountDisabled ? "yes" : "no"); printf("Account expired: %s\n", pObject->userInfo.bAccountExpired ? "yes" : "no"); printf("Account locked: %s\n", pObject->userInfo.bAccountLocked ? "yes" : "no"); } } else { if (dwObjectTotal && dwObjectNumber+1 < dwObjectTotal) { printf("%s\\%s, ", SAFE_STRING(pObject->pszNetbiosDomainName), SAFE_STRING(pObject->pszSamAccountName)); } else { printf("%s\\%s\n\n", SAFE_STRING(pObject->pszNetbiosDomainName), SAFE_STRING(pObject->pszSamAccountName)); } } break; default: printf("Unknown object (%s)\n", SAFE_STRING(pObject->pszObjectSid)); break; } }
/** * g_process_perform_supervise: * * Supervise process, returns only in the context of the daemon process, the * supervisor process exits here. **/ static void g_process_perform_supervise(void) { pid_t pid; gboolean first = TRUE, exited = FALSE; gchar proc_title[PROC_TITLE_SPACE]; struct sigaction sa; g_snprintf(proc_title, PROC_TITLE_SPACE, "supervising %s", process_opts.name); g_process_setproctitle(proc_title); memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; sigaction(SIGHUP, &sa, NULL); while (1) { if (pipe(init_result_pipe) != 0) { g_process_message("Error daemonizing process, cannot open pipe; error='%s'", g_strerror(errno)); g_process_startup_failed(1, TRUE); } /* fork off a child process */ if ((pid = fork()) < 0) { g_process_message("Error forking child process; error='%s'", g_strerror(errno)); g_process_startup_failed(1, TRUE); } else if (pid != 0) { gint rc; gboolean deadlock = FALSE; /* this is the supervisor process */ /* shut down init_result_pipe write side */ close(init_result_pipe[1]); init_result_pipe[1] = -1; rc = g_process_recv_result(); if (first) { /* first time encounter, we have a chance to report back, do it */ g_process_send_result(rc); if (rc != 0) break; g_process_detach_stdio(); } first = FALSE; if (rc != 0) { gint i = 0; /* initialization failed in daemon, it will probably exit soon, wait and restart */ while (i < 6 && waitpid(pid, &rc, WNOHANG) == 0) { if (i > 3) kill(pid, i > 4 ? SIGKILL : SIGTERM); sleep(1); i++; } if (i == 6) g_process_message("Initialization failed but the daemon did not exit, even when forced to, trying to recover; pid='%d'", pid); continue; } if (process_opts.check_fn && (process_opts.check_period >= 0)) { gint i = 1; while (!(exited = waitpid(pid, &rc, WNOHANG))) { if (i >= process_opts.check_period) { if (!process_opts.check_fn()) break; i = 0; } sleep(1); i++; } if (!exited) { gint j = 0; g_process_message("Daemon deadlock detected, killing process;"); deadlock = TRUE; while (j < 6 && waitpid(pid, &rc, WNOHANG) == 0) { if (j > 3) kill(pid, j > 4 ? SIGKILL : SIGABRT); sleep(1); j++; } if (j == 6) g_process_message("The daemon did not exit after deadlock, even when forced to, trying to recover; pid='%d'", pid); } } else { waitpid(pid, &rc, 0); } if (deadlock || WIFSIGNALED(rc) || (WIFEXITED(rc) && WEXITSTATUS(rc) != 0)) { gchar argbuf[64]; if (!access(G_PROCESS_FAILURE_NOTIFICATION, R_OK | X_OK)) { const gchar *notify_reason; pid_t npid = fork(); gint nrc; switch (npid) { case -1: g_process_message("Could not fork for external notification; reason='%s'", strerror(errno)); break; case 0: switch(fork()) { case -1: g_process_message("Could not fork for external notification; reason='%s'", strerror(errno)); exit(1); break; case 0: if (deadlock) { notify_reason = "deadlock detected"; argbuf[0] = 0; } else { snprintf(argbuf, sizeof(argbuf), "%d", WIFSIGNALED(rc) ? WTERMSIG(rc) : WEXITSTATUS(rc)); if (WIFSIGNALED(rc)) notify_reason = "signalled"; else notify_reason = "non-zero exit code"; } execlp(G_PROCESS_FAILURE_NOTIFICATION, G_PROCESS_FAILURE_NOTIFICATION, SAFE_STRING(process_opts.name), SAFE_STRING(process_opts.chroot_dir), SAFE_STRING(process_opts.pidfile_dir), SAFE_STRING(process_opts.pidfile), SAFE_STRING(process_opts.cwd), SAFE_STRING(process_opts.caps), notify_reason, argbuf, (deadlock || !WIFSIGNALED(rc) || WTERMSIG(rc) != SIGKILL) ? "restarting" : "not-restarting", (gchar *) NULL); g_process_message("Could not execute external notification; reason='%s'", strerror(errno)); break; default: exit(0); break; } /* child process */ default: waitpid(npid, &nrc, 0); break; } } if (deadlock || !WIFSIGNALED(rc) || WTERMSIG(rc) != SIGKILL) { g_process_message("Daemon exited due to a deadlock/signal/failure, restarting; exitcode='%d'", rc); sleep(1); } else { g_process_message("Daemon was killed, not restarting; exitcode='%d'", rc); break; } } else { g_process_message("Daemon exited gracefully, not restarting; exitcode='%d'", rc); break; } } else { /* this is the daemon process, thus we should return to the caller of g_process_start() */ /* shut down init_result_pipe read side */ process_kind = G_PK_DAEMON; close(init_result_pipe[0]); init_result_pipe[0] = -1; /* update systemd socket activation pid */ inherit_systemd_activation(); memcpy(process_opts.argv_start, process_opts.argv_orig, process_opts.argv_env_len); return; } } exit(0); }
JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_dumpInfo0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources) { Display * dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; int pos[] = { 0, 0 } ; int i, j, minWidth, minHeight, maxWidth, maxHeight; int vs_width = DisplayWidth(dpy, screen_idx); int vs_height = DisplayHeight(dpy, screen_idx); int vs_width_mm = DisplayWidthMM(dpy, screen_idx); int vs_height_mm = DisplayHeightMM(dpy, screen_idx); fprintf(stderr, "ScreenVirtualSize: %dx%d %dx%d mm\n", vs_width, vs_height, vs_width_mm, vs_height_mm); XRRGetScreenSizeRange (dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight); fprintf(stderr, "XRRGetScreenSizeRange: %dx%d .. %dx%d\n", minWidth, minHeight, maxWidth, maxHeight); if( NULL == resources ) { fprintf(stderr, "XRRScreenResources NULL\n"); return; } fprintf(stderr, "XRRScreenResources %p: Crtc count %d\n", resources, resources->ncrtc); for(i=0; i<resources->ncrtc; i++) { RRCrtc crtc = resources->crtcs[i]; XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, resources, crtc); fprintf(stderr, "Crtc[%d]: %d/%d %dx%d, rot 0x%X, mode.id %#lx\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height, xrrCrtcInfo->rotations, xrrCrtcInfo->mode); for(j=0; j<xrrCrtcInfo->noutput; j++) { fprintf(stderr, " Crtc[%d].Output[%d].id %#lx\n", i, j, xrrCrtcInfo->outputs[j]); } XRRFreeCrtcInfo(xrrCrtcInfo); } dumpOutputs("XRRScreenResources.outputs", dpy, resources, resources->noutput, resources->outputs); fprintf(stderr, "XRRScreenResources %p: Mode count %d\n", resources, resources->nmode); for(i=0; i<resources->nmode; i++) { XRRModeInfo *mode = &resources->modes[i]; unsigned int dots = mode->hTotal * mode->vTotal; float refresh = getVRefresh(mode); fprintf(stderr, "Mode[%d, id %#lx]: %ux%u@%f, name %s\n", i, mode->id, mode->width, mode->height, refresh, SAFE_STRING(mode->name)); } }
/* {{{ proto object ffmpeg_movie(string filename) Constructor for ffmpeg_movie objects */ FFMPEG_PHP_CONSTRUCTOR(ffmpeg_movie, __construct) { int persistent = 0, hashkey_length = 0; char *filename = NULL, *fullpath = NULL, *hashkey = NULL; zval ***argv; ff_movie_context *ffmovie_ctx = NULL; /* retrieve arguments */ argv = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0); if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), argv) != SUCCESS) { efree(argv); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error parsing arguments"); } switch (ZEND_NUM_ARGS()) { case 2: convert_to_boolean_ex(argv[1]); if (! INI_BOOL("ffmpeg.allow_persistent") && Z_LVAL_PP(argv[1])) { zend_error(E_WARNING, "Persistent movies have been disabled in php.ini"); break; } persistent = Z_LVAL_PP(argv[1]); /* fallthru */ case 1: convert_to_string_ex(argv[0]); filename = Z_STRVAL_PP(argv[0]); break; default: WRONG_PARAM_COUNT; } if (persistent) { list_entry *le; /* resolve the fully-qualified path name to use as the hash key */ fullpath = expand_filepath(filename, NULL TSRMLS_CC); hashkey_length = sizeof("ffmpeg-php_")-1 + strlen(SAFE_STRING(filename)); hashkey = (char *) emalloc(hashkey_length+1); snprintf(hashkey, hashkey_length, "ffmpeg-php_%s", SAFE_STRING(filename)); /* do we have an existing persistent movie? */ if (SUCCESS == zend_hash_find(&EG(persistent_list), hashkey, hashkey_length+1, (void**)&le)) { int type; if (Z_TYPE_P(le) != le_ffmpeg_pmovie) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to retrieve persistent resource"); } ffmovie_ctx = (ff_movie_context*)le->ptr; /* sanity check to ensure that the resource is still a valid * regular resource number */ if (zend_list_find(ffmovie_ctx->rsrc_id, &type) == ffmovie_ctx) { /* add a reference to the persistent movie */ zend_list_addref(ffmovie_ctx->rsrc_id); } else { //php_error_docref(NULL TSRMLS_CC, E_ERROR, //"Not a valid persistent movie resource"); ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_pmovie); } } else { /* no existing persistant movie, create one */ list_entry new_le; ffmovie_ctx = _php_alloc_ffmovie_ctx(1); if (_php_open_movie_file(ffmovie_ctx, filename)) { zend_error(E_WARNING, "Can't open movie file %s", filename); efree(argv); ZVAL_BOOL(getThis(), 0); RETURN_FALSE; } Z_TYPE(new_le) = le_ffmpeg_pmovie; new_le.ptr = ffmovie_ctx; if (FAILURE == zend_hash_update(&EG(persistent_list), hashkey, hashkey_length+1, (void *)&new_le, sizeof(list_entry), NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to register persistent resource"); } ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_pmovie); } } else { ffmovie_ctx = _php_alloc_ffmovie_ctx(0); if (_php_open_movie_file(ffmovie_ctx, Z_STRVAL_PP(argv[0]))) { zend_error(E_WARNING, "Can't open movie file %s", Z_STRVAL_PP(argv[0])); efree(argv); ZVAL_BOOL(getThis(), 0); RETURN_FALSE; } /* pass NULL for resource result since we're not returning the resource directly, but adding it to the returned object. */ ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_movie); } object_init_ex(getThis(), ffmpeg_movie_class_entry_ptr); add_property_resource(getThis(), "ffmpeg_movie", ffmovie_ctx->rsrc_id); efree(argv); if (fullpath) { efree(fullpath); } if (hashkey) { efree(hashkey); } }
void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gpointer data) { SpellingPage *prefs_spelling = (SpellingPage *) _page; /* START GLADE CODE */ GtkWidget *table; GtkWidget *checkbtn_enable_aspell; GtkWidget *checkbtn_check_while_typing; GtkWidget *checkbtn_use_alternate; GtkWidget *label2; GtkWidget *entry_aspell_path; GtkWidget *label3; GtkWidget *optmenu_dictionary; GtkWidget *optmenu_dictionary_menu; GtkWidget *label4; GtkWidget *optmenu_sugmode; GtkWidget *optmenu_sugmode_menu; GtkWidget *label5; GtkWidget *btn_aspell_path; GtkWidget *hbox1; GtkWidget *misspelled_btn; GtkTooltips *tooltips; tooltips = gtk_tooltips_new (); table = gtk_table_new(8, 3, FALSE); gtk_widget_show(table); gtk_container_set_border_width(GTK_CONTAINER(table), 8); gtk_table_set_row_spacings(GTK_TABLE(table), 4); gtk_table_set_col_spacings(GTK_TABLE(table), 8); checkbtn_enable_aspell = gtk_check_button_new_with_label(_("Enable spell checker")); gtk_widget_show(checkbtn_enable_aspell); gtk_table_attach(GTK_TABLE(table), checkbtn_enable_aspell, 0, 3, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); checkbtn_check_while_typing = gtk_check_button_new_with_label(_("Check while typing")); gtk_widget_show(checkbtn_check_while_typing); gtk_table_attach(GTK_TABLE(table), checkbtn_check_while_typing, 0, 3, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); checkbtn_use_alternate = gtk_check_button_new_with_label(_ ("Enable alternate dictionary")); gtk_widget_show(checkbtn_use_alternate); gtk_table_attach(GTK_TABLE(table), checkbtn_use_alternate, 0, 3, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_tooltips_set_tip (tooltips, checkbtn_use_alternate, _("Faster switching with last used dictionary"), NULL); label2 = gtk_label_new(_("Dictionaries path:")); gtk_widget_show(label2); gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify(GTK_LABEL(label2), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(label2), 1, 0.5); entry_aspell_path = gtk_entry_new(); gtk_widget_show(entry_aspell_path); gtk_table_attach(GTK_TABLE(table), entry_aspell_path, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); label3 = gtk_label_new(_("Default dictionary:")); gtk_widget_show(label3); gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify(GTK_LABEL(label3), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(label3), 1, 0.5); optmenu_dictionary = gtk_option_menu_new(); gtk_widget_show(optmenu_dictionary); gtk_table_attach(GTK_TABLE(table), optmenu_dictionary, 1, 3, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); optmenu_dictionary_menu = gtk_menu_new(); gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary), optmenu_dictionary_menu); label4 = gtk_label_new(_("Default suggestion mode:")); gtk_widget_show(label4); gtk_table_attach(GTK_TABLE(table), label4, 0, 1, 6, 7, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify(GTK_LABEL(label4), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(label4), 1, 0.5); optmenu_sugmode = gtk_option_menu_new(); gtk_widget_show(optmenu_sugmode); gtk_table_attach(GTK_TABLE(table), optmenu_sugmode, 1, 3, 6, 7, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); optmenu_sugmode_menu = gtk_menu_new(); gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_sugmode), optmenu_sugmode_menu); label5 = gtk_label_new(_("Misspelled word color:")); gtk_widget_show(label5); gtk_table_attach(GTK_TABLE(table), label5, 0, 1, 7, 8, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify(GTK_LABEL(label5), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(label5), 1, 0.5); btn_aspell_path = gtk_button_new_with_label(_(" ... ")); gtk_widget_show(btn_aspell_path); gtk_table_attach(GTK_TABLE(table), btn_aspell_path, 2, 3, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); hbox1 = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox1); gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 7, 8, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); misspelled_btn = gtk_button_new_with_label(""); gtk_widget_show(misspelled_btn); gtk_box_pack_start(GTK_BOX(hbox1), misspelled_btn, FALSE, FALSE, 0); gtk_widget_set_usize(misspelled_btn, 30, 20); /* END GLADE CODE */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_aspell), prefs_common.enable_aspell); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_check_while_typing), prefs_common.check_while_typing); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_use_alternate), prefs_common.use_alternate); gtk_entry_set_text(GTK_ENTRY(entry_aspell_path), SAFE_STRING(prefs_common.aspell_path)); gtk_signal_connect(GTK_OBJECT(checkbtn_enable_aspell), "toggled", GTK_SIGNAL_FUNC(prefs_spelling_checkbtn_enable_aspell_toggle_cb), prefs_spelling); gtk_signal_connect(GTK_OBJECT(btn_aspell_path), "clicked", GTK_SIGNAL_FUNC(prefs_spelling_btn_aspell_path_clicked_cb), prefs_spelling); gtk_signal_connect(GTK_OBJECT(misspelled_btn), "clicked", GTK_SIGNAL_FUNC(prefs_spelling_colorsel), prefs_spelling); gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_dictionary), gtkaspell_dictionary_option_menu_new(prefs_common.aspell_path)); gtkaspell_set_dictionary_menu_active_item(optmenu_dictionary, prefs_common.dictionary); gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_sugmode), gtkaspell_sugmode_option_menu_new(prefs_common.aspell_sugmode)); gtkaspell_sugmode_option_menu_set(GTK_OPTION_MENU(optmenu_sugmode), prefs_common.aspell_sugmode); prefs_spelling->misspell_col = prefs_common.misspelled_col; gtkut_set_widget_bgcolor_rgb(misspelled_btn, prefs_spelling->misspell_col); prefs_spelling->window = GTK_WIDGET(window); prefs_spelling->checkbtn_enable_aspell = checkbtn_enable_aspell; prefs_spelling->entry_aspell_path = entry_aspell_path; prefs_spelling->btn_aspell_path = btn_aspell_path; prefs_spelling->optmenu_dictionary = optmenu_dictionary; prefs_spelling->optmenu_sugmode = optmenu_sugmode; prefs_spelling->checkbtn_use_alternate = checkbtn_use_alternate; prefs_spelling->checkbtn_check_while_typing = checkbtn_check_while_typing; prefs_spelling->misspelled_btn = misspelled_btn; prefs_spelling->page.widget = table; prefs_spelling_enable(prefs_spelling, prefs_common.enable_aspell); }
int32_t SearcherWorkerFactory::initilize(const char *path) { ini_context_t cfg; const ini_section_t *grp = NULL; const char *val = NULL; const char *seconf = NULL; uint32_t nval = 0; int32_t ret = 0; if (_ready) { return KS_SUCCESS; } if (!_server) { TERR("initialize _server error."); return KS_EFAILED; } _server->_type = FRAMEWORK::srv_type_searcher; ret = ini_load_from_file(path, &cfg); if (unlikely(ret != 0)) { TERR("initialize SearcherWorkerFactory by `%s' error.", SAFE_STRING(path)); return KS_EFAILED; } grp = &cfg.global; if (unlikely(!grp)) { TERR("invalid config file `%s' for SearcherWorkerFactory.", SAFE_STRING(path)); ini_destroy(&cfg); return KS_EFAILED; } //获得搜索xml文件句柄 val = ini_get_str_value1(grp, "module_config_path"); if (val && (val[0] != '\0')) { FILE *fp = NULL; if ((fp = fopen(val, "r")) == NULL) { TERR("模块配置文件 %s 打开出错, 文件可能不存在.\n", val); ini_destroy(&cfg); return KS_EFAILED; } _pXMLTree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK); if (_pXMLTree == NULL) { TERR("模块配置文件 %s 格式有错, 请修正您的配置文件.\n", val); fclose(fp); ini_destroy(&cfg); return KS_EFAILED; } fclose(fp); } else { TERR("search module config path is null"); ini_destroy(&cfg); return KS_EFAILED; } //各个处理模块的初始化工作 if (index_lib::init(_pXMLTree) != KS_SUCCESS) { TERR("init index lib failed!"); ini_destroy(&cfg); return KS_EFAILED; } if (_qrewiter.init(_pXMLTree) != KS_SUCCESS){ TERR("init query rewriter failed!"); ini_destroy(&cfg); return KS_EFAILED; } if (_qp.init(_pXMLTree) != KS_SUCCESS){ TERR("init query parser failed!"); ini_destroy(&cfg); return KS_EFAILED; } if (_is.init(_pXMLTree) != KS_SUCCESS){ TERR("init index searcher failed!"); ini_destroy(&cfg); return KS_EFAILED; } if (_stat.init(_pXMLTree) != KS_SUCCESS){ TWARN("init statistic failed!"); } //get default value of format type _ofmt_type = get_outfmt_type(_pXMLTree); //get sort config val = ini_get_str_value1(grp, "sort_config_path"); if (val && (val[0] != '\0')) { if (_sort.init(val) != KS_SUCCESS) { TERR("init sort failed! path = %s\n", val); ini_destroy(&cfg); return KS_EFAILED; } } else { TERR("sort config file is error!"); ini_destroy(&cfg); return KS_EFAILED; } val = ini_get_str_value1(grp, "update_config_path"); if (val && (val[0] != '\0')) { _pIndexUpdater = new UPDATE::IndexUpdater; int32_t nRes = -1; if ((nRes = _pIndexUpdater->init(val)) != 0) { TERR("init IndexUpdater failed! errno=%d", nRes); } else if (pthread_create(&_updateTid, NULL, UPDATE::Updater::start, _pIndexUpdater) != 0) { TERR("start updater thread failed!"); ini_destroy(&cfg); return KS_EFAILED; } } else { TERR("update config path is null"); } //获得detail_module.xml文件句柄 val = ini_get_str_value1(grp, "detail_module_config_path"); if (val && (val[0] != '\0')) { FILE *fp = NULL; if ((fp = fopen(val, "r")) == NULL) { TERR("模块配置文件 %s 打开出错, 文件可能不存在.\n", val); ini_destroy(&cfg); return KS_EFAILED; } _pXMLTreeDetail= mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK); if (_pXMLTreeDetail == NULL) { TERR("模块配置文件 %s 格式有错, 请修正您的配置文件.\n", val); fclose(fp); ini_destroy(&cfg); return KS_EFAILED; } fclose(fp); _detail = true; } else { _detail = false; } if(_detail) { //初始化detail各模块 if(di_detail_init(_pXMLTreeDetail)!=KS_SUCCESS){ TERR("di_detail_init failed!"); ini_destroy(&cfg); return KS_EFAILED; } } ini_destroy(&cfg); _ready = true; return KS_SUCCESS; }