diff options
-rw-r--r-- | dsimple.c | 50 | ||||
-rw-r--r-- | dsimple.h | 39 | ||||
-rw-r--r-- | xlsfonts.c | 91 | ||||
-rw-r--r-- | xlsfonts.man | 7 |
4 files changed, 130 insertions, 57 deletions
@@ -26,25 +26,22 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/xlsfonts/dsimple.c,v 3.6 2001/12/14 20:02:09 dawes Exp $ */ #include <X11/Xos.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> #include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> /* * Other_stuff.h: Definitions of routines in other_stuff. * * Written by Mark Lillibridge. Last updated 7/1/87 */ -unsigned long Resolve_Color(); -Pixmap Bitmap_To_Pixmap(); -Window Select_Window(); -void out(); -void blip(); -Window Window_With_Name(); -void Fatal_Error(); +#include "dsimple.h" /* * Just_display: A group of routines designed to make the writting of simple @@ -58,10 +55,11 @@ void Fatal_Error(); /* This stuff is defined in the calling program by just_display.h */ -extern char *program_name; -extern Display *dpy; -extern int screen; +char *program_name = "unknown_program"; +Display *dpy; +int screen; +static void _bitmap_error(int, char *); /* * Malloc: like malloc but handles out of memory using Fatal_Error. @@ -69,7 +67,7 @@ extern int screen; char *Malloc(size) unsigned size; { - char *data, *malloc(); + char *data; if (!(data = malloc(size))) Fatal_Error("Out of memory!"); @@ -85,7 +83,7 @@ char *Realloc(ptr, size) char *ptr; int size; { - char *new_ptr, *realloc(); + char *new_ptr; if (!ptr) return(Malloc(size)); @@ -326,9 +324,6 @@ Window Select_Window_Args(rargc, argv) * Written by Mark Lillibridge. Last updated 7/1/87 */ -extern Display *dpy; -extern int screen; - /* * Resolve_Color: This routine takes a color name and returns the pixel # * that when used in the window w will be of color name. @@ -402,7 +397,9 @@ Pixmap Bitmap_To_Pixmap(dpy, d, gc, bitmap, width, height) */ void blip() { - outl("blip!"); + fflush(stdout); + fprintf(stderr, "blip!\n"); + fflush(stderr); } @@ -493,13 +490,14 @@ Window Window_With_Name(dpy, top, name) * in code so we can tell where we are. Outl may be invoked like * printf with up to 7 arguments. */ -/* VARARGS1 */ -outl(msg, arg0,arg1,arg2,arg3,arg4,arg5,arg6) - char *msg; - char *arg0, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6; +void +outl(char *msg, ...) { + va_list args; fflush(stdout); - fprintf(stderr, msg, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + va_start(args, msg); + vfprintf(stderr, msg, args); + va_end(args); fprintf(stderr, "\n"); fflush(stderr); } @@ -509,15 +507,15 @@ outl(msg, arg0,arg1,arg2,arg3,arg4,arg5,arg6) * Standard fatal error routine - call like printf but maximum of 7 arguments. * Does not require dpy or screen defined. */ -/* VARARGS1 */ -void Fatal_Error(msg, arg0,arg1,arg2,arg3,arg4,arg5,arg6) -char *msg; -char *arg0, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6; +void Fatal_Error(char *msg, ...) { + va_list args; fflush(stdout); fflush(stderr); fprintf(stderr, "%s: error: ", program_name); - fprintf(stderr, msg, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + va_start(args, msg); + vfprintf(stderr, msg, args); + va_end(args); fprintf(stderr, "\n"); exit(1); } @@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/xlsfonts/dsimple.h,v 1.8 2002/12/24 17:43:01 tsi Exp $ */ /* * Just_display.h: This file contains the definitions needed to use the @@ -40,16 +41,28 @@ from The Open Group. /* Global variables used by routines in just_display.c */ -char *program_name = "unknown_program"; /* Name of this program */ -Display *dpy; /* The current display */ -int screen; /* The current screen */ +extern char *program_name; /* Name of this program */ +extern Display *dpy; /* The current display */ +extern int screen; /* The current screen */ #define INIT_NAME program_name=argv[0] /* use this in main to setup program_name */ /* Declaritions for functions in just_display.c */ -void Fatal_Error(); +#if NeedFunctionPrototypes +char *Malloc(unsigned); +char *Realloc(char *, int); +char *Get_Display_Name(int *, char **); +Display *Open_Display(char *); +void Setup_Display_And_Screen(int *, char **); +XFontStruct *Open_Font(char *); +void Beep(void); +Pixmap ReadBitmapFile(Drawable, char *, int *, int *, int *, int *); +void WriteBitmapFile(char *, Pixmap, int, int, int, int); +Window Select_Window_Args(int *, char **); +void usage(void); +#else char *Malloc(); char *Realloc(); char *Get_Display_Name(); @@ -60,10 +73,11 @@ void Beep(); Pixmap ReadBitmapFile(); void WriteBitmapFile(); Window Select_Window_Args(); +void usage(); +#endif #define X_USAGE "[host:display]" /* X arguments handled by Get_Display_Name */ -#define SELECT_USAGE "[{-root|-id <id>|-font <font>|-name <name>}]" /* * Other_stuff.h: Definitions of routines in other_stuff. @@ -73,9 +87,22 @@ Window Select_Window_Args(); * Send bugs, etc. to chariot@athena.mit.edu. */ +#if NeedFunctionPrototypes +unsigned long Resolve_Color(Window, char *); +Pixmap Bitmap_To_Pixmap(Display *, Drawable, GC, Pixmap, int, int); +Window Select_Window(Display *); +void blip(void); +Window Window_With_Name(Display *, Window, char *); +#else unsigned long Resolve_Color(); Pixmap Bitmap_To_Pixmap(); Window Select_Window(); -void out(); void blip(); Window Window_With_Name(); +#endif +#ifdef __GNUC__ +void Fatal_Error(char *, ...) __attribute__((__noreturn__)); +#else +void Fatal_Error(char *, ...); +#endif +void outl(char *, ...); @@ -24,11 +24,13 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/xlsfonts/xlsfonts.c,v 1.8 2001/12/14 20:02:10 dawes Exp $ */ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <stdio.h> +#include <stdlib.h> #include "dsimple.h" #define N_START 1000 /* Maximum # of fonts to start with */ @@ -55,6 +57,25 @@ typedef struct { FontList *font_list; +#if NeedFunctionPrototypes +extern void usage(void); +extern int main(int, char **); +extern void get_list(char *); +extern void show_fonts(void); +extern void copy_number(char **, char **, int, int); +extern void do_query_font(Display *, char *); +static int compare(const void *, const void *); +#ifndef max +static int max(int, int); +#endif +static int IgnoreError(Display *, XErrorEvent *); +static void PrintProperty(XFontProp *); +static void ComputeFontType(XFontStruct *); +static void print_character_metrics(register XFontStruct *); +#endif + + +void usage() { fprintf (stderr,"usage: %s [-options] [-fn pattern]\n", program_name); @@ -82,6 +103,7 @@ usage() exit(1); } +int main(argc, argv) int argc; char **argv; @@ -149,6 +171,7 @@ char **argv; exit(0); } +void get_list(pattern) char *pattern; { @@ -204,17 +227,22 @@ get_list(pattern) } } -compare(f1, f2) - FontList *f1, *f2; +static int +compare(arg1, arg2) + const void *arg1; + const void *arg2; { - char *p1 = f1->name, - *p2 = f2->name; + const FontList *f1 = arg1; + const FontList *f2 = arg2; + const char *p1 = f1->name; + const char *p2 = f2->name; while (*p1 && *p2 && *p1 == *p2) p1++, p2++; return(*p1 - *p2); } +void show_fonts() { int i; @@ -371,6 +399,8 @@ show_fonts() printf("%s\n", font_list[i].name); } +#ifndef max +static int max(i, j) int i, j; { @@ -378,7 +408,9 @@ max(i, j) return (i); return(j); } +#endif +void copy_number(pp1, pp2, n1, n2) char **pp1, **pp2; int n1, n2; @@ -423,27 +455,37 @@ static char *bounds_metrics_fmt = static char* stringValued [] = { /* values are atoms */ - "FAMILY_NAME", + /* font name components (see section 3.2 of the XLFD) */ "FOUNDRY", - "STYLE", - "MONOSPACED", - "RELATIVE_WEIGHT", - "RELATIVE_SET", - "CLASSIFICATION", - "CHARSET_REGISTRY", - "CHARSET_ENCODING", - "QUALITY", - "CHARSET_COLLECTIONS", - "FULL_NAME", - "COPYRIGHT", + "FAMILY_NAME", "WEIGHT_NAME", - "SETWIDTH_NAME", "SLANT", - "SPACING", + "SETWIDTH_NAME", "ADD_STYLE_NAME", - "FONTNAME_REGISTRY", + "SPACING", + "CHARSET_REGISTRY", + "CHARSET_ENCODING", + + /* other standard X font properties (see section 3.2 of the XLFD) */ "FONT", + "FACE_NAME", + "FULL_NAME", /* deprecated */ + "COPYRIGHT", + "NOTICE", + "FONT_TYPE", + "FONT_VERSION", + "RASTERIZER_NAME", + "RASTERIZER_VERSION", + + /* unregistered font properties */ + "CHARSET_COLLECTIONS", + "CLASSIFICATION", "DEVICE_FONT_NAME", + "FONTNAME_REGISTRY", + "MONOSPACED", + "QUALITY", + "RELATIVE_SET", + "STYLE", NULL }; @@ -453,25 +495,25 @@ static void PrintProperty (prop) char *atom, *value; char nosuch[40]; int i; - int (*oldhandler)() = XSetErrorHandler (IgnoreError); + XErrorHandler oldhandler = XSetErrorHandler(IgnoreError); atom = XGetAtomName(dpy, prop->name); if (!atom) { atom = nosuch; nosuch[0] = '\0'; - (void)sprintf (atom, "No such atom = %d", prop->name); + (void)sprintf (atom, "No such atom = %ld", prop->name); } printf (" %s", atom); for (i = strlen(atom); i < 22; i++) printf (" "); for (i = 0; ; i++) { if (stringValued[i] == NULL) { - printf ("%d\n", prop->card32); + printf ("%ld\n", prop->card32); break; } if (strcmp(stringValued[i], atom) == 0) { value = XGetAtomName(dpy, prop->card32); if (value == NULL) - printf ("%d (expected string value)\n", prop->card32); + printf ("%ld (expected string value)\n", prop->card32); else { printf ("%s\n", value); XFree (value); @@ -484,6 +526,7 @@ static void PrintProperty (prop) } +static void ComputeFontType (fs) XFontStruct *fs; { @@ -552,6 +595,7 @@ ComputeFontType (fs) } +static void print_character_metrics (info) register XFontStruct *info; { @@ -576,6 +620,7 @@ print_character_metrics (info) } +void do_query_font (dpy, name) Display *dpy; char *name; diff --git a/xlsfonts.man b/xlsfonts.man index 9ac6a24..056398c 100644 --- a/xlsfonts.man +++ b/xlsfonts.man @@ -22,7 +22,10 @@ .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from The Open Group. -.TH XLSFONTS 1 "Release 6.4" "X Version 11" +.\" +.\" $XFree86: xc/programs/xlsfonts/xlsfonts.man,v 1.8 2001/12/14 20:02:10 dawes Exp $ +.\" +.TH XLSFONTS 1 __xorgversion__ .SH NAME xlsfonts \- server font list displayer for X .SH SYNOPSIS @@ -87,7 +90,7 @@ font (as is the case with some scaled font systems). This option specifies the font name pattern to match. .PP .SH "SEE ALSO" -X(1), Xserver(1), xset(1), xfd(1), +X(__miscmansuffix__), Xserver(1), xset(1), xfd(1), .I "X Logical Font Description Conventions" .SH ENVIRONMENT .TP 8 |