XpSetAttributes(3Xp)
π XpSetAttributes β the one where you set or update an attribute pool in a print context
okay so real talk, this is XpSetAttributes(3Xp), and it lives in the XPRINT FUNCTIONS family. If you're the kind of girlie who likes telling the X Print Server exactly what's what, this is your moment. π
β¨ SYNOPSIS β¨
cc [ flag... ] file... -lXp [ library... ]
#include <X11/extensions/Print.h>
void XpSetAttributes ( display, context, type, pool, replacement_rule )
Display *display;
XPContext context;
XPAttributes type;
char *pool;
XPAttrReplacement replacement_rule;
πΈ ARGUMENTS πΈ
displayβ a pointer to theDisplaystructure, bestie. You get it back fromXOpenDisplay. It's literally your whole connection to the X server.contextβ the print context whose attribute pool is about to get a glow-up (or a full replacement, we don't judge).typeβ specifies the attribute pool. Which pool? That's what this tells you.poolβ an attribute pool represented as a resource string, encoded inCOMPOUND_TEXT. Yes, encoded. Don't come at me with plain ASCII.replacement_ruleβ eitherXPAttrReplaceorXPAttrMerge. Pick one, choose your fighter. βοΈ
π DESCRIPTION π
So XpSetAttributes takes pool β a COMPOUND_TEXT resource string stuffed with new name-value pairs β and shoves them into the attribute pool that type points at. The way it modifies things depends on replacement_rule:
- With
XPAttrReplace, the existing attribute pool is discarded and replaced withpool. Gone. Done. New pool, who dis. π - With
XPAttrMerge,poolgets merged into the existing attribute pool: pre-existing name-value pairs are replaced, and non-existing name-value pairs are just added like they were always invited. π«Ά
And important: the contents of pool are not affected by this call, so you can free it yourself afterwards. No sneaky ownership transfer, no cap.
Okay, now the part where the server gets opinions. π
When you set supported attribute names, the X Print Server and its associated driver will validate the new values and ignore the ones that are invalid β and when that happens, the previous values remain unchanged. So invalid input = nothing happens, not chaos.
When you set unsupported (that is, unknown) attribute names, no validation is done at all, and the name-value pairs will be set β even though they will not be used. It's giving "clutter in the group chat," but sure, go off. π
When you delete a supported attribute name β meaning you fail to reset it with XPAttrReplace β the X Print Server explicitly or implicitly resets the attribute to a default value. β¨
Also, heads up: when you set certain supported attributes, the X Print Server may modify other associated attributes as a side effect. The example they gave: considering the XPPrinterAttr attribute document-formats-supported, setting the XPDocAttr attribute document-format may cause a number of other attributes to change. Butterfly effect, but make it print server. π¦
For attribute pools that are read-only (see "get only" in the XPAttributes definition), attempting to use XpSetAttributes generates a BadMatch. Rude? Maybe. Correct? Absolutely. For attribute pools that are writable, lists of the supported attributes can be found in the XPPrinterAttr pool.
The lifetime of all attribute pools is bounded by the lifetime of the print context they're contained in. When set, all attribute values will be retained across all Xp operations β until changed by the user directly, by the X Print Server directly, or changed because of a side effect when either the user or the X Print Server changed another attribute value.
Refer to a complete description of all print attributes, the precedence between print attributes, and the side effects of setting certain print attributes on other print attributes, etc. (Their words, not mine β go read the docs, bestie.)
Wanna monitor changes to the attribute pools? Look at XpSelectInput and the event XPAttributeNotify. Because a print context can be shared among clients, changes made by one client will be seen by all the others β and if selected for, the event XPAttributeNotify will be sent to all clients referencing the print context when changes do occur. So it is the responsibility of the clients sharing a print context to coordinate their operations. Communicate. Please. π
π§ STRUCTURES π§
The values for the typedef XPAttributes in <X11/extensions/Print.h> are:
#define XPJobAttr 1 /β get/set */
#define XPDocAttr 2 /β get/set */
#define XPPageAttr 3 /β get/set - subset of XPDocAttr */
#define XPPrinterAttr 4 /β get only (library) */
#define XPServerAttr 5 /β get only (library), no context needed */
The values for the typedef XPAttrReplacement in <X11/extensions/Print.h> are:
#define XPAttrReplace 1
#define XPAttrMerge 2
π₯ DIAGNOSTICS π₯
BadAllocβ insufficient memory. You ran out. Skill issue, but recoverable.BadMatchβ the attribute pool specified bypoolcannot be set. Probably read-only, see above. πBadValueβ the value specified fortypeis not valid. Check yourtype, bestie.XPBadContextβ the specified print context-id is not valid.XPBadSequenceβ a request to set an attribute pool occurred at a time when the attribute pool could not be modified. Their example: modifyingXPJobAttrimmediately after callingXpStartJob. Timing is everything, fr fr. β
π FILES π
<X11/extensions/Print.h>
π SEE ALSO π
XpSelectInput(3Xp), XpStartJob(3Xp)
π and that's the whole vibe. this iconic little page comes to you from X Version 11 and libXp 1.0.4 β mwah, slay, periodt. π
π¦ where this page comes from
- arch rolling: libxp 1.0.4-3 Β· X11 AND X11-distribute-modifications-variant
- nixos 26.05: libxp 1.0.4
- nixpkgs unstable: libxp 1.0.4
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- Copyright 1996 Hewlett-Packard Company
- Copyright 1996 International Business Machines Corp
- Copyright 1996, 1999, 2004, Oracle and/or its affiliates. All rights reserved
- Copyright 1996 Novell, Inc
- Copyright 1996 Digital Equipment Corp
- Copyright 1996 Fujitsu Limited
- Copyright 1996 Hitachi, Ltd
- Copyright 1996 X Consortium, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms