* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/ .
+ * along with this program. If not, see https://www.gnu.org/licenses/ .
*
* Author: Peter Feigl <peter.feigl@gmx.at>
*/
+#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <talloc.h>
/* A flag to signify that a separator should be inserted in the
* output as soon as possible. */
- notmuch_bool_t insert_separator;
+ bool insert_separator;
};
struct sexp_state {
/* True if nothing has been printed in this aggregate yet.
* Suppresses the space before a value. */
- notmuch_bool_t first;
+ bool first;
};
/* Helper function to set up the stream to print a value. If this
if (! sps->state->first) {
if (sps->insert_separator) {
fputc ('\n', sps->stream);
- sps->insert_separator = FALSE;
+ sps->insert_separator = false;
} else {
fputc (' ', sps->stream);
}
} else {
- sps->state->first = FALSE;
+ sps->state->first = false;
}
}
return sps;
fputc ('(', sps->stream);
state->parent = sps->state;
- state->first = TRUE;
+ state->first = true;
sps->state = state;
}
}
static void
-sexp_integer (struct sprinter *sp, int val)
+sexp_integer (struct sprinter *sp, int64_t val)
{
struct sprinter_sexp *sps = sexp_begin_value (sp);
- fprintf (sps->stream, "%d", val);
+ fprintf (sps->stream, "%" PRId64, val);
}
static void
-sexp_boolean (struct sprinter *sp, notmuch_bool_t val)
+sexp_boolean (struct sprinter *sp, bool val)
{
struct sprinter_sexp *sps = sexp_begin_value (sp);
{
struct sprinter_sexp *sps = (struct sprinter_sexp *) sp;
- sps->insert_separator = TRUE;
+ sps->insert_separator = true;
}
struct sprinter *
-sprinter_sexp_create (const void *ctx, FILE *stream)
+sprinter_sexp_create (notmuch_database_t *db, FILE *stream)
{
static const struct sprinter_sexp template = {
.vtable = {
.map_key = sexp_map_key,
.separator = sexp_separator,
.set_prefix = sexp_set_prefix,
- .is_text_printer = FALSE,
+ .is_text_printer = false,
}
};
struct sprinter_sexp *res;
- res = talloc (ctx, struct sprinter_sexp);
+ res = talloc (db, struct sprinter_sexp);
if (! res)
return NULL;
*res = template;
+ res->vtable.notmuch = db;
res->stream = stream;
return &res->vtable;
}