1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

Add some extra stub modules.

Also for use in test programs: stub modules that provide non-
functional versions of logging, printing and storage.
This commit is contained in:
Simon Tatham 2023-02-18 13:44:28 +00:00
parent edce3fb9da
commit 334d4f315e
3 changed files with 78 additions and 0 deletions

20
stubs/no-logging.c Normal file
View File

@ -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; }

18
stubs/no-printing.c Normal file
View File

@ -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) {}

40
stubs/no-storage.c Normal file
View File

@ -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?"); }