X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/fwd/blobdiff_plain/1cd4a3bfdaf82f0bc0691671954b239dccb003fb..57ceb980e3c55306f3f70f92604703abf132cf27:/fwd.h diff --git a/fwd.h b/fwd.h index 5868fda..e295c8b 100644 --- a/fwd.h +++ b/fwd.h @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -87,6 +88,7 @@ #include #include #include +#include #include #include #include @@ -265,14 +267,26 @@ extern sel_state *sel; +/* --- Global state flags --- */ + +extern unsigned flags; + +#define FW_SYSLOG 1u +#define FW_QUIET 2u +#define FW_SET 4u + /* --- Help text --- */ extern const char grammar_text[]; extern const char option_text[]; +/* --- Generally useful magic constants --- */ + +#define NOW ((time_t)-1) + /* --- @fw_log@ --- * * - * Arguments: @time_t t@ = when the connection occurred or (@-1@) + * Arguments: @time_t t@ = when the connection occurred or (@NOW@) * @const char *fmt@ = format string to fill in * @...@ = other arguments * @@ -281,7 +295,8 @@ extern const char option_text[]; * Use: Logs a connection. */ -extern void fw_log(time_t /*t*/, const char */*fmt*/, ...); +extern void PRINTF_LIKE(2, 3) + fw_log(time_t /*t*/, const char */*fmt*/, ...); /* --- @fw_inc@, @fw_dec@ --- * * @@ -529,7 +544,8 @@ extern int token(scanner */*sc*/); * Use: Reports an error at the current scanner location. */ -extern void error(scanner */*sc*/, const char */*msg*/, ...); +extern void PRINTF_LIKE(2, 3) NORETURN + error(scanner */*sc*/, const char */*msg*/, ...); /* --- @pushback@ --- * * @@ -883,6 +899,7 @@ typedef struct endpt_ops { typedef struct target { struct target_ops *ops; + unsigned ref; char *desc; } target; @@ -957,9 +974,13 @@ typedef struct target_ops { typedef struct source { struct source *next, *prev; struct source_ops *ops; + unsigned ref; + unsigned f; +#define SF_ACTIVE 1u char *desc; } source; + /* --- Forwarding source operations --- */ typedef struct source_ops { @@ -1003,6 +1024,18 @@ typedef struct source_ops { void (*attach)(source */*s*/, scanner */*sc*/, target */*t*/); + /* --- @shutdown@ --- * + * + * Arguments: @source *s@ = pointer to source + * + * Returns: --- + * + * Use: Deactivates the source so that it won't produce any more + * endpoints. + */ + + void (*shutdown)(source */*s*/); + /* --- @destroy@ --- * * * Arguments: @source *s@ = pointer to source @@ -1062,6 +1095,28 @@ extern void endpt_killall(void); extern void endpt_join(endpt */*a*/, endpt */*b*/, const char */*desc*/); +/* --- @target_inc@ --- * + * + * Arguments: @target *t@ = pointer to a source + * + * Returns: --- + * + * Use: Increments a target's refcount. + */ + +extern void target_inc(target */*t*/); + +/* --- @target_dec@ --- * + * + * Arguments: @target *t@ = pointer to a target + * + * Returns: --- + * + * Use: Decrements a target's refcount, destroying it if necessary. + */ + +extern void target_dec(target */*t*/); + /* --- @source_add@ --- * * * Arguments: @source *s@ = pointer to a source @@ -1086,6 +1141,28 @@ extern void source_add(source */*s*/); extern void source_remove(source */*s*/); +/* --- @source_inc@ --- * + * + * Arguments: @source *s@ = pointer to a source + * + * Returns: --- + * + * Use: Increments a source's refcount. + */ + +extern void source_inc(source */*s*/); + +/* --- @source_dec@ --- * + * + * Arguments: @source *s@ = pointer to a source + * + * Returns: --- + * + * Use: Decrements a source's refcount, destroying it if necessary. + */ + +extern void source_dec(source */*s*/); + /* --- @source_killall@ --- * * * Arguments: ---