X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=miniexpect.h;h=2e9b534c95f9e43f522e13ef5809349cec4cf737;hb=fcf73607913050d246dbcc4f39e7717d0960763f;hp=192d18028dc8032fb7238c99d561e3f1ead895e8;hpb=3df4c0d3e4192cb6bb8e9ed7126346ab6aa98043;p=miniexpect.git diff --git a/miniexpect.h b/miniexpect.h index 192d180..2e9b534 100644 --- a/miniexpect.h +++ b/miniexpect.h @@ -1,5 +1,5 @@ /* miniexpect - * Copyright (C) 2014 Red Hat Inc. + * Copyright (C) 2014-2022 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,9 +29,11 @@ #ifndef MINIEXPECT_H_ #define MINIEXPECT_H_ +#include #include -#include +#define PCRE2_CODE_UNIT_WIDTH 8 +#include /* This handle is created per subprocess that is spawned. */ struct mexp_h { @@ -44,6 +46,7 @@ struct mexp_h { ssize_t next_match; size_t read_size; int pcre_error; + FILE *debug_fp; void *user1; void *user2; void *user3; @@ -62,10 +65,19 @@ typedef struct mexp_h mexp_h; #define mexp_get_read_size(h) ((h)->read_size) #define mexp_set_read_size(h, size) ((h)->read_size = (size)) #define mexp_get_pcre_error(h) ((h)->pcre_error) +#define mexp_set_debug_file(h, fp) ((h)->debug_fp = (fp)) +#define mexp_get_debug_file(h) ((h)->debug_fp) /* Spawn a subprocess. */ -extern mexp_h *mexp_spawnv (const char *file, char **argv); -extern mexp_h *mexp_spawnl (const char *file, const char *arg, ...); +extern mexp_h *mexp_spawnvf (unsigned flags, const char *file, char **argv); +extern mexp_h *mexp_spawnlf (unsigned flags, const char *file, const char *arg, ...); +#define mexp_spawnv(file,argv) mexp_spawnvf (0, (file), (argv)) +#define mexp_spawnl(file,...) mexp_spawnlf (0, (file), __VA_ARGS__) + +#define MEXP_SPAWN_KEEP_SIGNALS 1 +#define MEXP_SPAWN_KEEP_FDS 2 +#define MEXP_SPAWN_COOKED_MODE 4 +#define MEXP_SPAWN_RAW_MODE 0 /* Close the handle. */ extern int mexp_close (mexp_h *h); @@ -73,8 +85,7 @@ extern int mexp_close (mexp_h *h); /* Expect. */ struct mexp_regexp { int r; - const pcre *re; - const pcre_extra *extra; + const pcre2_code *re; int options; }; typedef struct mexp_regexp mexp_regexp; @@ -87,9 +98,13 @@ enum mexp_status { }; extern int mexp_expect (mexp_h *h, const mexp_regexp *regexps, - int *ovector, int ovecsize); + pcre2_match_data *match_data); +/* Sending commands, keypresses. */ extern int mexp_printf (mexp_h *h, const char *fs, ...) __attribute__((format(printf,2,3))); +extern int mexp_printf_password (mexp_h *h, const char *fs, ...) + __attribute__((format(printf,2,3))); +extern int mexp_send_interrupt (mexp_h *h); #endif /* MINIEXPECT_H_ */