'\" t .\" Title: libtraceevent .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 02/15/2021 .\" Manual: libtraceevent Manual .\" Source: libtraceevent 1.1.2 .\" Language: English .\" .TH "LIBTRACEEVENT" "3" "02/15/2021" "libtraceevent 1\&.1\&.2" "libtraceevent Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" trace_seq_init, trace_seq_destroy, trace_seq_reset, trace_seq_terminate, trace_seq_putc, trace_seq_puts, trace_seq_printf, trace_seq_vprintf, trace_seq_do_fprintf, trace_seq_do_printf \- Initialize / destroy a trace sequence\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR \fB#include \fR void \fBtrace_seq_init\fR(struct trace_seq *\fIs\fR); void \fBtrace_seq_destroy\fR(struct trace_seq *\fIs\fR); void \fBtrace_seq_reset\fR(struct trace_seq *\fIs\fR); void \fBtrace_seq_terminate\fR(struct trace_seq *\fIs\fR); int \fBtrace_seq_putc\fR(struct trace_seq *\fIs\fR, unsigned char \fIc\fR); int \fBtrace_seq_puts\fR(struct trace_seq *\fIs\fR, const char *\fIstr\fR); int \fBtrace_seq_printf\fR(struct trace_seq *\fIs\fR, const char *\fIfmt\fR, \fI\&...\fR); int \fBtrace_seq_vprintf\fR(struct trace_seq *\fIs\fR, const char *\fIfmt\fR, va_list \fIargs\fR); int \fBtrace_seq_do_printf\fR(struct trace_seq *\fIs\fR); int \fBtrace_seq_do_fprintf\fR(struct trace_seq *\fIs\fR, FILE *\fIfp\fR); .fi .SH "DESCRIPTION" .sp Trace sequences are used to allow a function to call several other functions to create a string of data to use\&. .sp The \fItrace_seq_init()\fR function initializes the trace sequence \fIs\fR\&. .sp The \fItrace_seq_destroy()\fR function destroys the trace sequence \fIs\fR and frees all its resources that it had used\&. .sp The \fItrace_seq_reset()\fR function re\-initializes the trace sequence \fIs\fR\&. All characters already written in \fIs\fR will be deleted\&. .sp The \fItrace_seq_terminate()\fR function terminates the trace sequence \fIs\fR\&. It puts the null character \*(Aq\e0\*(Aq at the end of the buffer\&. .sp The \fItrace_seq_putc()\fR function puts a single character \fIc\fR in the trace sequence \fIs\fR\&. .sp The \fItrace_seq_puts()\fR function puts a NULL terminated string \fIstr\fR in the trace sequence \fIs\fR\&. .sp The \fItrace_seq_printf()\fR function puts a formated string \fIfmt _with variable arguments _\&...\fR in the trace sequence \fIs\fR\&. .sp The \fItrace_seq_vprintf()\fR function puts a formated string \fIfmt _with list of arguments _args\fR in the trace sequence \fIs\fR\&. .sp The \fItrace_seq_do_printf()\fR function prints the buffer of trace sequence \fIs\fR to the standard output stdout\&. .sp The \fItrace_seq_do_fprintf()\fR function prints the buffer of trace sequence \fIs\fR to the given file \fIfp\fR\&. .SH "RETURN VALUE" .sp Both \fItrace_seq_putc()\fR and \fItrace_seq_puts()\fR functions return the number of characters put in the trace sequence, or 0 in case of an error .sp Both \fItrace_seq_printf()\fR and \fItrace_seq_vprintf()\fR functions return 0 if the trace oversizes the buffer\(cqs free space, the number of characters printed, or a negative value in case of an error\&. .sp Both \fItrace_seq_do_printf()\fR and \fItrace_seq_do_fprintf()\fR functions return the number of printed characters, or \-1 in case of an error\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include #include \&.\&.\&. struct trace_seq seq; trace_seq_init(&seq); \&.\&.\&. void foo_seq_print(struct trace_seq *tseq, char *format, \&.\&.\&.) { va_list ap; va_start(ap, format); if (trace_seq_vprintf(tseq, format, ap) <= 0) { /* Failed to print in the trace sequence */ } va_end(ap); } trace_seq_reset(&seq); char *str = " MAN page example"; if (trace_seq_puts(&seq, str) != strlen(str)) { /* Failed to put str in the trace sequence */ } if (trace_seq_putc(&seq, \*(Aq:\*(Aq) != 1) { /* Failed to put \*(Aq:\*(Aq in the trace sequence */ } if (trace_seq_printf(&seq, " trace sequence: %d", 1) <= 0) { /* Failed to print in the trace sequence */ } foo_seq_print( &seq, " %d\en", 2); trace_seq_terminate(&seq); \&.\&.\&. if (trace_seq_do_printf(&seq) < 0 ) { /* Failed to print the sequence buffer to the standard output */ } FILE *fp = fopen("trace\&.txt", "w"); if (trace_seq_do_fprintf(&seq, fp) < 0 ) [ /* Failed to print the sequence buffer to the trace\&.txt file */ } trace_seq_destroy(&seq); \&.\&.\&. .fi .if n \{\ .RE .\} .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBevent\-parse\&.h\fR Header file to include in order to have access to the library APIs\&. \fBtrace\-seq\&.h\fR Header file to include in order to have access to trace sequences related APIs\&. \fB\-ltraceevent\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fIlibtraceevent(3)\fR, \fItrace\-cmd(1)\fR .SH "AUTHOR" .sp .if n \{\ .RS 4 .\} .nf \fBSteven Rostedt\fR <\m[blue]\fBrostedt@goodmis\&.org\fR\m[]\&\s-2\u[1]\d\s+2>, author of \fBlibtraceevent\fR\&. \fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2>, author of this man page\&. .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[3]\d\s+2> .SH "LICENSE" .sp libtraceevent is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/libs/libtrace/libtraceevent\&.git/\fR\m[] .SH "NOTES" .IP " 1." 4 rostedt@goodmis.org .RS 4 \%mailto:rostedt@goodmis.org .RE .IP " 2." 4 tz.stoyanov@gmail.com .RS 4 \%mailto:tz.stoyanov@gmail.com .RE .IP " 3." 4 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE