summaryrefslogtreecommitdiff
path: root/output.h
blob: 2e74d6145719df3ef1d028d49a7e5a33e444402b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * This file is part of ltrace.
 * Copyright (C) 2011, 2012, 2013 Petr Machata, Red Hat Inc.
 * Copyright (C) 2009 Juan Cespedes
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */
#ifndef _OUTPUT_H_
#define _OUTPUT_H_

#include "fetch.h"
#include "forward.h"

void output_line(struct process *proc, const char *fmt, ...);
void output_left(enum tof type, struct process *proc,
		 struct library_symbol *libsym);
void output_right(enum tof type, struct process *proc,
		  struct library_symbol *libsym,
		  struct timedelta *spent);

/* This function is for emitting lists of comma-separated strings.
 *
 * STREAM is where the output should be eventually sent.
 *
 * WRITER is the function to do the output.  It returns number of
 * characters written, or a negative value if there were errors (like
 * what fprintf does).  If WRITER returns 0, it means nothing was
 * written, and separator shouldn't therefore be emitted either.
 *
 * NEED_DELIMP serves for keeping state between calls.  It should
 * point to a variable that is initialized to 0.  DATA is passed
 * verbatim to the WRITER.
 *
 * Returns number of characters written to STREAM (including any
 * separators), or a negative value if there were errors.  */
int delim_output(FILE *stream, int *need_delimp,
		 int (*writer)(FILE *stream, void *data), void *data);

/* If C is positive, add it to *COUNTP.  Returns C.  */
int account_output(int *countp, int c);

void report_error(char const *file, unsigned line_no, const char *fmt, ...);
void report_warning(char const *file, unsigned line_no, const char *fmt, ...);
void report_global_error(const char *fmt, ...);

#endif /* _OUTPUT_H_ */