133c89af1Smrg/* 233c89af1Smrg * 333c89af1SmrgCopyright 1989, 1998 The Open Group 433c89af1Smrg 533c89af1SmrgPermission to use, copy, modify, distribute, and sell this software and its 633c89af1Smrgdocumentation for any purpose is hereby granted without fee, provided that 733c89af1Smrgthe above copyright notice appear in all copies and that both that 833c89af1Smrgcopyright notice and this permission notice appear in supporting 933c89af1Smrgdocumentation. 1033c89af1Smrg 1133c89af1SmrgThe above copyright notice and this permission notice shall be included in 1233c89af1Smrgall copies or substantial portions of the Software. 1333c89af1Smrg 1433c89af1SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1533c89af1SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1633c89af1SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1733c89af1SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1833c89af1SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1933c89af1SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2033c89af1Smrg 2133c89af1SmrgExcept as contained in this notice, the name of The Open Group shall not be 2233c89af1Smrgused in advertising or otherwise to promote the sale, use or other dealings 2333c89af1Smrgin this Software without prior written authorization from The Open Group. 2433c89af1Smrg */ 2533c89af1Smrg 2638d718bdSmrg#ifdef HAVE_CONFIG_H 2738d718bdSmrg# include "config.h" 2838d718bdSmrg#endif 2938d718bdSmrg 3033c89af1Smrg#include <stdio.h> 3133c89af1Smrg#include <stdlib.h> 3233c89af1Smrg#include <X11/Intrinsic.h> 3333c89af1Smrg#include <X11/StringDefs.h> 34ad47b356Smrg#include <X11/Xaw/Cardinals.h> 3533c89af1Smrg 3633c89af1Smrg#define THIS_IS_MAIN /* Don't get extern definitions of global 3733c89af1Smrg variables. */ 3833c89af1Smrg 3933c89af1Smrg#include "editresP.h" 4033c89af1Smrg 4133c89af1Smrg/* 42ad47b356Smrg * Global variables. 4333c89af1Smrg */ 4433c89af1Smrg 4533c89af1Smrg/* array of toolkit dependent labels taken from the resource file */ 4633c89af1SmrgString res_labels[NUM_RES_LABELS]; 4733c89af1Smrg 4833c89af1Smrg/* decremented if the target client does not speak the current version */ 4933c89af1Smrgint global_effective_protocol_version = CURRENT_PROTOCOL_VERSION; 5033c89af1Smrg 5133c89af1Smrg/* toolkit type of client whose "resources" we are currently editing */ 5238d718bdSmrgconst char *global_effective_toolkit = "xt"; 5333c89af1Smrg 5433c89af1Smrgint global_error_code; 5533c89af1Smrgunsigned long global_serial_num; 5633c89af1Smrgint (*global_old_error_handler)(Display *, XErrorEvent *); 5733c89af1Smrg 5833c89af1SmrgBoolean global_resource_box_up = FALSE; 5933c89af1SmrgTreeInfo *global_tree_info = NULL; 6033c89af1SmrgCurrentClient global_client; 6133c89af1SmrgScreenData global_screen_data; 6233c89af1SmrgWidget global_tree_parent; 6333c89af1SmrgWidget global_paned = NULL; /* named after toolkit */ 6433c89af1SmrgWidget global_toplevel; 6533c89af1SmrgAppResources global_resources; 6633c89af1Smrg 6733c89af1Smrg 6838d718bdSmrgstatic void Syntax (XtAppContext, const char *, int) _X_NORETURN; 6933c89af1Smrg 70ad47b356Smrgstatic String fallback_resources[] = { 7133c89af1Smrg NULL, 7233c89af1Smrg}; 7333c89af1Smrg 7433c89af1Smrg#define Offset(field) (XtOffsetOf(AppResources, field)) 7533c89af1Smrg 7633c89af1Smrgstatic XtResource editres_resources[] = { 7738d718bdSmrg {(String)"debug", (String)"Debug", XtRBoolean, sizeof(Boolean), 7833c89af1Smrg Offset(debug), XtRImmediate, (XtPointer) FALSE}, 7938d718bdSmrg {(String)"numFlashes", (String)"NumFlashes", XtRInt, sizeof(int), 80ad47b356Smrg Offset(num_flashes), XtRImmediate, (XtPointer) NUM_FLASHES}, 8138d718bdSmrg {(String)"flashTime", (String)"FlashTime", XtRInt, sizeof(int), 82ad47b356Smrg Offset(flash_time), XtRImmediate, (XtPointer) FLASH_TIME}, 8338d718bdSmrg {(String)"flashColor", XtCForeground, XtRPixel, sizeof(Pixel), 8433c89af1Smrg Offset(flash_color), XtRImmediate, (XtPointer) XtDefaultForeground}, 8538d718bdSmrg {(String)"saveResourceFile", (String)"SaveResourcesFile", XtRString, sizeof(String), 8633c89af1Smrg Offset(save_resources_file), XtRString, (XtPointer) ""}, 8733c89af1Smrg}; 8833c89af1Smrg 8933c89af1SmrgAtom wm_delete_window; 9033c89af1Smrg 9133c89af1Smrgint 92278eca22Smrgmain(int argc, char **argv) 9333c89af1Smrg{ 9433c89af1Smrg XtAppContext app_con; 9533c89af1Smrg 9638d718bdSmrg /* Handle args that don't require opening a display */ 9738d718bdSmrg for (int n = 1; n < argc; n++) { 9838d718bdSmrg const char *argn = argv[n]; 9938d718bdSmrg /* accept single or double dash for -help & -version */ 10038d718bdSmrg if (argn[0] == '-' && argn[1] == '-') { 10138d718bdSmrg argn++; 10238d718bdSmrg } 10338d718bdSmrg if (strcmp(argn, "-help") == 0) { 10438d718bdSmrg Syntax(NULL, argv[0], 0); 10538d718bdSmrg } 10638d718bdSmrg if (strcmp(argn, "-version") == 0) { 10738d718bdSmrg puts(PACKAGE_STRING); 10838d718bdSmrg exit(0); 10938d718bdSmrg } 11038d718bdSmrg } 11138d718bdSmrg 11233c89af1Smrg global_toplevel = XtAppInitialize(&app_con, "Editres", NULL, ZERO, 11333c89af1Smrg &argc, argv, fallback_resources, 11433c89af1Smrg NULL, ZERO); 11533c89af1Smrg 11638d718bdSmrg if (argc != 1) { 11738d718bdSmrg fputs("Unknown argument(s):", stderr); 11838d718bdSmrg for (int n = 1; n < argc; n++) { 11938d718bdSmrg fprintf(stderr, " %s", argv[n]); 12038d718bdSmrg } 12138d718bdSmrg fputs("\n\n", stderr); 12238d718bdSmrg Syntax(app_con, argv[0], 1); 12338d718bdSmrg } 12433c89af1Smrg 12533c89af1Smrg SetApplicationActions(app_con); 126ad47b356Smrg XtGetApplicationResources(global_toplevel, (XtPointer) &global_resources, 12733c89af1Smrg editres_resources, XtNumber(editres_resources), 12833c89af1Smrg NULL, (Cardinal) 0); 12933c89af1Smrg global_resources.allocated_save_resources_file = FALSE; 13033c89af1Smrg 13133c89af1Smrg XtOverrideTranslations 132ad47b356Smrg (global_toplevel, 133ad47b356Smrg XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()")); 13433c89af1Smrg 13533c89af1Smrg /* build tree for Xt intrinsics */ 136ad47b356Smrg BuildWidgetTree(global_toplevel); 13733c89af1Smrg 138ad47b356Smrg SetMessage(global_screen_data.info_label, 13933c89af1Smrg res_labels[13]); 14033c89af1Smrg 14133c89af1Smrg global_screen_data.set_values_popup = NULL; 14233c89af1Smrg 14333c89af1Smrg InternAtoms(XtDisplay(global_toplevel)); 14433c89af1Smrg 14533c89af1Smrg XtRealizeWidget(global_toplevel); 14633c89af1Smrg 147ad47b356Smrg wm_delete_window = 14833c89af1Smrg XInternAtom(XtDisplay(global_toplevel), "WM_DELETE_WINDOW", 14933c89af1Smrg False); 150ad47b356Smrg (void) XSetWMProtocols (XtDisplay(global_toplevel), 15133c89af1Smrg XtWindow(global_toplevel), 15233c89af1Smrg &wm_delete_window, 1); 15333c89af1Smrg XtAppMainLoop(app_con); 15433c89af1Smrg exit(0); 15533c89af1Smrg} 15633c89af1Smrg 15733c89af1Smrg/* Function Name: Syntax 15833c89af1Smrg * Description: Prints a the calling syntax for this function to stdout. 15933c89af1Smrg * Arguments: app_con - the application context. 16033c89af1Smrg * call - the name of the application. 161352bf44eSmrg * Returns: none - exits though. 16233c89af1Smrg */ 16333c89af1Smrg 164ad47b356Smrgstatic void 16538d718bdSmrgSyntax(XtAppContext app_con, const char *call, int exit_val) 16633c89af1Smrg{ 16738d718bdSmrg if (app_con != NULL) 16838d718bdSmrg XtDestroyApplicationContext(app_con); 16938d718bdSmrg fprintf(stderr, "Usage: %s [ toolkitoptions ] [-help] [-version]\n", call); 17038d718bdSmrg exit(exit_val); 17133c89af1Smrg} 172