• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef CRAS_DUMPER_H_
7 #define CRAS_DUMPER_H_
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <stdio.h>
14 
15 /* dumper is an interface to output some human-readable information */
16 struct dumper {
17 	void (*vprintf)(struct dumper *dumper, const char *format, va_list ap);
18 	void *data;  /* private to each dumper */
19 };
20 
21 /* a convenience function outputs to a dumper */
22 void dumpf(struct dumper *dumper, const char *format, ...);
23 
24 /*
25  * a dumper outputs to syslog with the given priority
26  */
27 struct dumper *syslog_dumper_create(int priority);
28 void syslog_dumper_free(struct dumper *dumper);
29 
30 /*
31  * a dumper saves the output in a memory buffer
32  */
33 struct dumper *mem_dumper_create();
34 void mem_dumper_free(struct dumper *dumper);
35 
36 /* get the memory buffer of the output */
37 void mem_dumper_get(struct dumper *dumper, char **buf, int *size);
38 
39 /* clear the memory buffer */
40 void mem_dumper_clear(struct dumper *dumper);
41 
42 /* delete the first n characters in the memory buffer */
43 void mem_dumper_consume(struct dumper *dumper, int n);
44 
45 #ifdef __cplusplus
46 } /* extern "C" */
47 #endif
48 
49 #endif /* CRAS_DUMPER_H_ */
50