annotate src/xrdb.c @ 109165:750db9f3e6d8

Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp * alloc.c (overrun_check_malloc, overrun_check_realloc) (overrun_check_free, xstrdup, allocate_string) (allocate_string_data, compact_small_strings, Fmake_string) (make_unibyte_string, make_multibyte_string) (make_string_from_bytes, make_specified_string, make_float) (Fcons, allocate_terminal, allocate_frame, make_pure_string) (Fgarbage_collect): Replace bcopy, safe_bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp. * atimer.c (start_atimer, set_alarm): Likewise. * buffer.c (clone_per_buffer_values, report_overlay_modification) (mmap_realloc, init_buffer_once): Likewise. * callint.c (Fcall_interactively): Likewise. * callproc.c (Fcall_process, Fcall_process_region, child_setup) (getenv_internal_1): Likewise. * casefiddle.c (casify_object): Likewise. * ccl.c (ccl_driver): Likewise. * character.c (str_as_multibyte, str_to_multibyte): Likewise. * charset.c (load_charset_map_from_file) (load_charset_map_from_file, load_charset_map_from_vector) (Fdefine_charset_internal): Likewise. * cm.c (Wcm_clear): Likewise. * coding.c (decode_eol, decode_coding_object) (Fset_coding_system_priority, make_subsidiaries): Likewise. * data.c (Faset): Likewise. * dired.c (directory_files_internal, file_name_completion_stat): Likewise. * dispnew.c (new_glyph_matrix, adjust_glyph_matrix) (clear_glyph_row, copy_row_except_pointers) (copy_glyph_row_contents, new_glyph_pool, realloc_glyph_pool) (save_current_matrix, restore_current_matrix) (build_frame_matrix_from_leaf_window, mirrored_line_dance) (mirror_line_dance, scrolling_window): Likewise. * doc.c (Fsnarf_documentation, Fsubstitute_command_keys): Likewise. * doprnt.c (doprnt): Likewise. * editfns.c (Fuser_full_name, make_buffer_string_both) (Fmessage_box, Fformat, Ftranspose_regions): Likewise. * emacs.c (sort_args): Likewise. * eval.c (Fapply, Ffuncall): Likewise. * fileio.c (Ffile_name_directory, make_temp_name) (Fexpand_file_name, search_embedded_absfilename) (Fsubstitute_in_file_name, Ffile_symlink_p, Finsert_file_contents) (auto_save_error): Likewise. * fns.c (Fstring_equal, Fcopy_sequence, concat) (string_to_multibyte, Fstring_as_unibyte, Fstring_as_multibyte) (internal_equal, Fclear_string, larger_vector, copy_hash_table) (Fmake_hash_table): Likewise. * fringe.c (Fdefine_fringe_bitmap): Likewise. * ftfont.c (ftfont_text_extents): Likewise. * getloadavg.c (getloadavg): Likewise. * image.c (define_image_type, make_image, make_image_cache) (x_create_x_image_and_pixmap, xbm_image_p) (w32_create_pixmap_from_bitmap_data, xbm_load, xpm_lookup_color) (xpm_image_p, x_create_bitmap_from_xpm_data, xpm_load) (init_color_table, x_build_heuristic_mask, pbm_image_p, pbm_load) (png_image_p, png_read_from_memory, png_load, jpeg_image_p) (tiff_image_p, tiff_read_from_memory, gif_image_p) (gif_read_from_memory, gif_load, svg_image_p, gs_image_p): Likewise. * indent.c (scan_for_column, compute_motion): Likewise. * insdel.c (gap_left, gap_right, make_gap_smaller, copy_text) (insert_1_both, insert_from_gap, replace_range_2): Likewise. * intervals.c (reproduce_tree, reproduce_tree_obj): Likewise. * keyboard.c (echo_char, save_getcjmp, restore_getcjmp) (kbd_buffer_store_event_hold, apply_modifiers_uncached) (store_user_signal_events, menu_bar_items, tool_bar_items) (process_tool_bar_item, append_tool_bar_item) (read_char_minibuf_menu_prompt, read_key_sequence) (Fread_key_sequence, Fread_key_sequence_vector, Frecent_keys): Likewise. * keymap.c (current_minor_maps, Fdescribe_buffer_bindings): Likewise. * lisp.h (STRING_COPYIN): Likewise. * lread.c (Fload, read1, oblookup): Likewise. * msdos.c (Frecent_doskeys): Likewise. * nsfns.m (Fx_create_frame): Likewise. * nsfont.m (nsfont_open, nsfont_text_extents, ns_glyph_metrics): Likewise. * nsimage.m (EmacsImage-initFromSkipXBM:width:height:) (EmacsImage-initForXPMWithDepth:width:height:flip:length:): Likewise. * nsmenu.m (ns_update_menubar): Likewise. * nsterm.m (ns_draw_fringe_bitmap, ns_term_init): Likewise. * print.c (print_unwind, printchar, strout, print_string) (print_error_message): Likewise. * process.c (conv_lisp_to_sockaddr, set_socket_option) (Fmake_network_process, Fnetwork_interface_list) (Fnetwork_interface_info, read_process_output, Fprocess_send_eof) (init_process): Likewise. * ralloc.c (resize_bloc, r_alloc_sbrk, r_alloc_init): Likewise. * regex.c (init_syntax_once, regex_compile, re_compile_fastmap): Likewise. * scroll.c (do_scrolling, do_direct_scrolling) (scrolling_max_lines_saved): Likewise. * search.c (search_buffer, wordify, Freplace_match): Likewise. * sound.c (wav_init, au_init, Fplay_sound_internal): Likewise. * syntax.c (skip_chars, skip_syntaxes): Likewise. * sysdep.c (child_setup_tty, sys_subshell, emacs_get_tty) (emacs_set_tty): Likewise. * term.c (encode_terminal_code, calculate_costs) (produce_special_glyphs, create_tty_output, init_tty, delete_tty): Likewise. * termcap.c (tgetst1, gobble_line): Likewise. * termhooks.h (EVENT_INIT): Likewise. * tparam.c (tparam1): Likewise. * unexalpha.c (unexec): Likewise. * unexec.c (write_segment): Likewise. * unexmacosx.c (unexec_write_zero): Likewise. * w32fns.c (w32_wnd_proc, Fx_create_frame, x_create_tip_frame) (Fx_file_dialog, Fsystem_move_file_to_trash): Likewise. * w32font.c (w32font_list_family, w32font_text_extents) (w32font_list_internal, w32font_match_internal) (w32font_open_internal, compute_metrics, Fx_select_font): Likewise. * w32menu.c (set_frame_menubar, add_menu_item) (w32_menu_display_help, w32_free_submenu_strings): Likewise. * w32term.c (XCreateGC, w32_initialize_display_info): Likewise. * w32uniscribe.c (uniscribe_list_family): Likewise. * w32xfns.c (get_next_msg, post_msg, prepend_msg): Likewise. * window.c (make_window, replace_window, set_window_buffer) (Fsplit_window): Likewise. * xdisp.c (init_iterator, RECORD_OVERLAY_STRING, reseat_to_string) (add_to_log, message3, x_consider_frame_title) (append_space_for_newline, extend_face_to_end_of_line) (decode_mode_spec_coding, init_glyph_string): Likewise. * xfaces.c (x_create_gc, get_lface_attributes_no_remap) (Finternal_copy_lisp_face, Finternal_merge_in_global_face) (face_attr_equal_p, make_realized_face, make_face_cache) (free_realized_faces, lookup_named_face, smaller_face) (face_with_height, lookup_derived_face) (x_supports_face_attributes_p, Finternal_set_font_selection_order) (Finternal_set_font_selection_order, realize_default_face) (compute_char_face, face_at_buffer_position) (face_for_overlay_string, face_at_string_position, merge_faces): Likewise. * xfns.c (xic_create_fontsetname, Fx_create_frame) (Fx_window_property, x_create_tip_frame) (Fx_backspace_delete_keys_p): Likewise. * xfont.c (xfont_list, xfont_match, xfont_list_family) (xfont_text_extents): Likewise. * xmenu.c (set_frame_menubar, xmenu_show): Likewise. * xrdb.c (magic_file_p, x_get_resource): Likewise. * xselect.c (x_queue_event, x_get_window_property) (receive_incremental_selection): Likewise. * xsmfns.c (x_session_check_input): Likewise. * xterm.c (x_send_scroll_bar_event, SET_SAVED_MENU_EVENT) (handle_one_xevent, x_check_errors, xim_initialize, x_term_init): Likewise. * character.h (BCOPY_SHORT): Removed. * config.in: Regenerate. * dispnew.c (safe_bcopy): Only define as dummy if PROFILING. * emacs.c (main) [PROFILING]: Don't declare dump_opcode_frequencies. * lisp.h (safe_bcopy): Remove declaration. (memset) [!HAVE_MEMSET]: Declare. (memcpy) [!HAVE_MEMCPY]: Likewise. (memmove) [!HAVE_MEMMOVE]: Likewise. (memcmp) [!HAVE_MEMCMP]: Likewise. * s/ms-w32.h (bzero, bcopy, bcmp, GAP_USE_BCOPY) (BCOPY_UPWARD_SAFE, BCOPY_DOWNWARD_SAFE, HAVE_BCOPY, HAVE_BCMP): Don't define. (HAVE_MEMCMP, HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET): Define. * s/msdos.h (GAP_USE_BCOPY, BCOPY_UPWARD_SAFE) (BCOPY_DOWNWARD_SAFE): Don't define. * sysdep.c (memset) [!HAVE_MEMSET]: Define. (memcpy) [!HAVE_MEMCPY]: Define. (memmove) [!HAVE_MEMMOVE]: Define. (memcmp) [!HAVE_MEMCMP]: Define. * config.nt (HAVE_BCOPY, HAVE_BCMP): Remove undefs. (HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET, HAVE_MEMCMP): Add undefs. * sed2v2.inp (HAVE_MEMCPY, HAVE_MEMSET): Edit to 1. (HAVE_BZERO): Don't edit. * lwlib.c (lwlib_memset, lwlib_bcopy): Remove. (malloc_widget_value, free_widget_info, allocate_widget_instance) (lw_separator_p): Replace lwlib_memset, lwlib_bcopy, bzero, bcmp by memset, memcpy, memcmp. * lwlib-utils.c (XtApplyToWidgets): Likewise. * xlwmenu.c (XlwMenuInitialize): Likewise. * lwlib.h (lwlib_bcopy): Remove declaration. * ebrowse.c (add_sym, make_namespace): Replace bcopy, bzero by memcpy, memmove, memset. * pop.c (pop_retrieve, socket_connection, pop_getline): Likewise. * CPP-DEFINES (BCOPY_DOWNWARD_SAFE, BCOPY_UPWARD_SAFE) (GAP_USE_BCOPY, HAVE_BCMP, HAVE_BCOPY, bcmp, bcopy, bzero): Remove. * configure.in: Don't check for bcopy, bcmp, bzero. Don't include <strings.h> and don't define bcopy, bzero, BCMP in config.h.
author Andreas Schwab <schwab@linux-m68k.org>
date Thu, 08 Jul 2010 00:18:28 +0200
parents c25c24812fb1
children 05e7e7c46ff0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Deal with the X Resource Manager.
64770
a0d1312ede66 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
2 Copyright (C) 1990, 1993, 1994, 2000, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
101091
9e4d0326f86c Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents: 100951
diff changeset
5 Author: Joseph Arceneaux
9e4d0326f86c Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents: 100951
diff changeset
6 Created: 4/90
9e4d0326f86c Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents: 100951
diff changeset
7
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 10463
diff changeset
8 This file is part of GNU Emacs.
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 10463
diff changeset
9
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94942
diff changeset
10 GNU Emacs is free software: you can redistribute it and/or modify
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94942
diff changeset
12 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94942
diff changeset
13 (at your option) any later version.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 10463
diff changeset
15 GNU Emacs is distributed in the hope that it will be useful,
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 GNU General Public License for more details.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94942
diff changeset
21 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
23 #ifdef emacs
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4538
diff changeset
24 #include <config.h>
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
25 #endif
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
26
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
27 #ifdef HAVE_UNISTD_H
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
28 #include <unistd.h>
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
29 #endif
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
30
107737
912a8c0c9a8a Remove extern errno declarations.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
31 #include <errno.h>
24412
d11ac02f9d6a Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 21514
diff changeset
32 #include <epaths.h>
19393
ef747a07f03d Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 19388
diff changeset
33
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
34 #include <stdio.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105069
diff changeset
35 #include <setjmp.h>
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
36
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #include <X11/Xlib.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include <X11/Xatom.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #include <X11/X.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 #include <X11/Xutil.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 #include <X11/Xresource.h>
61700
8a54ce1fae6a Remove reference to defunct vms-pwd.h.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60830
diff changeset
42 #ifdef HAVE_PWD_H
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include <pwd.h>
556
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
44 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 #include <sys/stat.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
47 #if !defined(S_ISDIR) && defined(S_IFDIR)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
48 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
49 #endif
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
50
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
51 #include "lisp.h"
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
52
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
53 extern char *getenv (const char *);
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
54
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
55 /* This does cause trouble on AIX. I'm going to take the comment at
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
56 face value. */
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
57 #if 0
1126
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
58 extern short getuid (); /* If this causes portability problems,
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
59 I think we should just delete it; it'll
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
60 default to `int' anyway. */
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
61 #endif
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
62
8775
36f01bbb7d71 (getpwuid, getpwnam): Test just DECLARE_GETPWUID_WITH_UID_T, not __bsdi__.
Richard M. Stallman <rms@gnu.org>
parents: 8295
diff changeset
63 #ifdef DECLARE_GETPWUID_WITH_UID_T
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
64 extern struct passwd *getpwuid (uid_t);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
65 extern struct passwd *getpwnam (const char *);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
66 #else
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
67 extern struct passwd *getpwuid (uid_t);
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
68 extern struct passwd *getpwnam (const char *);
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
69 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
109139
c25c24812fb1 Convert declarations or definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109126
diff changeset
71 extern char *get_system_name (void);
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
72
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
73 /* Make sure not to #include anything after these definitions. Let's
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
74 not step on anyone's prototypes. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
75 #ifdef emacs
68631
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
76 /* darwin.h may have already defined these. */
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
77 #undef malloc
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
78 #undef realloc
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
79 #undef free
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
80 #define malloc xmalloc
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
81 #define realloc xrealloc
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
82 #define free xfree
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
83 #endif
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
84
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
85 char *x_get_string_resource (XrmDatabase rdb, char *name, char *class);
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
86 static int file_p (char *filename);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
87
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
88
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
89 /* X file search path processing. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
90
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
91
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
92 /* The string which gets substituted for the %C escape in XFILESEARCHPATH
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
93 and friends, or zero if none was specified. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
94 char *x_customization_string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
95
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
96
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
97 /* Return the value of the emacs.customization (Emacs.Customization)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
98 resource, for later use in search path decoding. If we find no
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
99 such resource, return zero. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
100 char *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
101 x_get_customization_string (XrmDatabase db, char *name, char *class)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
102 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
103 char *full_name
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
104 = (char *) alloca (strlen (name) + sizeof ("customization") + 3);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
105 char *full_class
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
106 = (char *) alloca (strlen (class) + sizeof ("Customization") + 3);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
107 char *result;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
108
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
109 sprintf (full_name, "%s.%s", name, "customization");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
110 sprintf (full_class, "%s.%s", class, "Customization");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
111
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
112 result = x_get_string_resource (db, full_name, full_class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
113
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
114 if (result)
4538
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
115 {
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
116 char *copy = (char *) malloc (strlen (result) + 1);
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
117 strcpy (copy, result);
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
118 return copy;
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
119 }
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
120 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
121 return 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
122 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
123
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
124
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
125 /* Expand all the Xt-style %-escapes in STRING, whose length is given
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
126 by STRING_LEN. Here are the escapes we're supposed to recognize:
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
127
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
128 %N The value of the application's class name
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
129 %T The value of the type parameter ("app-defaults" in this
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
130 context)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
131 %S The value of the suffix parameter ("" in this context)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
132 %L The language string associated with the specified display
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
133 (We use the "LANG" environment variable here, if it's set.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
134 %l The language part of the display's language string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
135 (We treat this just like %L. If someone can tell us what
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
136 we're really supposed to do, dandy.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
137 %t The territory part of the display's language string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
138 (This never gets used.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
139 %c The codeset part of the display's language string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
140 (This never gets used either.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
141 %C The customization string retrieved from the resource
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
142 database associated with display.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
143 (This is x_customization_string.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
144
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
145 Return the expanded file name if it exists and is readable, and
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
146 refers to %L only when the LANG environment variable is set, or
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
147 otherwise provided by X.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
148
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
149 ESCAPED_SUFFIX and SUFFIX are postpended to STRING if they are
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
150 non-zero. %-escapes in ESCAPED_SUFFIX are expanded; STRING is left
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
151 alone.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
152
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
153 Return NULL otherwise. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
154
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 static char *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
156 magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, char *suffix)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
157 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
158 char *lang = getenv ("LANG");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
159
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
160 int path_size = 100;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
161 char *path = (char *) malloc (path_size);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
162 int path_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
163
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
164 char *p = string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
165
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
166 while (p < string + string_len)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
167 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
168 /* The chunk we're about to stick on the end of result. */
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 29865
diff changeset
169 char *next = NULL;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
170 int next_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
171
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
172 if (*p == '%')
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
173 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
174 p++;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
175
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
176 if (p >= string + string_len)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
177 next_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
178 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
179 switch (*p)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
180 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
181 case '%':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
182 next = "%";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
183 next_len = 1;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
184 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
185
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
186 case 'C':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
187 next = (x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
188 ? x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
189 : "");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
190 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
191 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
192
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
193 case 'N':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
194 next = class;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
195 next_len = strlen (class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
196 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
197
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
198 case 'T':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
199 next = "app-defaults";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
200 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
201 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
202
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
203 default:
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
204 case 'S':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
205 next_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
206 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
207
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
208 case 'L':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
209 case 'l':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
210 if (! lang)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
211 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
212 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
213 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
214 }
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
215
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
216 next = lang;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
217 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
218 break;
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
219
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
220 case 't':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
221 case 'c':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
222 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
223 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
224 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
225 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
226 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
227 next = p, next_len = 1;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
228
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
229 /* Do we have room for this component followed by a '\0' ? */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
230 if (path_len + next_len + 1 > path_size)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
231 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
232 path_size = (path_len + next_len + 1) * 2;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
233 path = (char *) realloc (path, path_size);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
234 }
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
235
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109139
diff changeset
236 memcpy (path + path_len, next, next_len);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
237 path_len += next_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
238
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
239 p++;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
240
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
241 /* If we've reached the end of the string, append ESCAPED_SUFFIX. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
242 if (p >= string + string_len && escaped_suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
243 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
244 string = escaped_suffix;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
245 string_len = strlen (string);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
246 p = string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
247 escaped_suffix = NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
248 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
249 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
250
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
251 /* Perhaps we should add the SUFFIX now. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
252 if (suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
253 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
254 int suffix_len = strlen (suffix);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
255
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
256 if (path_len + suffix_len + 1 > path_size)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
257 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
258 path_size = (path_len + suffix_len + 1);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
259 path = (char *) realloc (path, path_size);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
260 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
261
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109139
diff changeset
262 memcpy (path + path_len, suffix, suffix_len);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
263 path_len += suffix_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
264 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
265
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
266 path[path_len] = '\0';
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
267
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
268 if (! file_p (path))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
269 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
270 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
271 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
272 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
273
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
274 return path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
275 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
276
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
277
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
278 static char *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
279 gethomedir (void)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 struct passwd *pw;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 char *ptr;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
283 char *copy;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 if ((ptr = getenv ("HOME")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 {
5917
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
287 if ((ptr = getenv ("LOGNAME")) != NULL
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
288 || (ptr = getenv ("USER")) != NULL)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 pw = getpwnam (ptr);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 else
5917
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
291 pw = getpwuid (getuid ());
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
292
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 if (pw)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 ptr = pw->pw_dir;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
297 if (ptr == NULL)
69913
eddb3cab7138 (gethomedir): Use xstrdup.
Romain Francoise <romain@orebokech.com>
parents: 69911
diff changeset
298 return xstrdup ("/");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
300 copy = (char *) malloc (strlen (ptr) + 2);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
301 strcpy (copy, ptr);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
302 strcat (copy, "/");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
304 return copy;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
307
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 static int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
309 file_p (char *filename)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 struct stat status;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312
43672
e26d9755d4e8 (file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents: 38840
diff changeset
313 return (access (filename, 4) == 0 /* exists and is readable */
e26d9755d4e8 (file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents: 38840
diff changeset
314 && stat (filename, &status) == 0 /* get the status */
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
315 && (S_ISDIR (status.st_mode)) == 0); /* not a directory */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
319 /* Find the first element of SEARCH_PATH which exists and is readable,
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
320 after expanding the %-escapes. Return 0 if we didn't find any, and
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
321 the path name of the one we found otherwise. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
323 static char *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
324 search_magic_path (char *search_path, char *class, char *escaped_suffix, char *suffix)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
325 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
326 register char *s, *p;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
328 for (s = search_path; *s; s = p)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
330 for (p = s; *p && *p != ':'; p++)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
331 ;
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
332
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
333 if (p > s)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
334 {
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
335 char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix);
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
336 if (path)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
337 return path;
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
338 }
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
339 else if (*p == ':')
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
341 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
342
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
343 s = "%N%S";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
344 path = magic_file_p (s, strlen (s), class, escaped_suffix, suffix);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
345 if (path)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
346 return path;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
349 if (*p == ':')
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
350 p++;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
356 /* Producing databases for individual sources. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
357
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
359 get_system_app (char *class)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
361 XrmDatabase db = NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
362 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
363
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
364 path = getenv ("XFILESEARCHPATH");
19388
0f27d1477c21 (get_system_app): Use PATH_X_DEFAULTS.
Richard M. Stallman <rms@gnu.org>
parents: 19318
diff changeset
365 if (! path) path = PATH_X_DEFAULTS;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
367 path = search_magic_path (path, class, 0, 0);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
368 if (path)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
369 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
370 db = XrmGetFileDatabase (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
371 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
372 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
377
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
379 get_fallback (Display *display)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 return NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
384
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
386 get_user_app (char *class)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
388 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
389 char *file = 0;
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
390 char *free_it = 0;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
392 /* Check for XUSERFILESEARCHPATH. It is a path of complete file
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
393 names, not directories. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
394 if (((path = getenv ("XUSERFILESEARCHPATH"))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
395 && (file = search_magic_path (path, class, 0, 0)))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
397 /* Check for APPLRESDIR; it is a path of directories. In each,
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
398 we have to search for LANG/CLASS and then CLASS. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
399 || ((path = getenv ("XAPPLRESDIR"))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
400 && ((file = search_magic_path (path, class, "/%L/%N", 0))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
401 || (file = search_magic_path (path, class, "/%N", 0))))
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
402
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
403 /* Check in the home directory. This is a bit of a hack; let's
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
404 hope one's home directory doesn't contain any %-escapes. */
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
405 || (free_it = gethomedir (),
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
406 ((file = search_magic_path (free_it, class, "%L/%N", 0))
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
407 || (file = search_magic_path (free_it, class, "%N", 0)))))
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
408 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
409 XrmDatabase db = XrmGetFileDatabase (file);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
410 free (file);
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
411 free (free_it);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
412 return db;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 }
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
414
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
415 free (free_it);
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
416 return NULL;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
419
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
421 get_user_db (Display *display)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 char *xdefs;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425
2126
616aeb5c1432 * xrdb.c (get_user_db): Since xrdb.c doesn't #include xterm.h,
Jim Blandy <jimb@redhat.com>
parents: 1934
diff changeset
426 #ifdef PBaseSize /* Cheap way to test for X11R4 or later. */
1051
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
427 xdefs = XResourceManagerString (display);
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
428 #else
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
429 xdefs = display->xdefaults;
1051
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
430 #endif
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
431
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 if (xdefs != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 db = XrmGetStringDatabase (xdefs);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
436 char *home;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
437 char *xdefault;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
439 home = gethomedir ();
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
440 xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults"));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
441 strcpy (xdefault, home);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 strcat (xdefault, ".Xdefaults");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 db = XrmGetFileDatabase (xdefault);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
444 free (home);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
445 free (xdefault);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447
4366
04bd0c1a6245 * config.h.in (HAVE_XSCREENRESOURCESTRING): New #undef for
Jim Blandy <jimb@redhat.com>
parents: 4233
diff changeset
448 #ifdef HAVE_XSCREENRESOURCESTRING
3654
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
449 /* Get the screen-specific resources too. */
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
450 xdefs = XScreenResourceString (DefaultScreenOfDisplay (display));
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
451 if (xdefs != NULL)
3873
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
452 {
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
453 XrmMergeDatabases (XrmGetStringDatabase (xdefs), &db);
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
454 XFree (xdefs);
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
455 }
3654
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
456 #endif
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
457
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
462 get_environ_db (void)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 char *p;
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
466 char *path = 0, *home = 0, *host;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 if ((p = getenv ("XENVIRONMENT")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
470 home = gethomedir ();
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
471 host = get_system_name ();
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
472 path = (char *) malloc (strlen (home)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
473 + sizeof (".Xdefaults-")
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
474 + strlen (host));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
475 sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 p = path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 db = XrmGetFileDatabase (p);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
480
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
481 free (path);
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
482 free (home);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
483
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
487 /* External interface. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
488
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 /* Types of values that we can find in a database */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 #define XrmStringType "String" /* String representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 XrmRepresentation x_rm_string; /* Quark representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 /* Load X resources based on the display and a possible -xrm option. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
497 x_load_resources (Display *display, char *xrm_string, char *myname, char *myclass)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
499 XrmDatabase user_database;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 XrmDatabase db;
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
502 char line[256];
60830
35cf88000489 * xrdb.c (x_load_resources): Undo previous change (2005-03-18).
Jan Djärv <jan.h.d@swipnet.se>
parents: 60717
diff changeset
503
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
504 char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
60830
35cf88000489 * xrdb.c (x_load_resources): Undo previous change (2005-03-18).
Jan Djärv <jan.h.d@swipnet.se>
parents: 60717
diff changeset
505
25749
275227ca3c0c (get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents: 24992
diff changeset
506 #ifdef USE_MOTIF
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
507 char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
508 extern Lisp_Object Vdouble_click_time;
25749
275227ca3c0c (get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents: 24992
diff changeset
509 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 x_rm_string = XrmStringToQuark (XrmStringType);
7342
4cf4669565af (x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
512 #ifndef USE_X_TOOLKIT
4cf4669565af (x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
513 /* pmr@osf.org says this shouldn't be done if USE_X_TOOLKIT.
4cf4669565af (x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
514 I suspect it's because the toolkit version does this elsewhere. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 XrmInitialize ();
7342
4cf4669565af (x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
516 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 rdb = XrmGetStringDatabase ("");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
519 /* Add some font defaults. If the font `helv' doesn't exist, widgets
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
520 will use some other default font. */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
521 #ifdef USE_MOTIF
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
522
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
523 sprintf (line, "%s.pane.background: grey75", myclass);
29865
6b6699c7fce3 (x_load_resources): Add default resource for scroll bar's
Gerd Moellmann <gerd@gnu.org>
parents: 29803
diff changeset
524 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
525 sprintf (line, "%s*fontList: %s", myclass, helv);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
526 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
527 sprintf (line, "%s*menu*background: grey75", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
528 XrmPutLineResource (&rdb, line);
36739
483ab551a108 (x_load_resources) [USE_MOTIF]: Remove extraneous arg
Gerd Moellmann <gerd@gnu.org>
parents: 33084
diff changeset
529 sprintf (line, "%s*menubar*background: grey75", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
530 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
531 sprintf (line, "%s*verticalScrollBar.background: grey75", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
532 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
533 sprintf (line, "%s*verticalScrollBar.troughColor: grey75", myclass);
29865
6b6699c7fce3 (x_load_resources): Add default resource for scroll bar's
Gerd Moellmann <gerd@gnu.org>
parents: 29803
diff changeset
534 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
535 sprintf (line, "%s.dialog*.background: grey75", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
536 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
537 sprintf (line, "%s*fsb.Text.background: white", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
538 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
539 sprintf (line, "%s*fsb.FilterText.background: white", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
540 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
541 sprintf (line, "%s*fsb*DirList.background: white", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
542 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
543 sprintf (line, "%s*fsb*ItemsList.background: white", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
544 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
545 sprintf (line, "%s*fsb*background: grey75", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
546 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
547 sprintf (line, "%s*fsb.Text.fontList: %s", myclass, courier);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
548 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
549 sprintf (line, "%s*fsb.FilterText.fontList: %s", myclass, courier);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
550 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
551 sprintf (line, "%s*fsb*ItemsList.fontList: %s", myclass, courier);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
552 XrmPutLineResource (&rdb, line);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
553 sprintf (line, "%s*fsb*DirList.fontList: %s", myclass, courier);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
554 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
555
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
556 /* Set double click time of list boxes in the file selection
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
557 dialog from `double-click-time'. */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
558 if (INTEGERP (Vdouble_click_time) && XINT (Vdouble_click_time) > 0)
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
559 {
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
560 sprintf (line, "%s*fsb*DirList.doubleClickInterval: %d",
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
561 myclass, XFASTINT (Vdouble_click_time));
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
562 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
563 sprintf (line, "%s*fsb*ItemsList.doubleClickInterval: %d",
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
564 myclass, XFASTINT (Vdouble_click_time));
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
565 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
566 }
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
567
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
568 #else /* not USE_MOTIF */
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
569
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
570 sprintf (line, "Emacs.dialog*.font: %s", helv);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
571 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
572 sprintf (line, "Emacs.dialog*.background: grey75");
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
573 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
574 sprintf (line, "*XlwMenu*font: %s", helv);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
575 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
576 sprintf (line, "*XlwMenu*background: grey75");
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
577 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
578 sprintf (line, "Emacs*verticalScrollBar.background: grey75");
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
579 XrmPutLineResource (&rdb, line);
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
580
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
581 #endif /* not USE_MOTIF */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
582
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
583 user_database = get_user_db (display);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
584
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
585 /* Figure out what the "customization string" is, so we can use it
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
586 to decode paths. */
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
587 free (x_customization_string);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
588 x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
589 = x_get_customization_string (user_database, myname, myclass);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
590
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 /* Get application system defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 db = get_system_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 /* Get Fallback resources */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 db = get_fallback (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 /* Get application user defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 db = get_user_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 /* get User defaults */
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
607 if (user_database != NULL)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
608 XrmMergeDatabases (user_database, &rdb);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 /* Get Environment defaults. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 db = get_environ_db ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 XrmMergeDatabases (db, &rdb);
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
614
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 /* Last, merge in any specification from the command line. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 if (xrm_string != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 db = XrmGetStringDatabase (xrm_string);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 return rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
626
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 /* Retrieve the value of the resource specified by NAME with class CLASS
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 and of type TYPE from database RDB. The value is returned in RET_VALUE. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
631 x_get_resource (XrmDatabase rdb, char *name, char *class, XrmRepresentation expected_type, XrmValue *ret_value)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 XrmName namelist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 XrmClass classlist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 XrmRepresentation type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 XrmStringToNameList(name, namelist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 XrmStringToClassList(class, classlist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 if (XrmQGetResource (rdb, namelist, classlist, &type, &value) == True
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 && (type == expected_type))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 if (type == x_rm_string)
1200
d2360c870787 * xrdb.c (x_get_resource): Cast the value being assigned to
Jim Blandy <jimb@redhat.com>
parents: 1126
diff changeset
645 ret_value->addr = (char *) value.addr;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 else
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109139
diff changeset
647 memcpy (ret_value->addr, value.addr, ret_value->size);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 return value.size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 /* Retrieve the string resource specified by NAME with CLASS from
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 database RDB. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 char *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
659 x_get_string_resource (XrmDatabase rdb, char *name, char *class)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662
105069
4cbb223d0b1c The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents: 101091
diff changeset
663 if (inhibit_x_resources)
4cbb223d0b1c The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents: 101091
diff changeset
664 /* --quick was passed, so this is a no-op. */
4cbb223d0b1c The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents: 101091
diff changeset
665 return NULL;
4cbb223d0b1c The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents: 101091
diff changeset
666
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 if (x_get_resource (rdb, name, class, x_rm_string, &value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 return (char *) value.addr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 return (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
673 /* Stand-alone test facilities. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
674
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 #ifdef TESTRM
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
676
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
677 typedef char **List;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
678 #define arg_listify(len, list) (list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
679 #define car(list) (*(list))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
680 #define cdr(list) (list + 1)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
681 #define NIL(list) (! *(list))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
682 #define free_arglist(list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
683
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
684 static List
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
685 member (elt, list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
686 char *elt;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
687 List list;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
688 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
689 List p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
690
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
691 for (p = list; ! NIL (p); p = cdr (p))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
692 if (! strcmp (elt, car (p)))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
693 return p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
694
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
695 return p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
696 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 static void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 fatal (msg, prog, x1, x2, x3, x4, x5)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 char *msg, *prog;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 int x1, x2, x3, x4, x5;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 if (errno)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 perror (prog);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 (void) fprintf (stderr, msg, prog, x1, x2, x3, x4, x5);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 exit (1);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 main (argc, argv)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 int argc;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 char **argv;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 Display *display;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
715 char *displayname, *resource_string, *class, *name;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 XrmDatabase xdb;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
717 List arg_list, lp;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 arg_list = arg_listify (argc, argv);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 lp = member ("-d", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 if (!NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 displayname = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 displayname = "localhost:0.0";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 lp = member ("-xrm", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 resource_string = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 resource_string = (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 lp = member ("-c", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 class = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 class = "Emacs";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
739 lp = member ("-n", arg_list);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
740 if (! NIL (lp))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
741 name = car (cdr (lp));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
742 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
743 name = "emacs";
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
745 free_arglist (arg_list);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 if (!(display = XOpenDisplay (displayname)))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 fatal ("Can't open display '%s'\n", XDisplayName (displayname));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
750 xdb = x_load_resources (display, resource_string, name, class);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 /* In a real program, you'd want to also do this: */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 display->db = xdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 while (1)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
757 char query_name[90];
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
758 char query_class[90];
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
759
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
760 printf ("Name: ");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
761 gets (query_name);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
763 if (strlen (query_name))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
765 char *value;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
766
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
767 printf ("Class: ");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
768 gets (query_class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
769
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
770 value = x_get_string_resource (xdb, query_name, query_class);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 if (value != NULL)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
773 printf ("\t%s(%s): %s\n\n", query_name, query_class, value);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 printf ("\tNo Value.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 break;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 printf ("\tExit.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 XCloseDisplay (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 #endif /* TESTRM */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
785
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
786 /* arch-tag: 37e6fbab-ed05-4363-9e76-6c4109ed511f
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
787 (do not change this comment) */