From 334d4f315ef45b1506b880b3e64ea023611eb2fb Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 18 Feb 2023 13:44:28 +0000 Subject: [PATCH] Add some extra stub modules. Also for use in test programs: stub modules that provide non- functional versions of logging, printing and storage. --- stubs/no-logging.c | 20 ++++++++++++++++++++ stubs/no-printing.c | 18 ++++++++++++++++++ stubs/no-storage.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 stubs/no-logging.c create mode 100644 stubs/no-printing.c create mode 100644 stubs/no-storage.c diff --git a/stubs/no-logging.c b/stubs/no-logging.c new file mode 100644 index 00000000..cb361c08 --- /dev/null +++ b/stubs/no-logging.c @@ -0,0 +1,20 @@ +/* + * Stub module implementing the logging API for tools that don't do + * session logging. + */ + +#include "putty.h" + +void logtraffic(LogContext *ctx, unsigned char c, int logmode) {} +void logflush(LogContext *ctx) {} +void logevent(LogContext *ctx, const char *event) {} +void log_free(LogContext *ctx) {} +void log_reconfig(LogContext *ctx, Conf *conf) {} +void log_packet(LogContext *ctx, int direction, int type, + const char *texttype, const void *data, size_t len, + int n_blanks, const struct logblank_t *blanks, + const unsigned long *seq, + unsigned downstream_id, const char *additional_log_text) {} + +LogContext *log_init(LogPolicy *lp, Conf *conf) +{ return NULL; } diff --git a/stubs/no-printing.c b/stubs/no-printing.c new file mode 100644 index 00000000..6c8859e7 --- /dev/null +++ b/stubs/no-printing.c @@ -0,0 +1,18 @@ +/* + * Stub module implementing the printing API for tools that don't + * print. + */ + +#include "putty.h" + +printer_job *printer_start_job(char *printer) { return NULL; } +void printer_job_data(printer_job *pj, const void *data, size_t len) {} +void printer_finish_job(printer_job *pj) {} + +printer_enum *printer_start_enum(int *nprinters_ptr) +{ + *nprinters_ptr = 0; + return NULL; +} +char *printer_get_name(printer_enum *pe, int i) { return NULL; } +void printer_finish_enum(printer_enum *pe) {} diff --git a/stubs/no-storage.c b/stubs/no-storage.c new file mode 100644 index 00000000..a8671a15 --- /dev/null +++ b/stubs/no-storage.c @@ -0,0 +1,40 @@ +/* + * Stub module implementing the saved-session storage APIs for tools + * that don't load or save sessions. + */ + +#include "putty.h" + +settings_w *open_settings_w(const char *sessionname, char **errmsg) +{ return NULL; } +void write_setting_s(settings_w *handle, const char *key, const char *value) +{ unreachable("where did you get a settings_w from?"); } +void write_setting_i(settings_w *handle, const char *key, int value) +{ unreachable("where did you get a settings_w from?"); } +void write_setting_fontspec(settings_w *handle, const char *name, FontSpec *fs) +{ unreachable("where did you get a settings_w from?"); } +void write_setting_filename(settings_w *handle, const char *name, Filename *fn) +{ unreachable("where did you get a settings_w from?"); } +void close_settings_w(settings_w *handle) +{ unreachable("where did you get a settings_w from?"); } + +settings_r *open_settings_r(const char *sessionname) +{ return NULL; } +char *read_setting_s(settings_r *handle, const char *key) +{ return NULL; } +int read_setting_i(settings_r *handle, const char *key, int defvalue) +{ return defvalue; } +FontSpec *read_setting_fontspec(settings_r *handle, const char *name) +{ return fontspec_new_default(); } +Filename *read_setting_filename(settings_r *handle, const char *name) +{ return filename_from_str(""); } +void close_settings_r(settings_r *handle) { } + +void del_settings(const char *sessionname) {} + +settings_e *enum_settings_start(void) +{ return NULL; } +bool enum_settings_next(settings_e *handle, strbuf *out) +{ unreachable("where did you get a settings_e from?"); } +void enum_settings_finish(settings_e *handle) +{ unreachable("where did you get a settings_e from?"); }