| 1 |
/* $XConsortium: dainput.c /main/5 1995/07/15 20:47:20 drk $ */ |
| 2 |
/* |
| 3 |
* Motif |
| 4 |
* |
| 5 |
* Copyright (c) 1987-2012, The Open Group. All rights reserved. |
| 6 |
* |
| 7 |
* These libraries and programs are free software; you can |
| 8 |
* redistribute them and/or modify them under the terms of the GNU |
| 9 |
* Lesser General Public License as published by the Free Software |
| 10 |
* Foundation; either version 2 of the License, or (at your option) |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* These libraries and programs are distributed in the hope that |
| 14 |
* they will be useful, but WITHOUT ANY WARRANTY; without even the |
| 15 |
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 |
* PURPOSE. See the GNU Lesser General Public License for more |
| 17 |
* details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU Lesser General Public |
| 20 |
* License along with these librararies and programs; if not, write |
| 21 |
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth |
| 22 |
* Floor, Boston, MA 02110-1301 USA |
| 23 |
* |
| 24 |
*/ |
| 25 |
/* |
| 26 |
* HISTORY |
| 27 |
*/ |
| 28 |
|
| 29 |
#include <stdio.h> |
| 30 |
#include <stdlib.h> |
| 31 |
#include <ctype.h> |
| 32 |
#include <string.h> |
| 33 |
#include <locale.h> |
| 34 |
|
| 35 |
#include <X11/Intrinsic.h> |
| 36 |
#include <Xm/Xm.h> /* to get _NO_PROTO */ |
| 37 |
|
| 38 |
#include "dainput.h" |
| 39 |
|
| 40 |
|
| 41 |
/**************************************************************** |
| 42 |
* base: |
| 43 |
****************************************************************/ |
| 44 |
static char *base(char *str) |
| 45 |
{ |
| 46 |
static char basename[300]; |
| 47 |
char *p; |
| 48 |
|
| 49 |
if ((p = strrchr(str, '/'))) |
| 50 |
(void) strcpy(basename, p+1); |
| 51 |
else |
| 52 |
(void) strcpy(basename, str); |
| 53 |
if ((p = strrchr(basename, '.'))) |
| 54 |
*p ='\0'; |
| 55 |
return basename; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
/************************************************************** |
| 60 |
* main: |
| 61 |
**************************************************************/ |
| 62 |
int main(int argc, char **argv) |
| 63 |
{ |
| 64 |
XtAppContext app_context; |
| 65 |
Display * display; |
| 66 |
Widget top_level; |
| 67 |
char * aclass = "XmdDaInput"; |
| 68 |
char name[132]; |
| 69 |
char ** temp_argv = argv; |
| 70 |
|
| 71 |
|
| 72 |
(void) strncpy(name, base(argv[0]), 132); |
| 73 |
|
| 74 |
/* handle the '-name' option */ |
| 75 |
while (*temp_argv) { |
| 76 |
if (strcmp(*temp_argv, "-name") == 0) { |
| 77 |
(void) strncpy(name, *++temp_argv, 132); |
| 78 |
break; |
| 79 |
} |
| 80 |
temp_argv++; |
| 81 |
} |
| 82 |
|
| 83 |
/* Initialize the X Intrinsics */ |
| 84 |
XtToolkitInitialize(); |
| 85 |
|
| 86 |
/* Set up language environment */ |
| 87 |
XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); |
| 88 |
|
| 89 |
/* create application context */ |
| 90 |
app_context = XtCreateApplicationContext(); |
| 91 |
|
| 92 |
/* open up one display */ |
| 93 |
display = XtOpenDisplay(app_context, |
| 94 |
NULL, |
| 95 |
name, aclass, |
| 96 |
(XrmOptionDescRec *)NULL, 0, |
| 97 |
&argc, argv); |
| 98 |
if (!display) { |
| 99 |
(void) fprintf(stderr, "Unable to open display\n"); |
| 100 |
exit(0); |
| 101 |
} |
| 102 |
|
| 103 |
/* Create the user interface */ |
| 104 |
top_level = DaCreateGui(name, aclass, argc, argv, display); |
| 105 |
if (top_level == NULL) { |
| 106 |
(void) fprintf(stderr, "Unable to create user interface\n"); |
| 107 |
exit(1); |
| 108 |
} |
| 109 |
|
| 110 |
/* Realize and start event dispatching */ |
| 111 |
XtRealizeWidget(top_level); |
| 112 |
XtAppMainLoop(app_context); |
| 113 |
|
| 114 |
return 0; /* make compiler happy */ |
| 115 |
} |
| 116 |
|