--- chkfontpath-1.10.1/man/en/chkfontpath.8.noxfs~ 2001-01-18 22:45:17.000000000 +0100 +++ chkfontpath-1.10.1/man/en/chkfontpath.8 2006-11-25 15:09:34.000000000 +0100 @@ -1,7 +1,7 @@ .de FN \fI\|\\$1\|\fP .. -.TH CHKFONTPATH 8 "Thu Jan 18 2001" "Linux" "Red Hat, Inc." +.TH CHKFONTPATH 8 "Sat Nov 25 2006" "Linux" "Ark Linux" .UC 4 .SH NAME chkfontpath \- simple interface for adding, removing, and listing @@ -14,10 +14,7 @@ .SH DESCRIPTION .PP \fBchkfontpath\fR provides a simple method of configuring the directories -contained in the X font server's path. As of Red Hat 6.0, all fonts in X -are served via this separate font server process, not through the main -X server process. This speeds up font rendering, and also allows use -of font servers which are not running on the local host. +contained in the X server or X font server's path. .PP \fBchkfontpath\fR is mainly used by \fBrpm\fR in its \fB%post\fR and \fB%postun\fR sections to add and remove new directories to the server's @@ -42,6 +39,10 @@ Requires usage of the \fBadd\fR command; puts the specified directory first in the font path, rather than last. .TP +\fB-x\fR, \fB--xfs\fR +Use the xfs font server instead of editing the XFree86 configuration +directly. +.TP \fB-h\fR, \fB--help\fR Show detailed help on the command line. @@ -60,22 +61,26 @@ .SH FILES .PD 0 .TP +.FN /etc/X11/xorg.conf +Configuration file for X.org .TP .FN /etc/X11/fs/config Configuration file for the X font server (xfs). .PD .SH "SEE ALSO" -.BR xfs (1), fslsfonts (1) +.BR xlsfonts (1), xfs (1), fslsfonts (1) .SH AUTHOR .nf Written by Preston Brown <pbrown@redhat.com> +Adapted to work without xfs by Bernhard Rosenkraenzer <bero@arklinux.org> .fi .SH "REPORTING BUGS" -Report bugs to <http://bugzilla.redhat.com>. +Report bugs to http://bugzilla.arklinux.org/. .SH COPYRIGHT Copyright \(co 1999-2001 Red Hat, Inc. All rights reserved. +Copyright \(co 2002-2006 Ark Linux .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTIBILITY or FITNESS FOR A PARTICULAR --- chkfontpath-1.10.1/chkfontpath.c.noxfs~ 2006-02-16 14:50:38.000000000 +0100 +++ chkfontpath-1.10.1/chkfontpath.c 2006-11-25 15:08:03.000000000 +0100 @@ -2,7 +2,9 @@ * chkfontpath - utility for manipulating X Font Server font paths * * Copyright (C) 1998-2003 Red Hat, Inc. - * Author: Preston Brown <pbrown@redhat.com> + * Copyright (C) 2002-2006 Ark Linux + * Author (RH): Preston Brown <pbrown@redhat.com> + * Author (Ark Linux version): Bernhard Rosenkraenzer <bero@arklinux.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -20,6 +22,7 @@ * Boston, MA 02111-1307, USA. */ +#define _GNU_SOURCE 1 /* for isblank */ #include <ctype.h> #include <signal.h> #include <stdarg.h> /* For variadic functions */ @@ -32,16 +35,24 @@ #include <popt.h> #include <locale.h> -#define XFS_CONFIGFILE "/etc/X11/fs/config" -#define XFS_CONFIGBACKUP "/etc/X11/fs/config-" +static const char *xfsConfigFile = "/etc/X11/fs/config"; +static const char *xfsBackupFile = "/etc/X11/fs/config-"; #define XFS_PIDFILE "/var/run/xfs.pid" #define XFS_SUBSYSLOCK "/var/lock/subsys/xfs" +static const char *xorgConfigFile = "/etc/X11/xorg.conf"; +static const char *xorgBackupFile = "/etc/X11/xorg.conf-"; +static const char *tmpFile = "/tmp/chkfontpath.todo"; +static const char *tmpBackup = "/tmp/chkfontpath.todo-"; + +static const char *configFile; +static const char *configBackup; static char *progName; static const char **fpList; static int fpCount; static int quiet; static int firstdir; +static int use_xfs; void fatalerror(const char *format, ...) { @@ -62,9 +73,10 @@ char *s, *p, *q; int catFlag = 0; int noFirstLine = 0; + int inFileSection = 0; - if (NULL == (f = fopen(XFS_CONFIGFILE, "r"))) - fatalerror("%s: error opening %s\n", progName, XFS_CONFIGFILE); + if (NULL == (f = fopen(configFile, "r"))) + fatalerror("%s: error opening %s\n", progName, configFile); while ((q = s = fgets(buf, sizeof(buf)-1, f)) != NULL) { @@ -81,6 +93,7 @@ if (*s == '#') continue; + if (use_xfs) { /* find the catalogue line */ if (strstr(s, "catalogue") && !catFlag) { catFlag = 1; @@ -130,6 +143,37 @@ if (catFlag && (s[strlen(s)-2] != ',')) catFlag = 0; + } else /* use_xfs */ { + /* find the 'Section "Files"' line */ + if (!inFileSection && (p = strstr(s, "Section")) != NULL) { + if (strstr(p, "Files")) { + inFileSection = 1; + continue; + } + } else if (inFileSection && strstr(s, "EndSection")) { + inFileSection = 0; + continue; // can there be > 1 "Files" sections?? + } +#ifdef DEBUG + printf("inFileSection: %d, q: %c, string: %s\n", (inFileSection?1:0), *q, q); +#endif + if (inFileSection) { + if ((q = strstr(s, "FontPath")) != NULL) { + q += 8; + while (isblank(*q)) q++; + if(*q == '"') q++; + /* now we should be at the font path */ + fpCount++; + p = strdup(q); + if (p[strlen(p)-1] == '\n') + p[strlen(p)-1] = 0; + if (p[strlen(p)-1] == '"') + p[strlen(p)-1] = 0; + fpList = (const char **) realloc(fpList, sizeof(char*) * fpCount); + fpList[fpCount - 1]=p; + } + } + } } fclose(f); @@ -139,30 +183,32 @@ { FILE *f, *f1; char buf[250]; - char *s, *p; + char *s, *p, *q; int catFlag = 0, i; + int inFileSection = 0; struct stat sb; - stat(XFS_CONFIGFILE, &sb); + stat(configFile, &sb); - if (NULL == (f = fopen(XFS_CONFIGFILE, "r"))) - fatalerror("%s: error opening %s for reading\n", progName, XFS_CONFIGFILE); + if (NULL == (f = fopen(configFile, "r"))) + fatalerror("%s: error opening %s for reading\n", progName, configFile); - if (NULL == (f1 = fopen(XFS_CONFIGBACKUP, "w"))) - fatalerror("%s: error opening %s for writing\n", progName, XFS_CONFIGBACKUP); + if (NULL == (f1 = fopen(configBackup, "w"))) + fatalerror("%s: error opening %s for writing\n", progName, configBackup); while ((s = fgets(buf, sizeof(buf), f)) != NULL) { - p = s; + p = q = s; /* strip leading white space */ while (isblank(*s)) s++; /* skip all comment lines */ if (*s == '#') { - fputs(s, f1); + fputs(q, f1); continue; } + if (use_xfs) { if (strstr(s, "catalogue") && !catFlag) { catFlag = 1; p = strchr(s, '='); @@ -187,13 +233,34 @@ if (catFlag && (s[0] == '\n' || s[strlen(s)-2] != ',')) { catFlag = 0; } + } else /* use_xfs */ { + if (!inFileSection && (p = strstr(s, "Section")) != NULL ) { + if (strstr(p, "Files")) { + inFileSection = 1; + fputs(q, f1); + for (i=0; i<fpCount; i++) { + fprintf(f1, "\tFontPath\t\"%s\"\n", fpList[i]); + } + continue; + } + } else if(inFileSection && strstr(s, "EndSection")) { + inFileSection = 0; + fputs(q, f1); + continue; /* can there be > 1 "Files" sections?? */ + } else if(inFileSection && !strstr(s, "FontPath")) { + fputs(q, f1); + continue; + } + if(!inFileSection) + fputs(q, f1); + } } fclose(f); fclose(f1); - unlink(XFS_CONFIGFILE); - rename(XFS_CONFIGBACKUP, XFS_CONFIGFILE); - chmod(XFS_CONFIGFILE, sb.st_mode); + unlink(configFile); + rename(configBackup, configFile); + chmod(configFile, sb.st_mode); } void addDir(const char *newDir) @@ -372,6 +439,7 @@ int rc, list = 0, listfp = 0, help = 0; poptContext optCon; char *newDir = NULL, *delDir = NULL; + struct stat st; const struct poptOption options[] = { { "add", 'a', POPT_ARG_STRING, &newDir, 0, "add directory to font path", "name of directory to add" }, { "remove", 'r', POPT_ARG_STRING, &delDir, 0, "remove directory from font path", "name of directory to remove" }, @@ -379,6 +447,7 @@ { "listfp", 'm', 0, &listfp, 0, "display list of font path elements in machine parseable form", NULL }, { "quiet", 'q', 0, &quiet, 0, "quiet operation; don't print anything to the screen", NULL }, { "first", 'f', 0, &firstdir, 0, "--add puts the directory first (not last) in the path", NULL }, + { "xfs", 'x', 0, &use_xfs, 0, "Use xfs (X Font Server) instead of xorg.conf", NULL }, { "help", 'h', 0, &help, 0, "show this help", NULL }, { 0, 0, 0, 0, 0, NULL, NULL } }; @@ -410,6 +479,49 @@ poptPrintHelp(optCon, stdout, 0); exit(0); } + + if (use_xfs) { + configFile=xfsConfigFile; + configBackup=xfsBackupFile; + } else { + configFile=xorgConfigFile; + configBackup=xorgBackupFile; + } + + if(stat(configFile, &st) || st.st_size < 10) { + /* We're either in installation, before the XFree86 configuration + * is created, or we're on a badly messed up system in recovery mode. + * Let's leave a clue on what was supposed to be done. + */ + FILE *f=fopen(tmpFile, "r"); + FILE *f2=fopen(tmpBackup, "w"); + if(f) { + char buf[1024]; + while(fgets(buf, 1024, f)) { + if(strncmp(buf, "rm ", 3)) + fputs(buf, f2); + } + fclose(f); + } else + fputs("#!/bin/sh\n" + "# chkfontpath commands called without an existing config file.\n" + "# Run this script once your base config files are in place.\n", f2); + fprintf(f2, "/usr/sbin/chkfontpath %s %s %s %s %s %s %s %s\n", + use_xfs ? "--xfs" : "", + list ? "--list" : "", + quiet ? "--quiet" : "", + firstdir ? "--first" : "", + newDir ? "--add" : "", + newDir ? newDir : "", + delDir ? "--remove" : "", + delDir ? delDir : ""); + fputs("rm $0", f2); + fchmod(fileno(f2), 0755); + fclose(f2); + unlink(tmpFile); + rename(tmpBackup, tmpFile); + exit(0); + } poptFreeContext(optCon); @@ -431,7 +543,10 @@ if (newDir != NULL || delDir != NULL) { writeNewConfig(); - restartXfs(); + if(use_xfs) + restartXfs(); + else + system("/usr/bin/xset fb rehash &>/dev/null || :"); } return 0;