summaryrefslogtreecommitdiff
path: root/Xprint/attributes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xprint/attributes.c')
-rw-r--r--Xprint/attributes.c238
1 files changed, 108 insertions, 130 deletions
diff --git a/Xprint/attributes.c b/Xprint/attributes.c
index 7348d6402..7d71760be 100644
--- a/Xprint/attributes.c
+++ b/Xprint/attributes.c
@@ -44,26 +44,30 @@ copyright holders.
** *********************************************************
**
********************************************************************/
+/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.18 2002/05/31 18:45:53 dawes Exp $ */
-#include <Xproto.h>
+#include <X11/Xproto.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <sys/wait.h>
#include <pwd.h>
+#if defined(sun) && defined(SVR4)
+#include <wchar.h>
+#endif
-#include <scrnintstr.h>
+#include "scrnintstr.h"
-#define _XP_PRINT_SERVER_
-#include "extensions/Printstr.h"
-#undef _XP_PRINT_SERVER_
+#include <X11/extensions/Printstr.h>
+#include "attributes.h"
#include "Xrm.c"
static XrmDatabase CopyDb(XrmDatabase inDb);
-extern XrmDatabase XpSpoolerGetServerAttributes();
+extern XrmDatabase XpSpoolerGetServerAttributes(void);
-static int attrGeneration = 0;
+static unsigned long attrGeneration = 0;
typedef struct {
XrmDatabase *pDb;
@@ -137,8 +141,7 @@ static char NULL_STRING[] = "\0";
* $LANG. It makes no attempt to ensure that the directory actually exists.
*/
char *
-XpGetConfigDir(useLocale)
- Bool useLocale;
+XpGetConfigDir(Bool useLocale)
{
char *dirName, *langName, *langDir, *configDir;
Bool freeLangDir = False;
@@ -182,8 +185,7 @@ XpGetConfigDir(useLocale)
* locale (if other than the top-level).
*/
static XrmDatabase
-GetMergedDatabase(attrName)
- char *attrName;
+GetMergedDatabase(const char *attrName)
{
char *dirName, *fileName;
XrmDatabase db;
@@ -220,7 +222,7 @@ GetMergedDatabase(attrName)
* the context.
*/
static void
-BuildSystemAttributes()
+BuildSystemAttributes(void)
{
if(systemAttributes.printers != (XrmDatabase)NULL)
XrmDestroyDatabase(systemAttributes.printers);
@@ -243,13 +245,13 @@ BuildSystemAttributes()
* passed as the client_data (aka "closure").
*/
static Bool
-AddDbEntry(sourceDB, bindings, quarks, type, value, client_data)
- XrmDatabase *sourceDB;
- XrmBindingList bindings;
- XrmQuarkList quarks;
- XrmRepresentation *type;
- XrmValue *value;
- XPointer client_data;
+AddDbEntry(
+ XrmDatabase *sourceDB,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValue *value,
+ XPointer client_data)
{
DbEnumStruct *pEnumStruct = (DbEnumStruct *)client_data;
XrmName xrm_name[5];
@@ -293,15 +295,15 @@ AddDbEntry(sourceDB, bindings, quarks, type, value, client_data)
* printer.
*/
static XrmDatabase
-BuildPrinterAttrs(printerName, qualifierName)
- char *printerName;
- char *qualifierName;
+BuildPrinterAttrs(
+ char *printerName,
+ char *qualifierName)
{
XrmDatabase printerDB = (XrmDatabase)NULL;
if(systemAttributes.printers != (XrmDatabase)NULL)
{
- char *dirName, *fileName;
+ char *fileName;
XrmDatabase modelDB = (XrmDatabase)NULL;
XrmName xrm_name[5], xrm_class[2];
XrmRepresentation rep_type;
@@ -374,10 +376,10 @@ BuildPrinterAttrs(printerName, qualifierName)
* level doc and job databases.
*/
static XrmDatabase
-BuildABase(printerName, qualifierName, sourceBase)
- char *printerName;
- char *qualifierName;
- XrmDatabase sourceBase;
+BuildABase(
+ char *printerName,
+ char *qualifierName,
+ XrmDatabase sourceBase)
{
XrmDatabase builtDB = (XrmDatabase)NULL;
@@ -425,7 +427,7 @@ BuildABase(printerName, qualifierName, sourceBase)
* databases stored in the global attrList.
*/
static void
-FreeAttrList()
+FreeAttrList(void)
{
PrAttrPtr pAttr, pNext;
@@ -454,7 +456,7 @@ FreeAttrList()
* by calling XpBuildAttributeStore for a new list of printers.
*/
int
-XpRehashAttributes()
+XpRehashAttributes(void)
{
if(attrList != (PrAttrPtr)NULL)
FreeAttrList();
@@ -468,9 +470,9 @@ XpRehashAttributes()
* calls BuildSystemAttributes to create the system-level databases.
*/
void
-XpBuildAttributeStore(printerName, qualifierName)
- char *printerName;
- char *qualifierName;
+XpBuildAttributeStore(
+ char *printerName,
+ char *qualifierName)
{
PrAttrPtr pAttr;
@@ -510,13 +512,13 @@ XpBuildAttributeStore(printerName, qualifierName)
static Bool
-StoreEntry(sourceDB, bindings, quarks, type, value, client_data)
- XrmDatabase *sourceDB;
- XrmBindingList bindings;
- XrmQuarkList quarks;
- XrmRepresentation *type;
- XrmValue *value;
- XPointer client_data;
+StoreEntry(
+ XrmDatabase *sourceDB,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValue *value,
+ XPointer client_data)
{
XrmDatabase *outDb = (XrmDatabase *)client_data;
@@ -530,8 +532,7 @@ StoreEntry(sourceDB, bindings, quarks, type, value, client_data)
* the copy.
*/
static XrmDatabase
-CopyDb(inDb)
- XrmDatabase inDb;
+CopyDb(XrmDatabase inDb)
{
XrmDatabase outDb = (XrmDatabase)NULL;
XrmQuark empty = NULLQUARK;
@@ -547,8 +548,7 @@ CopyDb(inDb)
* attributes databases for the printer associated with the context.
*/
void
-XpInitAttributes( pContext )
- XpContextPtr pContext;
+XpInitAttributes(XpContextPtr pContext)
{
ContextAttrPtr pCtxtAttrs;
PrAttrPtr pPrAttr = attrList;
@@ -569,8 +569,8 @@ XpInitAttributes( pContext )
}
void
-XpDestroyAttributes( pContext )
- XpContextPtr pContext;
+XpDestroyAttributes(
+ XpContextPtr pContext)
{
ContextAttrPtr pCtxtAttrs;
@@ -596,14 +596,13 @@ XpDestroyAttributes( pContext )
* in which case the pContext parameter is ignored.
*/
char *
-XpGetOneAttribute( pContext, class, attributeName )
- XpContextPtr pContext;
- XPAttributes class;
- char *attributeName;
+XpGetOneAttribute(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attributeName)
{
ContextAttrPtr pCtxtAttrs;
XrmDatabase db = (XrmDatabase)NULL;
- char *retVal;
XrmName xrm_name[3];
XrmRepresentation rep_type;
XrmValue value;
@@ -666,12 +665,11 @@ XpGetOneAttribute( pContext, class, attributeName )
* function does not recognize XPServerAttr.
*/
void
-XpPutOneAttribute( pContext, class, attributeName, value )
-
-XpContextPtr pContext;
-XPAttributes class;
-const char* attributeName;
-const char* value;
+XpPutOneAttribute(
+ XpContextPtr pContext,
+ XPAttributes class,
+ const char* attributeName,
+ const char* value)
{
ContextAttrPtr pCtxtAttrs;
XrmDatabase db;
@@ -720,8 +718,8 @@ const char* value;
* struct to indicate the new amount of space available.
*/
static Bool
-ExpandSpace(pStr)
- StringDbStruct *pStr;
+ExpandSpace(
+ StringDbStruct *pStr)
{
char *newSpace;
@@ -740,9 +738,9 @@ ExpandSpace(pStr)
* are updated.
*/
static void
-PutString(pStr, pString)
- StringDbStruct *pStr;
- char *pString;
+PutString(
+ StringDbStruct *pStr,
+ char *pString)
{
int len = strlen(pString);
@@ -760,9 +758,9 @@ PutString(pStr, pString)
* the byte, and the nextPos and space fields are updated.
*/
static void
-PutByte(pStr, byte)
- StringDbStruct *pStr;
- char byte;
+PutByte(
+ StringDbStruct *pStr,
+ char byte)
{
if(pStr->space <= 1)
if(!ExpandSpace(pStr))
@@ -782,13 +780,13 @@ PutByte(pStr, byte)
* This code is based directly on that in "DumpEntry" in Xrm.c.
*/
static Bool
-AppendEntry(db, bindings, quarks, type, value, data)
- XrmDatabase *db;
- XrmBindingList bindings;
- XrmQuarkList quarks;
- XrmRepresentation *type;
- XrmValuePtr value;
- XPointer data;
+AppendEntry(
+ XrmDatabase *db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValuePtr value,
+ XPointer data)
{
StringDbStruct *pEnumStr = (StringDbStruct *)data;
Bool firstNameSeen;
@@ -796,7 +794,7 @@ AppendEntry(db, bindings, quarks, type, value, data)
char *s, c;
if (*type != XrmQString)
- return;
+ return False;
for (firstNameSeen = False; *quarks; bindings++, quarks++) {
if (*bindings == XrmBindLoosely) {
@@ -849,13 +847,12 @@ AppendEntry(db, bindings, quarks, type, value, data)
* unlike XpGetOneAttribute, where the caller must not free the string.
*/
char *
-XpGetAttributes( pContext, class )
- XpContextPtr pContext;
- XPAttributes class;
+XpGetAttributes(
+ XpContextPtr pContext,
+ XPAttributes class)
{
ContextAttrPtr pCtxtAttrs;
XrmDatabase db = (XrmDatabase)NULL;
- char *retVal;
StringDbStruct enumStruct;
XrmQuark empty = NULLQUARK;
@@ -904,10 +901,10 @@ XpGetAttributes( pContext, class )
}
int
-XpAugmentAttributes( pContext, class, attributes )
- XpContextPtr pContext;
- XPAttributes class;
- char *attributes;
+XpAugmentAttributes(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attributes)
{
XrmDatabase db;
ContextAttrPtr pCtxtAttrs;
@@ -940,10 +937,10 @@ XpAugmentAttributes( pContext, class, attributes )
* XpSetAttributes - sets the attribute stores for a specified context.
*/
int
-XpSetAttributes( pContext, class, attributes )
- XpContextPtr pContext;
- XPAttributes class;
- char *attributes;
+XpSetAttributes(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attributes)
{
XrmDatabase db;
ContextAttrPtr pCtxtAttrs;
@@ -981,12 +978,11 @@ XpSetAttributes( pContext, class, attributes )
}
void
-XpAddPrinterAttribute(printerName, printerQualifier, attributeName,
- attributeValue)
- char *printerName;
- char *printerQualifier;
- char *attributeName;
- char *attributeValue;
+XpAddPrinterAttribute(
+ char *printerName,
+ char *printerQualifier,
+ char *attributeName,
+ char *attributeValue)
{
PrAttrPtr pAttr;
@@ -1045,7 +1041,7 @@ static char serverAttrStr[] = "*document-attributes-supported: copy-count\n\
*multiple-documents-supported: False";
XrmDatabase
-XpSpoolerGetServerAttributes()
+XpSpoolerGetServerAttributes(void)
{
char *totalAttrs, *localeName;
XrmDatabase db;
@@ -1065,34 +1061,6 @@ XpSpoolerGetServerAttributes()
}
/*
- * ExecuteCommand takes two pointers - the command to execute,
- * and the "argv" style NULL-terminated vector of arguments for the command.
- * We wait for the command to terminate before continuing to ensure that
- * we don't delete the job file before the spooler has made a copy.
- */
-static void
-ExecCommand(pCommand, argVector)
- char *pCommand;
- char **argVector;
-{
- pid_t childPid;
- int status;
-
- if((childPid = fork()) == 0)
- {
- /* return BadAlloc? */
- if (execv(pCommand, argVector) == -1) {
- FatalError("unable to exec '%s'", pCommand);
- }
- }
- else
- {
- (void) waitpid(childPid, &status, 0);
- }
- return;
-}
-
-/*
* SendFileToCommand takes three character pointers - the file name,
* the command to execute,
* and the "argv" style NULL-terminated vector of arguments for the command.
@@ -1167,8 +1135,6 @@ SendFileToCommand(
}
else
{
- int res;
-
(void) close(pipefd[0]);
outPipe = fdopen(pipefd[1], "w");
@@ -1188,7 +1154,6 @@ SendFileToCommand(
* store for the supplied print context. The ReplaceAnyString utility
* routine is used to perform the actual replacements.
*/
-extern char *ReplaceAnyString(char *, char *, char *);
static char *
ReplaceAllKeywords(
@@ -1233,7 +1198,20 @@ ReplaceAllKeywords(
return command;
}
-#if defined(CSRG_BASED) || defined(linux) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL))
+#ifdef __QNX__
+#define toascii( c ) ((unsigned)(c) & 0x007f)
+#endif
+
+#if defined(CSRG_BASED) || \
+ defined(linux) || \
+ defined(__CYGWIN__) || \
+ (defined(sun) && !defined(SVR4)) || \
+ (defined(SVR4) && !defined(sun) && !defined(USL)) || \
+ defined(__UNIXOS2__) || \
+ defined(ISC) || \
+ defined(Lynx) || \
+ defined(__QNX__) || \
+ defined(__DARWIN__)
#define iswspace(c) (isascii(c) && isspace(toascii(c)))
#endif
@@ -1387,8 +1365,8 @@ VectorizeCommand(
char ***pVector,
XpContextPtr pContext)
{
- char *cmdName, *curTok;
- int i, numChars;
+ char *cmdName;
+ int numChars;
if(command == (char *)NULL)
return (char *)NULL;
@@ -1410,11 +1388,11 @@ static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -n %copy-co
#endif
int
-XpSubmitJob(fileName, pContext)
- char *fileName;
- XpContextPtr pContext;
+XpSubmitJob(
+ char *fileName,
+ XpContextPtr pContext)
{
- char **vector, *cmdNam, *cmdOpt, *command, *userName;
+ char **vector, *cmdNam, *command, *userName;
int i;
command = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-command");
@@ -1452,6 +1430,7 @@ XpSubmitJob(fileName, pContext)
FreeVector(vector);
xfree(cmdNam);
+ return Success;
}
/*
@@ -1524,7 +1503,6 @@ XpGetTrayMediumFromContext(XpContextPtr pCon,
{
char *defMedium, *defTray;
char *t, *m;
- char *pS, *pE, *pLast;
defMedium = XpGetOneAttribute( pCon, XPPageAttr,
"default-medium" );