Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

361 lines
14 KiB

// Copyright (c) 1996-1999 Microsoft Corporation
---- how to add new keywords to the parser ----
if the keyword is a global (not associated with a Feature or Option
or other structure) add an entry into the GLOBALATTRIB structure
in parsers\gpd\gpdparse.h . The entry should be of type ATREEREF.
Add an entry into the GLOBALS structure in \inc\gpd.h
(if this is a Unidrv specific attribute)
or into UIINFO structure in parser.h if it is used by the
UI or common also to Pscript.
If the keyword belongs to a Feature or Option structure
add an entry into the DFEATURE_OPTIONS structure
in parsers\gpd\gpdparse.h . The entry should be of type ATREEREF.
Add an entry into the GID_EX specific structure in \inc\gpd.h
if the keyword is specific to one Feature and is not used by the
UIModule. Add it to the GID option structure in \inc\parser.h
if the keyword is specific to one Feature and is used by the
UI and Control Modules. Add to the FEATURE structure in \inc\parser.h
if its a feature keyword.
if the new keyword has a CONSTANTS valuetype, add an enum value to
the CONSTANT_CLASSES enumeration. (in gpdparse.h)
This value is the CONSTANT_CLASS_ENUMERATION_VALUE and identifies
the set of CONSTANTS that may be used with this keyword.
next enumerate a set of constants to be associated
with each allowed value for that keyword.
(\inc\gpd.h)
//
// define values for *YMoveAttributes keyword
//
typedef enum _YMOVEATTRIBUTE {
YMOVE_FAVOR_ABS,
YMOVE_FAVOR_LINEFEEDSPACING,
YMOVE_SENDCR_FIRST,
} YMOVEATTRIBUTE;
now add a list of pairs to the CONSTANTDEF gConstantsTable[]
(globals.h)
which associate the constant values just enumerated with
the "STRINGS" representing these constants in the GPD spec.
This list is prefaced by {NULL, CONSTANT_CLASS_ENUMERATION_VALUE}.
The position this list appears in CONSTANTDEF gConstantsTable[]
is determined by CONSTANT_CLASS_ENUMERATION_VALUE. The lists
are ordered in ascending value of CONSTANT_CLASS_ENUMERATION_VALUE.
{NULL, CL_YMOVEATTRIB},
{"FAVOR_ABS", YMOVE_FAVOR_ABS},
{"FAV_LF", YMOVE_FAVOR_LINEFEEDSPACING},
{"SEND_CR_FIRST", YMOVE_SENDCR_FIRST},
add an entry to the VALUE enumeration gpdparse.h
of the form:
VALUE_CONSTANT_YMOVEATTRIB = VALUE_CONSTANT_FIRST + CL_YMOVEATTRIB ,
in framwrk1.c add an entry of this form to
VOID VinitMainKeywordTable()
// *YMoveAttributes:
mMainKeywordTable[dwI].pstrKeyword = "YMoveAttributes" ;
mMainKeywordTable[dwI].eAllowedValue = VALUE_CONSTANT_YMOVEATTRIB ;
mMainKeywordTable[dwI].flAgs = KWF_LIST ;
mMainKeywordTable[dwI].eType = TY_ATTRIBUTE ;
mMainKeywordTable[dwI].dwSubType = ATT_GLOBAL_FREEFLOAT ;
mMainKeywordTable[dwI].dwOffset = offsetof(GLOBALATTRIB,
atrYMoveAttributes) ;
dwI++ ;
// ---- MainKeyword table Section ---- //
/* the MainKeyword table contains static information that
describes each main keyword. This table controls what action
the parser takes. First define several enumerations used
in the table. */
typedef enum
{
TY_CONSTRUCT, TY_ATTRIBUTE, TY_SPECIAL
} KEYWORD_TYPE ;
typedef enum
{
ATT_GLOBAL_ONLY, ATT_GLOBAL_FREEFLOAT,
ATT_LOCAL_FEATURE_ONLY, ATT_LOCAL_FEATURE_FF ,
ATT_LOCAL_OPTION_ONLY, ATT_LOCAL_OPTION_FF ,
ATT_LOCAL_COMMAND_ONLY, ATT_LOCAL_FONTCART_ONLY,
ATT_LOCAL_TTFONTSUBS_ONLY, ATT_LOCAL_OEM_ONLY,
ATT_LAST // Must be last in list.
} ATTRIBUTE ; // subtype
typedef enum
{
CONSTRUCT_UIGROUP ,
CONSTRUCT_FEATURE ,
CONSTRUCT_OPTION ,
CONSTRUCT_SWITCH,
CONSTRUCT_CASE ,
CONSTRUCT_DEFAULT ,
CONSTRUCT_COMMAND ,
CONSTRUCT_FONTCART ,
CONSTRUCT_TTFONTSUBS ,
CONSTRUCT_OEM ,
CONSTRUCT_LAST, // must end list of transition inducing constructs.
// constructs below do not cause state transitions
CONSTRUCT_BLOCKMACRO ,
CONSTRUCT_MACROS,
CONSTRUCT_OPENBRACE,
CONSTRUCT_CLOSEBRACE,
} CONSTRUCT ; // SubType if Type = CONSTRUCT
typedef enum
{
SPEC_TTFS, SPEC_FONTSUB, SPEC_INVALID_COMBO,
SPEC_COMMAND_SHORTCUT,
SPEC_CONSTR, SPEC_INS_CONSTR,
SPEC_NOT_INS_CONSTR, SPEC_INVALID_INS_COMBO,
SPEC_MEM_CONFIG_KB, SPEC_MEM_CONFIG_MB,
SPEC_INCLUDE, SPEC_INSERTBLOCK
} SPECIAL ;
// what value type does the parser expect after each keyword?
typedef enum
{
NO_VALUE , // a linebreak OR an effective linebreak: ({) or comment
// or optional value.
VALUE_INTEGER, // integer
VALUE_POINT, // point
VALUE_RECT, // rectangle
// VALUE_BOOLEAN, // a subset of constants.
VALUE_QUALIFIED_NAME, // Qualified name (two symbols separated by .
VALUE_PARTIALLY_QUALIFIED_NAME , // (just one symbol or two symbols
// separated by .)
VALUE_CONSTRAINT, // list of qualified names but stored differently.
VALUE_ORDERDEPENDENCY,
VALUE_FONTSUB, // "fontname" : <int>
// VALUE_STRING, // Quoted String, hexstring, string MACROREF,
// parameterless invocation.
VALUE_STRING_NO_CONVERT, // string will not undergo unicode conversion
// for example *GPDSpecVersion must remain an ascii string.
VALUE_STRING_DEF_CONVERT, // string will be converted using the
// system codepage - filenames
VALUE_STRING_CP_CONVERT, // string will be converted using the
// codepage specified by *CodePage
VALUE_COMMAND_INVOC, // like VALUE_STRING but allowed to contain
// one or more parameter references.
VALUE_COMMAND_SHORTCUT, // Commandname:VALUE_COMMAND_INVOC
VALUE_SYMBOL_DEF, // * the value defines a symbol or value macro
// { and } are not permitted. Is this ever used ? yes
VALUE_SYMBOL_FIRST, // base of user-defined symbol catagory
VALUE_SYMBOL_FEATURES = VALUE_SYMBOL_FIRST + SCL_FEATURES , //
VALUE_SYMBOL_FONTCART = VALUE_SYMBOL_FIRST + SCL_FONTCART , //
VALUE_SYMBOL_TTFONTNAMES = VALUE_SYMBOL_FIRST + SCL_TTFONTNAMES , //
VALUE_SYMBOL_BLOCKMACRO = VALUE_SYMBOL_FIRST + SCL_BLOCKMACRO , //
VALUE_SYMBOL_VALUEMACRO = VALUE_SYMBOL_FIRST + SCL_VALUEMACRO , //
VALUE_SYMBOL_OPTIONS = VALUE_SYMBOL_FIRST + SCL_OPTIONS , //
// SCL_COMMANDNAMES intentionally omitted.
VALUE_SYMBOL_LAST = VALUE_SYMBOL_FIRST + SCL_NUMSYMCLASSES - 1 , //
VALUE_CONSTANT_FIRST, // base of enumeration catagory.
VALUE_CONSTANT_BOOLEANTYPE = VALUE_CONSTANT_FIRST + CL_BOOLEANTYPE ,
VALUE_CONSTANT_PRINTERTYPE = VALUE_CONSTANT_FIRST + CL_PRINTERTYPE ,
VALUE_CONSTANT_FEATURETYPE = VALUE_CONSTANT_FIRST + CL_FEATURETYPE ,
VALUE_CONSTANT_UITYPE = VALUE_CONSTANT_FIRST + CL_UITYPE ,
VALUE_CONSTANT_PROMPTTIME = VALUE_CONSTANT_FIRST + CL_PROMPTTIME ,
VALUE_CONSTANT_PAPERFEED_ORIENT = VALUE_CONSTANT_FIRST + CL_PAPERFEED_ORIENT ,
VALUE_CONSTANT_COLORPLANE = VALUE_CONSTANT_FIRST + CL_COLORPLANE ,
VALUE_CONSTANT_SEQSECTION = VALUE_CONSTANT_FIRST + CL_SEQSECTION ,
VALUE_CONSTANT_RASTERCAPS = VALUE_CONSTANT_FIRST + CL_RASTERCAPS ,
VALUE_CONSTANT_TEXTCAPS = VALUE_CONSTANT_FIRST + CL_TEXTCAPS ,
VALUE_CONSTANT_MEMORYUSAGE = VALUE_CONSTANT_FIRST + CL_MEMORYUSAGE ,
VALUE_CONSTANT_CURSORXAFTERCR = VALUE_CONSTANT_FIRST + CL_CURSORXAFTERCR ,
VALUE_CONSTANT_BADCURSORMOVEINGRXMODE = VALUE_CONSTANT_FIRST + CL_BADCURSORMOVEINGRXMODE ,
// VALUE_CONSTANT_SIMULATEXMOVE = VALUE_CONSTANT_FIRST + CL_SIMULATEXMOVE ,
VALUE_CONSTANT_PALETTESCOPE = VALUE_CONSTANT_FIRST + CL_PALETTESCOPE ,
VALUE_CONSTANT_OUTPUTDATAFORMAT = VALUE_CONSTANT_FIRST + CL_OUTPUTDATAFORMAT ,
VALUE_CONSTANT_STRIPBLANKS = VALUE_CONSTANT_FIRST + CL_STRIPBLANKS ,
VALUE_CONSTANT_LANDSCAPEGRXROTATION = VALUE_CONSTANT_FIRST + CL_LANDSCAPEGRXROTATION ,
VALUE_CONSTANT_CURSORXAFTERSENDBLOCKDATA = VALUE_CONSTANT_FIRST + CL_CURSORXAFTERSENDBLOCKDATA ,
VALUE_CONSTANT_CURSORYAFTERSENDBLOCKDATA = VALUE_CONSTANT_FIRST + CL_CURSORYAFTERSENDBLOCKDATA ,
VALUE_CONSTANT_CHARPOSITION = VALUE_CONSTANT_FIRST + CL_CHARPOSITION ,
VALUE_CONSTANT_FONTFORMAT = VALUE_CONSTANT_FIRST + CL_FONTFORMAT ,
VALUE_CONSTANT_QUERYDATATYPE = VALUE_CONSTANT_FIRST + CL_QUERYDATATYPE ,
VALUE_CONSTANT_YMOVEATTRIB = VALUE_CONSTANT_FIRST + CL_YMOVEATTRIB ,
VALUE_CONSTANT_DLSYMBOLSET = VALUE_CONSTANT_FIRST + CL_DLSYMBOLSET ,
VALUE_CONSTANT_CURXAFTER_RECTFILL = VALUE_CONSTANT_FIRST + CL_CURXAFTER_RECTFILL ,
VALUE_CONSTANT_CURYAFTER_RECTFILL = VALUE_CONSTANT_FIRST + CL_CURYAFTER_RECTFILL ,
VALUE_CONSTANT_PRINTRATEUNIT = VALUE_CONSTANT_FIRST + CL_PRINTRATEUNIT ,
VALUE_CONSTANT_STANDARD_VARS = VALUE_CONSTANT_FIRST + CL_STANDARD_VARS ,
VALUE_CONSTANT_COMMAND_NAMES = VALUE_CONSTANT_FIRST + CL_COMMAND_NAMES ,
VALUE_CONSTANT_CONS_FEATURES = VALUE_CONSTANT_FIRST + CL_CONS_FEATURES ,
VALUE_CONSTANT_CONS_PAPERSIZE = VALUE_CONSTANT_FIRST + CL_CONS_PAPERSIZE ,
VALUE_CONSTANT_CONS_MEDIATYPE = VALUE_CONSTANT_FIRST + CL_CONS_MEDIATYPE ,
VALUE_CONSTANT_CONS_INPUTSLOT = VALUE_CONSTANT_FIRST + CL_CONS_INPUTSLOT ,
VALUE_CONSTANT_CONS_DUPLEX = VALUE_CONSTANT_FIRST + CL_CONS_DUPLEX ,
VALUE_CONSTANT_CONS_ORIENTATION = VALUE_CONSTANT_FIRST + CL_CONS_ORIENTATION ,
VALUE_CONSTANT_CONS_PAGEPROTECT = VALUE_CONSTANT_FIRST + CL_CONS_PAGEPROTECT ,
VALUE_CONSTANT_CONS_COLLATE = VALUE_CONSTANT_FIRST + CL_CONS_COLLATE ,
VALUE_CONSTANT_LAST = VALUE_CONSTANT_FIRST + CL_NUMCLASSES - 1 ,
VALUE_LIST, // no attribute actually is assigned this descriptor,
// but used in the gValueToSize table.
VALUE_LARGEST, // not a real descriptor, but this position in the
// gValueToSize table holds the largest of the above values.
VALUE_MAX, // number of elements in gValueToSize table.
} VALUE ;
// -- allowed values for KEYWORDTABLE_ENTRY.flAgs: --
#define KWF_LIST (0x00000001)
// the value may be a LIST containing one or more
// items of type AllowedValue. The storage format
// must be of type LIST. Only certain values may qualify
// for list format.
#define KWF_ADDITIVE (0x00000002)
// this flag implies KWF_LIST and also specifies the behavior
// that any redefinition of this keyword simply adds its items
// onto the existing list. (removal of redundant items is not
// performed.)
#define KWF_MACROREF_ALLOWED (0x00000004)
// since only a handful of keywords cannot accept
// macro references, it may be a waste of a flag, but reserve this
// to alert us that this special case must accounted for.
#define KWF_SHORTCUT (0x00000008)
// This keyword has multiple variants of syntax.
// one of the following 3 flags is set
// if the values in the nodes of the attribute tree
// refer to indicies of dedicated arrays, (which obviously
// contain data fields not ATREEREFs) AND
// gMainKeywordTable[].dwOffset is an offset into
// this dedicated array, then set this flag.
// else dwOffset is used to select the treeroot.
#define KWF_COMMAND (0x00000010)
// This attribute is stored in a dedicated structure
#define KWF_FONTCART (0x00000020)
// This attribute is stored in a dedicated structure
#define KWF_OEM (0x00000040)
// This attribute is stored in a dedicated structure
#define KWF_TTFONTSUBS (0x00000080)
// This attribute is stored in a dedicated structure
#define KWF_DEDICATED_FIELD (KWF_COMMAND | KWF_FONTCART | \
KWF_OEM | KWF_TTFONTSUBS)
// this flag is never set in the MainKeywordTable[].
#define KWF_REQUIRED (0x00000100)
// this keyword must appear in the GPD file
also check the number of entries allocated for the mainkeyword
table is sufficient to hold all of the new entries.
See VOID VinitGlobals() in framwrk1.c
gMasterTable[MTI_MAINKEYWORDTABLE].dwArraySize = 300 ;
In BinitSnapShotTable - snaptbl.c add and initialize
an entry in the snapShotTable. Be sure to place this
entry in the proper section depending on the structure type
of the destination.
pmrbd->snapShotTable[dwI].dwSrcOffset = offsetof(GLOBALATTRIB,
atrMasterUnits) ;
pmrbd->snapShotTable[dwI].dwDestOffset = offsetof(UIINFO,
ptMasterUnits) ;
pmrbd->snapShotTable[dwI].dwNbytes = sizeof(POINT) ;
pmrbd->snapShotTable[dwI].dwDefaultValue = 0 ;
pmrbd->snapShotTable[dwI].dwFlags = SSF_REQUIRED ;
pmrbd->snapShotTable[dwI].dwGIDflags = 0 ;
dwI++ ;
// flags for snapshot table.
#define SSF_REQUIRED 0x00000001
// fail if there is no value to copy
#define SSF_DONT_USEDEFAULT 0x00000002
// if there is no value to copy leave dest
// undisturbed. Do not copy the default value.
#define SSF_OFFSETONLY 0x00000004
// Copy only the loOffset of an arrayref.
#define SSF_MAKE_STRINGPTR 0x00000008
// Convert arrayref to stringptr
#define SSF_SETRCID 0x00000010
// set high bit after copying the value (if found)
#define SSF_FAILIFZERO 0x00000020
// unlike SSF_REQUIRED, allow current copy
// to fail, then fail only if dest is zero.
#define SSF_SECOND_DWORD 0x00000040
// treat src value object as array of DWORDS
// and copy the 2nd DWORD to the destination.
// used to transfer just the Y value of a point
// to the dest.
#define SSF_KB_TO_BYTES 0x00000080
// treat dest as a dword and left shift by 10 bits.
#define SSF_HEAPOFFSET 0x00000100
// instead of copying the bytes at pheap + heapoffset
// just copy heapoffset to the destination.
// this is used with dedicated structures where
// the heapoffset is actually the array index of a dedicated
// structure.
#define SSF_RETURN_UNINITIALIZED 0x00000200
// if no value exists, cause EextractValueFromTree
// to return TRI_UNINITIALIZED, but don't complain
// to user.
The snapShotTable is currently divided into the
following sections:
typedef enum
{SSTI_GLOBALS, SSTI_UIINFO, SSTI_FEATURES, SSTI_OPTIONS, SSTI_OPTIONEX,
SSTI_SPECIAL, MAX_STRUCTURETYPES}
SSTABLEINDEX ;
each section is delimited by a few lines:
// end of SSTI_GLOBALS section
pmrbd->snapShotTable[dwI].dwNbytes = 0 ;
dwI++ ;
// beginning of SSTI_UIINFO section