3 #ifndef FVWM_MODULE_LIST_H
4 #define FVWM_MODULE_LIST_H
6 #include "libs/Module.h"
7 #include "libs/queue.h"
10 #include "fvwm/fvwm.h"
12 /* please don't use msg_masks_t and PipeMask outside of module_interface.c.
13 * They are only global to allow to access the IS_MESSAGE_SELECTED macro without
14 * having to call a function. */
15 typedef struct msg_masks_t
21 /* module linked list record, only to be accessed by using the access macros
23 typedef struct fmodule
27 unsigned is_cmdline_module
: 1;
32 msg_masks_t xPipeMask
;
33 msg_masks_t xNoGrabMask
;
34 msg_masks_t xSyncMask
;
39 #define MOD_IS_CMDLINE(m) ((m)->xflags.is_cmdline_module)
40 #define MOD_SET_CMDLINE(m,on) ((m)->xflags.is_cmdline_module = !!(on))
42 typedef struct fmodule_store
45 struct fmodule_store
*next
;
48 /* This defines the module list object */
49 typedef fmodule_store
* fmodule_list
;
51 /* this objects allows safe iteration over a module list */
52 typedef fmodule_store
* fmodule_list_itr
;
54 #define MOD_READFD(m) ((m)->xreadPipe)
55 #define MOD_WRITEFD(m) ((m)->xwritePipe)
56 #define MOD_PIPEQUEUE(m) ((m)->xpipeQueue)
57 #define MOD_PIPEMASK(m) ((m)->xPipeMask)
58 #define MOD_NAME(m) ((m)->xname)
59 #define MOD_ALIAS(m) ((m)->xalias)
61 /* this is a bit long winded to allow MAX_MESSAGE to be 32 and not get an
62 * integer overflow with (1 << MAX_MESSAGES) and even with
63 * (1<<(MAX_MESSAGES-1)) - 1 */
64 #define DEFAULT_MASK (MAX_MSG_MASK & ~(M_SENDCONFIG))
65 #define DEFAULT_XMASK (DEFAULT_XMSG_MASK)
68 * Returns zero if the msg is not selected by the mask. Takes care of normal
69 * and extended messages.
71 #define IS_MESSAGE_IN_MASK(mask, msg) \
72 (((msg)&M_EXTENDED_MSG) ? ((mask)->m2 & (msg)) : ((mask)->m1 & (msg)))
75 * Returns non zero if one of the specified messages is selected for the module
77 #define IS_MESSAGE_SELECTED(module, msg_mask) \
78 IS_MESSAGE_IN_MASK(&(MOD_PIPEMASK(module)), (msg_mask))
81 * M_SENDCONFIG for modules to tell fvwm that they want to see each
82 * module configuration command as it is entered. Causes modconf.c to
83 * look at each active module, find the ones that sent M_SENDCONFIG, and
84 * send a copy of the command in an M_CONFIG_INFO command.
87 /* struct to store module input data */
88 typedef struct fmodule_input
97 * Basic Module Handling Functions
100 /* kill all modules */
101 void module_kill_all(void);
104 void module_kill(fmodule
*module
);
106 /* execute module wraper, desperate mode */
107 fmodule
*executeModuleDesperate(F_CMD_ARGS
);
111 * Basic Module Communication Functions
114 /* send "raw" data to the module */
115 /* module_send(fmodule *module, unsigned long *ptr, int size); */
116 void PositiveWrite(fmodule
*module
, unsigned long *ptr
, int size
);
118 /* returns a dynamicaly allocated struct with the received data
119 * or NULL on error */
120 fmodule_input
*module_receive(fmodule
*module
);
122 /* frees an input data struct */
123 void module_input_discard(fmodule_input
*input
);
125 /* returns true if received the "expect" string, false otherwise */
126 Bool
module_input_expect(fmodule_input
*input
, char *expect
);
133 /* initializes the given iterator */
134 void module_list_itr_init(fmodule_list_itr
*itr
);
135 /* gets the next module on the list */
136 fmodule
*module_list_itr_next(fmodule_list_itr
*itr
);
138 /* free modules in the deathrow */
139 void module_cleanup(void);
144 * Message Queue Handling Functions
148 void FlushAllMessageQueues(void);
149 void FlushMessageQueue(fmodule
*module
);
153 * Misc Functions (should they be here?)
157 * exposed to be used by modconf.c
159 char *skipModuleAliasToken(const char *string
);
162 /* dead pipe signal handler - empty */
163 RETSIGTYPE
DeadPipe(int nonsense
);
165 #endif /* MODULE_LIST_H */