summaryrefslogtreecommitdiff
path: root/Xprint/Init.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xprint/Init.c')
-rw-r--r--Xprint/Init.c259
1 files changed, 96 insertions, 163 deletions
diff --git a/Xprint/Init.c b/Xprint/Init.c
index 06757fa77..a022c31c7 100644
--- a/Xprint/Init.c
+++ b/Xprint/Init.c
@@ -50,6 +50,7 @@ copyright holders.
** *********************************************************
**
********************************************************************/
+/* $XFree86: xc/programs/Xserver/Xprint/Init.c,v 1.13 2001/12/21 21:02:04 dawes Exp $ */
#include <unistd.h>
#include <stdlib.h>
@@ -74,53 +75,23 @@ copyright holders.
#include "cursor.h"
#include "misc.h"
#include "windowstr.h"
-#include "scrnintstr.h"
#include "inputstr.h"
#include "gcstruct.h"
#include "fonts/fontstruct.h"
#include "errno.h"
-#define _XP_PRINT_SERVER_
-#include "Printstr.h"
-#undef _XP_PRINT_SERVER_
-
typedef char *XPointer;
+#define HAVE_XPointer 1
+
#define Status int
#include <Xresource.h>
#include "DiPrint.h"
-#include "AttrValid.h"
#include "attributes.h"
-extern char *display; /* display number as a string */
-
-#if 0
-/* extern char *Xalloc(); */
-extern void Xfree();
-/* extern char *Xrealloc(); */
-#else
#include "os.h"
-#endif
-
-extern char *getenv();
-extern void XpAddPrinterAttribute();
-extern char *XpGetConfigDir();
-extern XpContextPtr XpContextOfClient();
-
-/*
-extern int GiveUp();
-*/
-
-extern WindowPtr *WindowTable; /* declared in dix:globals.c */
-
-#if NeedFunctionPrototypes
-
-static void GetDriverFromPrinterName(
- char *printerName,
- char **driverName,
- Bool (**initScreenFunc)());
static void GenericScreenInit(
int index,
ScreenPtr pScreen,
@@ -132,15 +103,6 @@ static Bool InitPrintDrivers(
int argc,
char **argv);
-#else
-
-static void GetDriverFromPrinterName();
-static void GenericScreenInit();
-static Bool InitPrintDrivers();
-
-#endif
-
-
/*
* The following two defines are used to build the name "X*printers", where
* the "*" is replaced by the display number. This is used to construct
@@ -188,7 +150,7 @@ const char *LIST_QUEUES = "LANG=C lpstat -v | "
" print substr($5, 1, x-1)"
" }' | sort";
#else
-#if defined(CSRG_BASED) || defined(linux)
+#if defined(CSRG_BASED) || defined(linux) || defined(ISC) || defined(__GNUC__)
const char *LIST_QUEUES = "LANG=C lpc status | grep -v '^\t' | "
"sed -e /:/s/// | sort";
#else
@@ -209,12 +171,11 @@ const char *LIST_QUEUES = "LANG=C lpstat -v | "
static
PixmapFormatRec RasterPixmapFormats[] = {
- 1, 1, BITMAP_SCANLINE_PAD
+ { 1, 1, BITMAP_SCANLINE_PAD }
};
#define NUMRASTFORMATS (sizeof RasterPixmapFormats)/(sizeof RasterPixmapFormats[0])
-extern Bool InitializeRasterDriver();
-extern XpValidatePoolsRec RasterValidatePoolsRec; /* From RasterAttVal.c */
+#include "raster/Raster.h"
#endif
@@ -222,51 +183,45 @@ extern XpValidatePoolsRec RasterValidatePoolsRec; /* From RasterAttVal.c */
static
PixmapFormatRec ColorPclPixmapFormats[] = {
- 1, 1, BITMAP_SCANLINE_PAD,
- 8, 8, BITMAP_SCANLINE_PAD,
- 24,32, BITMAP_SCANLINE_PAD
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 24,32, BITMAP_SCANLINE_PAD }
};
#define NUMCPCLFORMATS (sizeof ColorPclPixmapFormats)/(sizeof ColorPclPixmapFormats[0])
-extern Bool InitializeColorPclDriver();
-extern XpValidatePoolsRec PclValidatePoolsRec;
-
#endif
#ifdef XPMONOPCLDDX
static
PixmapFormatRec MonoPclPixmapFormats[] = {
- 1, 1, BITMAP_SCANLINE_PAD
+ { 1, 1, BITMAP_SCANLINE_PAD }
};
#define NUMMPCLFORMATS (sizeof MonoPclPixmapFormats)/(sizeof MonoPclPixmapFormats[0])
-extern Bool InitializeMonoPclDriver();
-extern XpValidatePoolsRec PclValidatePoolsRec;
+#endif
+#if defined(XPPCLDDX) || defined(XPMONOPCLDDX)
+#include "pcl/Pcl.h"
#endif
#ifdef XPPSDDX
static
PixmapFormatRec PSPixmapFormats[] = {
- 1, 1, BITMAP_SCANLINE_PAD,
- 8, 8, BITMAP_SCANLINE_PAD,
- 24,32, BITMAP_SCANLINE_PAD
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 24,32, BITMAP_SCANLINE_PAD }
};
#define NUMPSFORMATS (sizeof PSPixmapFormats)/(sizeof PSPixmapFormats[0])
-extern Bool InitializePsDriver();
-extern XpValidatePoolsRec PsValidatePoolsRec;
+#include "ps/Ps.h"
#endif
-
-typedef Bool (*pBFunc)();
-typedef void (*pVFunc)();
/*
* The driverInitArray contains an entry for each driver the
* server knows about. Each element contains pointers to pixmap formats, the
@@ -375,10 +330,6 @@ static const char configFilePath[] =
static const char printServerConfigDir[] = "XPSERVERCONFIGDIR";
-static int printScreenPrivIndex,
- printWindowPrivIndex,
- printGCPrivIndex;
-static unsigned long printGeneration = 0;
static char *configFileName = (char *)NULL;
static Bool freeDefaultFontPath = FALSE;
static char *origFontPath = (char *)NULL;
@@ -389,12 +340,11 @@ static char *origFontPath = (char *)NULL;
* of the next option to process.
*/
int
-XprintOptions(argc, argv, i)
- int argc;
- char **argv;
- int i;
+XprintOptions(
+ int argc,
+ char **argv,
+ int i)
{
- extern void ddxUseMsg();
if(strcmp(argv[i], "-XpFile") == 0)
{
if ((i + 1) >= argc) {
@@ -427,9 +377,7 @@ static pIFunc
GetInitFunc(driverName)
*/
-static Bool (*
-GetInitFunc(driverName))()
- char *driverName;
+static pBFunc GetInitFunc(char *driverName)
{
driverInitRec *pInitRec;
int numDrivers = sizeof(driverInits)/sizeof(driverInitRec);
@@ -441,7 +389,7 @@ GetInitFunc(driverName))()
return pInitRec->initFunc;
}
- return (Bool(*)())NULL;
+ return 0;
}
static void
@@ -464,17 +412,17 @@ GetDimFuncAndRec(
}
}
- *dimensionsFunc = (pVFunc)NULL;
- *pValRec = (XpValidatePoolsRec *)NULL;
+ *dimensionsFunc = 0;
+ *pValRec = 0;
return;
}
static void
-FreePrinterDb()
+FreePrinterDb(void)
{
PrinterDbPtr pCurEntry, pNextEntry;
- for(pCurEntry = printerDb, pNextEntry = (PrinterDbPtr)NULL;
+ for(pCurEntry = printerDb, pNextEntry = 0;
pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pNextEntry)
{
pNextEntry = pCurEntry->next;
@@ -486,7 +434,7 @@ FreePrinterDb()
*/
xfree(pCurEntry);
}
- printerDb = (PrinterDbPtr)NULL;
+ printerDb = 0;
}
/*
@@ -496,8 +444,7 @@ FreePrinterDb()
* XXX AddPrinterDbName needs to check for (and not add) duplicate names.
*/
static Bool
-AddPrinterDbName(name)
- char *name;
+AddPrinterDbName(char *name)
{
PrinterDbPtr pEntry = (PrinterDbPtr)xalloc(sizeof(PrinterDbEntry));
@@ -519,8 +466,7 @@ AddPrinterDbName(name)
}
static void
-AugmentPrinterDb(command)
- char *command;
+AugmentPrinterDb(const char *command)
{
FILE *fp;
char name[256];
@@ -539,7 +485,7 @@ AugmentPrinterDb(command)
* FreeNameMap frees all remaining memory associated with the nameMap.
*/
static void
-FreeNameMap()
+FreeNameMap(void)
{
NameMapPtr pEntry, pTmp;
@@ -561,9 +507,7 @@ FreeNameMap()
* AddNameMap adds an element to the nameMap linked list.
*/
static Bool
-AddNameMap(name, qualifier)
- char *name;
- char *qualifier;
+AddNameMap(char *name, char *qualifier)
{
NameMapPtr pEntry;
@@ -585,7 +529,7 @@ AddNameMap(name, qualifier)
* is NULLed out.
*/
static void
-MergeNameMap()
+MergeNameMap(void)
{
NameMapPtr pMap;
PrinterDbPtr pDb;
@@ -608,7 +552,7 @@ MergeNameMap()
* each printer in the printerDb.
*/
static void
-CreatePrinterAttrs()
+CreatePrinterAttrs(void)
{
PrinterDbPtr pDb;
@@ -642,7 +586,7 @@ CreatePrinterAttrs()
* the screens.
*/
static void
-StoreDriverNames()
+StoreDriverNames(void)
{
PrinterDbPtr pEntry;
@@ -653,7 +597,7 @@ StoreDriverNames()
"xp-ddx-identifier");
if(pEntry->driverName == (char *)NULL ||
strlen(pEntry->driverName) == 0 ||
- GetInitFunc(pEntry->driverName) == (Bool(*)())NULL)
+ GetInitFunc(pEntry->driverName) == 0)
{
if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) {
ErrorF("Xp Extension: Can't load driver %s\n",
@@ -670,7 +614,7 @@ StoreDriverNames()
}
}
-char *
+static char *
MbStrchr(
char *str,
int ch)
@@ -699,7 +643,7 @@ MbStrchr(
* string must be freed by the caller.
*/
static char *
-GetConfigFileName()
+GetConfigFileName(void)
{
/*
* We need to find the system-wide file, if one exists. This
@@ -711,7 +655,7 @@ GetConfigFileName()
/*
* Check for a LANG-specific file.
*/
- if(dirName = XpGetConfigDir(TRUE))
+ if ((dirName = XpGetConfigDir(TRUE)) != 0)
{
filePath = (char *)xalloc(strlen(dirName) +
strlen(XPRINTERSFILENAME) + 2);
@@ -730,7 +674,7 @@ GetConfigFileName()
xfree(filePath);
}
- if(dirName = XpGetConfigDir(FALSE))
+ if ((dirName = XpGetConfigDir(FALSE)) != 0)
{
filePath = (char *)xalloc(strlen(dirName) +
strlen(XPRINTERSFILENAME) + 2);
@@ -760,9 +704,8 @@ GetConfigFileName()
* XXX
*/
static PrinterDbPtr
-BuildPrinterDb()
+BuildPrinterDb(void)
{
- char *printerList, *augmentCmd = (char *)NULL;
Bool defaultAugment = TRUE, freeConfigFileName;
if(configFileName && access(configFileName, R_OK) != 0)
@@ -789,7 +732,7 @@ BuildPrinterDb()
{
while((tok = strtok((char *)NULL, " \t")) != (char *)NULL)
{
- if(ptr = MbStrchr(tok, '\012'))
+ if ((ptr = MbStrchr(tok, '\012')) != 0)
*ptr = (char)'\0';
AddPrinterDbName(tok);
}
@@ -855,8 +798,7 @@ BuildPrinterDb()
}
static void
-FreeDriverMap(driverMap)
- DriverMapPtr driverMap;
+FreeDriverMap(DriverMapPtr driverMap)
{
DriverMapPtr pCurEntry, pNextEntry;
@@ -882,7 +824,7 @@ FreeDriverMap(driverMap)
* the next rehash or server recycle.
*/
int
-XpRehashPrinterList()
+XpRehashPrinterList(void)
{
PrinterDbPtr pEntry, pPrev;
DriverMapPtr driverMap = (DriverMapPtr)NULL, pDrvEnt;
@@ -1014,7 +956,7 @@ FindFontDir(
return (char *)NULL;
configDir = XpGetConfigDir(TRUE);
- if(fontDir = ValidateFontDir(configDir, modelName))
+ if ((fontDir = ValidateFontDir(configDir, modelName)) != 0)
{
xfree(configDir);
return fontDir;
@@ -1074,10 +1016,10 @@ AddToFontPath(
* and to properly free the modified version upon server recycle.
*/
static void
-AugmentFontPath()
+AugmentFontPath(void)
{
- char *newPath, *modelID, **allIDs = (char **)NULL;
- PrinterDbPtr pDb, pDbEntry;
+ char *modelID, **allIDs = (char **)NULL;
+ PrinterDbPtr pDbEntry;
int numModels, i;
if(!origFontPath)
@@ -1135,7 +1077,7 @@ AugmentFontPath()
for(i = 0; allIDs != (char **)NULL && allIDs[i] != (char *)NULL; i ++)
{
char *fontDir;
- if(fontDir = FindFontDir(allIDs[i]))
+ if ((fontDir = FindFontDir(allIDs[i])) != 0)
{
AddToFontPath(fontDir);
xfree(fontDir);
@@ -1225,7 +1167,7 @@ XpClientIsPrintClient(
* fpe->name.
*/
if(fpe->name_length < PATH_PREFIX_LEN ||
- (strlen(fontDir) != (fpe->name_length - PATH_PREFIX_LEN)) ||
+ (strlen(fontDir) != (unsigned)(fpe->name_length - PATH_PREFIX_LEN)) ||
strncmp(fontDir, fpe->name + PATH_PREFIX_LEN,
fpe->name_length - PATH_PREFIX_LEN))
{
@@ -1237,9 +1179,7 @@ XpClientIsPrintClient(
}
static void
-AddFormats(pScreenInfo, driverName)
- ScreenInfo *pScreenInfo;
- char *driverName;
+AddFormats(ScreenInfo *pScreenInfo, char *driverName)
{
int i, j;
driverInitRec *pInitRec;
@@ -1290,10 +1230,10 @@ AddFormats(pScreenInfo, driverName)
************************************************************/
void
-PrinterInitOutput(pScreenInfo, argc, argv)
- ScreenInfo *pScreenInfo;
- int argc;
- char **argv;
+PrinterInitOutput(
+ ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
{
PrinterDbPtr pDb, pDbEntry;
int driverCount = 0, i;
@@ -1454,11 +1394,11 @@ PrinterInitOutput(pScreenInfo, argc, argv)
* screen.
*/
static Bool
-InitPrintDrivers(index, pScreen, argc, argv)
- int index;
- ScreenPtr pScreen;
- int argc;
- char **argv;
+InitPrintDrivers(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
{
PrinterDbPtr pDb, pDb2;
@@ -1479,7 +1419,7 @@ InitPrintDrivers(index, pScreen, argc, argv)
}
if(callInit == TRUE)
{
- Bool (*initFunc)();
+ pBFunc initFunc;
initFunc = GetInitFunc(pDb->driverName);
if(initFunc(index, pScreen, argc, argv) == FALSE)
{
@@ -1492,13 +1432,13 @@ InitPrintDrivers(index, pScreen, argc, argv)
}
void
-_XpVoidNoop()
+_XpVoidNoop(void)
{
return;
}
Bool
-_XpBoolNoop()
+_XpBoolNoop(void)
{
return TRUE;
}
@@ -1510,16 +1450,15 @@ _XpBoolNoop()
*/
static void
-GenericScreenInit( index, pScreen, argc, argv )
- int index;
- ScreenPtr pScreen;
- int argc;
- char **argv;
+GenericScreenInit(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
{
- int i;
float fWidth, fHeight, maxWidth, maxHeight;
unsigned short width, height;
- PrinterDbPtr pDb, pDb2;
+ PrinterDbPtr pDb;
int res, maxRes;
/*
@@ -1543,7 +1482,6 @@ GenericScreenInit( index, pScreen, argc, argv )
{
if(pDb->screenNum == index)
{
-
XpValidatePoolsRec *pValRec;
pVFunc dimensionsFunc;
@@ -1582,9 +1520,9 @@ GenericScreenInit( index, pScreen, argc, argv )
* freeing the associated memory.
*/
static char *
-QualifyName(fileName, searchPath)
- char *fileName;
- char *searchPath;
+QualifyName(
+ char *fileName,
+ char *searchPath)
{
char * curPath = searchPath;
char * nextPath;
@@ -1632,11 +1570,11 @@ QualifyName(fileName, searchPath)
* XXX "localeName" elements of the XpDiListEntry to the specified locale.
*/
static void
-FillPrinterListEntry(pEntry, pDb, localeLen, locale)
- XpDiListEntry *pEntry;
- PrinterDbPtr pDb;
- int localeLen;
- char *locale;
+FillPrinterListEntry(
+ XpDiListEntry *pEntry,
+ PrinterDbPtr pDb,
+ int localeLen,
+ char *locale)
{
static char *localeStr = (char *)NULL;
@@ -1659,18 +1597,19 @@ FillPrinterListEntry(pEntry, pDb, localeLen, locale)
*
*/
static Bool
-GetPrinterListInfo(pEntry, nameLen, name, localeLen, locale)
- XpDiListEntry *pEntry;
- int nameLen;
- char *name;
- int localeLen;
- char *locale;
+GetPrinterListInfo(
+ XpDiListEntry *pEntry,
+ int nameLen,
+ char *name,
+ int localeLen,
+ char *locale)
{
- PrinterDbPtr pDb, pDb2;
+ PrinterDbPtr pDb;
for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
{
- if(strlen(pDb->name) == nameLen && !strncmp(pDb->name, name, nameLen))
+ if (strlen(pDb->name) == (unsigned)nameLen
+ && !strncmp(pDb->name, name, nameLen))
{
FillPrinterListEntry(pEntry, pDb, localeLen, locale);
return TRUE;
@@ -1684,8 +1623,7 @@ GetPrinterListInfo(pEntry, nameLen, name, localeLen, locale)
* for a printer list.
*/
void
-XpDiFreePrinterList(list)
- XpDiListEntry **list;
+XpDiFreePrinterList(XpDiListEntry **list)
{
int i;
@@ -1705,18 +1643,18 @@ XpDiFreePrinterList(list)
* the information for all printers is desired.
*/
XpDiListEntry **
-XpDiGetPrinterList(nameLen, name, localeLen, locale)
- int nameLen;
- char *name;
- int localeLen;
- char *locale;
+XpDiGetPrinterList(
+ int nameLen,
+ char *name,
+ int localeLen,
+ char *locale)
{
XpDiListEntry **pList;
if(!nameLen || name == (char *)NULL)
{
int i;
- PrinterDbPtr pDb, pDb2;
+ PrinterDbPtr pDb;
for(pDb = printerDb, i = 0; pDb != (PrinterDbPtr)NULL;
pDb = pDb->next, i++)
@@ -1763,17 +1701,14 @@ XpDiGetPrinterList(nameLen, name, localeLen, locale)
}
WindowPtr
-XpDiValidatePrinter(printerName, printerNameLen)
- char *printerName;
- int printerNameLen;
+XpDiValidatePrinter(char *printerName, int printerNameLen)
{
PrinterDbPtr pCurEntry;
- WindowPtr pWin;
for(pCurEntry = printerDb;
pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pCurEntry->next)
{
- if(strlen(pCurEntry->name) == printerNameLen &&
+ if(strlen(pCurEntry->name) == (unsigned)printerNameLen &&
!strncmp(pCurEntry->name, printerName, printerNameLen))
return WindowTable[pCurEntry->screenNum];
}
@@ -1786,9 +1721,7 @@ XpDiValidatePrinter(printerName, printerNameLen)
* on the specified screen.
*/
char *
-XpDiGetDriverName(index, printerName)
- int index;
- char *printerName;
+XpDiGetDriverName(int index, char *printerName)
{
PrinterDbPtr pCurEntry;