static ad_device_data * sound_nas_create(Lisp_Object nas_options) { sound_nas_data_t *snd; char *server[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; int i, server_cnt = 0; AuServer *aud = NULL; Lisp_Object opt_server = Qnil; /* parse options */ opt_server = Fplist_get(nas_options, intern(":server"), Qnil); if (!NILP(opt_server) && !STRINGP(opt_server) && !DEVICEP(opt_server)) { wrong_type_argument(Qstringp, opt_server); return NULL; } if (NILP(opt_server)) nas_setup_defaults(server, &server_cnt); else if (STRINGP(opt_server)) server[server_cnt++] = (char*)XSTRING_DATA(opt_server); #ifdef HAVE_X_WINDOWS else if (DEVICEP(opt_server) && DEVICE_X_P(XDEVICE(opt_server))) server[server_cnt++] = (char*)XSTRING_DATA( DEVICE_CONNECTION(XDEVICE(opt_server))); #endif NAS_DEBUG("trying %d connections\n", server_cnt); for (i = 0; i<server_cnt; i++) if ((aud = nas_try_connection(server[i]))) break; if (!aud) { NAS_DEBUG_C("cannot contact any NAS server\n"); warn_when_safe(Qnas, Qwarning, GETTEXT("No NAS servers in sight.\n")); return NULL; /* Could not contact NAS server */ } /* -- initialise -- */ snd = xnew_and_zero(sound_nas_data_t); snd->aud = aud; /* round up SOUND_MAX_AUDIO_FRAME_SIZE to multiple of NAS_FRAG_SIZE * divide by 3 first because of 2:1 split */ snd->proposed_buffer_size = (SOUND_MAX_AUDIO_FRAME_SIZE/3 + NAS_FRAG_SIZE-1) & ~(NAS_FRAG_SIZE-1); NAS_DEBUG_C("proposed buffer size: %u\n", snd->proposed_buffer_size); NAS_DEBUG_C("created: 0x%x\n", (unsigned int)snd); return snd; }
static Lisp_Devmode * decode_devmode (Lisp_Object dev) { if (DEVMODEP (dev)) return XDEVMODE (dev); else { ensure_not_printing (XDEVICE (dev)); return XDEVMODE (DEVICE_MSPRINTER_DEVMODE (XDEVICE (dev))); } }
static void nas_setup_defaults(char **server, int *cnt) { int i; Lisp_Object tmp; /* considering some defaults */ NAS_DEBUG("trying to find some defaults\n"); #ifdef HAVE_X_WINDOWS /* check for the device connection of the currently active frame */ tmp = Fselected_device(Qnil); if (DEVICEP(tmp) && DEVICE_X_P(XDEVICE(tmp))) server[(*cnt)++] = (char*)XSTRING_DATA( DEVICE_CONNECTION(XDEVICE(tmp))); /* tbd: check for conn of the initial frame */ #endif /* try to look for $AUDIOSERVER */ if ((server[(*cnt)] = getenv("AUDIOSERVER"))) { /* only add the stuff, if not already in the try queue */ for (i=0; i < (*cnt); i++) if (strcmp(server[i], server[(*cnt)]) == 0) break; if (i == (*cnt)) (*cnt)++; } /* try to look for $DISPLAY */ if ((server[(*cnt)] = getenv("DISPLAY"))){ /* only add the stuff, if not already in the try queue */ for (i=0; i < (*cnt); i++) if (strcmp(server[i], server[(*cnt)]) == 0) break; if (i == (*cnt)) (*cnt)++; } /* oh, let's try localhost:0.0, if not already there of course */ for (i=0; i < (*cnt); i++) if (strcmp(server[i], "localhost:0.0") == 0) break; if (i == (*cnt)) server[(*cnt)++] = "localhost:0.0"; /* finally we try NULL, too */ server[(*cnt)++] = NULL; return; }
static void handle_devmode_changes (Lisp_Devmode *ldm, HGLOBAL hDevNames, HGLOBAL hDevMode) { DEVNAMES *devnames = (DEVNAMES *) GlobalLock (hDevNames); Extbyte *new_name = devnames ? (Extbyte *) devnames + XETCHAR_SIZE * devnames->wDeviceOffset : NULL; DEVMODEW *devmode = (DEVMODEW *) GlobalLock (hDevMode); /* Size and name may have changed */ ldm->devmode = (DEVMODEW *) xrealloc (ldm->devmode, DEVMODE_SIZE (devmode)); if (new_name) ldm->printer_name = build_tstr_string (new_name); if (!NILP (ldm->device)) { /* Apply the new devmode to the printer and get a compete one back */ struct device *d = XDEVICE (ldm->device); if (!sync_printer_with_devmode (d, devmode, ldm->devmode, new_name ? ldm->printer_name : Qnil)) { global_free_2_maybe (hDevNames, hDevMode); signal_error (Qio_error, "Printer device initialization I/O error, device deleted", ldm->device); } } else { /* Just copy the devmode structure */ memcpy (ldm->devmode, devmode, DEVMODE_SIZE (devmode)); } }
static int gtk_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name, Lisp_Object device, Error_behavior errb) { GdkColor color; int result; result = gtk_parse_nearest_color (XDEVICE (device), &color, XSTRING_DATA (name), XSTRING_LENGTH (name), errb); if (!result) return 0; /* Don't allocate the data until we're sure that we will succeed, or the finalize method may get f****d. */ c->data = xnew (struct gtk_color_instance_data); if (result == 3) COLOR_INSTANCE_GTK_DEALLOC (c) = 0; else COLOR_INSTANCE_GTK_DEALLOC (c) = 1; COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color); return 1; }
static Lisp_Object mark_device (Lisp_Object obj) { struct device *d = XDEVICE (obj); mark_object (d->name); mark_object (d->connection); mark_object (d->canon_connection); mark_object (d->console); mark_object (d->selected_frame); mark_object (d->frame_with_focus_real); mark_object (d->frame_with_focus_for_hooks); mark_object (d->frame_that_ought_to_have_focus); mark_object (d->device_class); mark_object (d->user_defined_tags); mark_object (d->pixel_to_glyph_cache.obj1); mark_object (d->pixel_to_glyph_cache.obj2); mark_object (d->color_instance_cache); mark_object (d->font_instance_cache); #ifdef MULE mark_object (d->charset_font_cache); #endif mark_object (d->image_instance_cache); if (d->devmeths) { mark_object (d->devmeths->symbol); MAYBE_DEVMETH (d, mark_device, (d)); } return (d->frame_list); }
static void gtk_finalize_color_instance (struct Lisp_Color_Instance *c) { if (c->data) { if (DEVICE_LIVE_P (XDEVICE (c->device))) { if (COLOR_INSTANCE_GTK_DEALLOC (c)) { gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)), COLOR_INSTANCE_GTK_COLOR (c), 1); } gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c)); } xfree (c->data); c->data = 0; } }
/* find a font spec that matches font spec FONT and also matches (the registry of) CHARSET. */ static Lisp_Object gtk_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset) { char **names; int count = 0; Lisp_Object result = Qnil; const char *patternext; int i; TO_EXTERNAL_FORMAT (LISP_STRING, font, C_STRING_ALLOCA, patternext, Qbinary); names = XListFonts (GDK_DISPLAY (), patternext, MAX_FONT_COUNT, &count); /* ### This code seems awfully bogus -- mrb */ for (i = 0; i < count; i ++) { const Bufbyte *intname; Bytecount intlen; TO_INTERNAL_FORMAT (C_STRING, names[i], ALLOCA, (intname, intlen), Qctext); if (gtk_font_spec_matches_charset (XDEVICE (device), charset, intname, Qnil, 0, -1)) { result = make_string ((char *) intname, intlen); break; } } if (names) XFreeFontNames (names); /* Check for a short font name. */ if (NILP (result) && gtk_font_spec_matches_charset (XDEVICE (device), charset, 0, font, 0, -1)) return font; return result; }
static GdkGC *get_toolbar_gc (struct frame *f) { Lisp_Object fg, bg; Lisp_Object frame; XSETFRAME (frame, f); fg = Fspecifier_instance (Fget (Vtoolbar_face, Qforeground, Qnil), frame, Qnil, Qnil); bg = Fspecifier_instance (Fget (Vtoolbar_face, Qbackground, Qnil), frame, Qnil, Qnil); /* Need to swap the foreground/background here or most themes look bug ugly */ return (gtk_get_gc (XDEVICE (FRAME_DEVICE (f)), Qnil, bg, fg, Qnil, Qnil)); }
static void gtk_finalize_font_instance (struct Lisp_Font_Instance *f) { if (f->data) { if (DEVICE_LIVE_P (XDEVICE (f->device))) { gdk_font_unref (FONT_INSTANCE_GTK_FONT (f)); } xfree (f->data); f->data = 0; } }
static void print_device (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) { struct device *d = XDEVICE (obj); char buf[256]; if (print_readably) error ("printing unreadable object #<device %s 0x%x>", XSTRING_DATA (d->name), d->header.uid); sprintf (buf, "#<%s-device", !DEVICE_LIVE_P (d) ? "dead" : DEVICE_TYPE_NAME (d)); write_c_string (buf, printcharfun); if (DEVICE_LIVE_P (d) && !NILP (DEVICE_CONNECTION (d))) { write_c_string (" on ", printcharfun); print_internal (DEVICE_CONNECTION (d), printcharfun, 1); } sprintf (buf, " 0x%x>", d->header.uid); write_c_string (buf, printcharfun); }
static SIGTYPE interrupt_signal (int sig) { /* This function can call lisp */ /* #### we should NOT be calling lisp from a signal handler, boys and girls */ /* Must preserve main program's value of errno. */ int old_errno = errno; EMACS_REESTABLISH_SIGNAL (sig, interrupt_signal); /* with the macroized error-checking stuff, the garbage below may mess things up because XCONSOLE() and such can use and change global vars. */ #if ! (defined (ERROR_CHECK_TYPECHECK) && defined (MACROIZE_ERROR_CHECKING)) if (sigint_happened && CONSOLEP (Vcontrolling_terminal) && CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal)) && !emacs_is_blocking) { char c; fflush (stdout); reset_initial_console (); EMACS_UNBLOCK_SIGNAL (sig); #ifdef SIGTSTP /* Support possible in later USG versions */ /* * On systems which can suspend the current process and return to the original * shell, this command causes the user to end up back at the shell. * The "Auto-save" and "Abort" questions are not asked until * the user elects to return to emacs, at which point he can save the current * job and either dump core or continue. */ sys_suspend (); #else /* Perhaps should really fork an inferior shell? But that would not provide any way to get back to the original shell, ever. */ stdout_out ("No support for stopping a process on this operating system;\n"); stdout_out ("you can continue or abort.\n"); #endif /* not SIGTSTP */ stdout_out ("Auto-save? (y or n) "); if (((c = getc (stdin)) & ~040) == 'Y') Fdo_auto_save (Qnil, Qnil); while (c != '\n') c = getc (stdin); stdout_out ("Abort (and dump core)? (y or n) "); if (((c = getc (stdin)) & ~040) == 'Y') ABORT (); while (c != '\n') c = getc (stdin); stdout_out ("Continuing...\n"); reinit_initial_console (); MARK_FRAME_CHANGED (XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (Vcontrolling_terminal)))))); } else #endif /* ! (defined (ERROR_CHECKING) && defined (MACROIZE_ERROR_CHECKING)) */ { /* Else request quit when it's safe */ Vquit_flag = Qt; sigint_happened = 1; #ifdef HAVE_UNIXOID_EVENT_LOOP signal_fake_event (); #endif } errno = old_errno; SIGRETURN; }