1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/* misc.c - miscellaneous functions for xtartan
* by Jim McBeath (jimmc@hisoft.uucp), Anselm Lingnau (lingnau@debian.org)
*
* 7.Jan.88 jimmc Initial definition (X10)
* 24.Oct.89 jimmc Convert to X11, Xt; general restructuring
* 9.Jan.91 jimmc v2.0: Split out tartan data stuff to tartan.c
* 26.May.03 lingnau Changed to use stdarg.h
*/
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
extern char *Progname;
extern Display *TDisplay;
void Bell()
{
XBell(TDisplay,0);
}
/* VARARGS1 - like printf */
void Warn(char *fmt, ...) /* print message */
{
va_list pvar;
va_start(pvar, fmt);
(void)fprintf(stderr,"%s: ",Progname);
(void)vfprintf(stderr,fmt,pvar);
(void)fprintf(stderr,"\n");
va_end(pvar);
}
/* VARARGS1 - like printf */
void Fatal(char *fmt, ...) /* print message and exit */
{
va_list pvar;
va_start(pvar, fmt);
(void)fprintf(stderr,"%s: ",Progname);
(void)vfprintf(stderr,fmt,pvar);
(void)fprintf(stderr,"\n");
va_end(pvar);
exit(1);
}
char *
GetSubResource(widget,sub,name)
Widget widget;
char *sub, *name;
{
String string;
static XtResource resources[] = {
{ "", "", XtRString, sizeof(String),
0, XtRString, NULL},
};
XtResource *tresource;
tresource = (XtResource *)XtMalloc(sizeof(resources));
tresource[0] = resources[0];
tresource->resource_name = name;
tresource->resource_class = name;
XtGetSubresources(widget, &string, sub, sub,
tresource, (Cardinal)1, (ArgList)NULL, (Cardinal)0 );
XtFree((char *)tresource);
return string;
}
String
GetStringResource(widget, resourcename)
Widget widget;
char *resourcename; /* what to look up in the file */
{
String string;
static XtResource resources[] = {
{ "", "", XtRString, sizeof(String),
0, XtRString, (caddr_t)NULL}
};
XtResource *tresource;
tresource = (XtResource *)XtMalloc(sizeof(resources));
tresource[0] = resources[0];
tresource->resource_name = resourcename;
tresource->resource_class = resourcename;
XtGetApplicationResources( widget, &string,
tresource, (Cardinal)1, (ArgList)NULL, (Cardinal)0 );
XtFree((char *)tresource);
return string;
}
/* end */
|