source: rtems/cpukit/include/rtems/print.h @ 5c370a5d

5
Last change on this file since 5c370a5d was 214156d, checked in by Sebastian Huber <sebastian.huber@…>, on 06/03/16 at 12:54:05

mghttpd: Add RTEMS printer support

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/**
2 * @file rtems/print.h
3 *
4 * @brief User print interface to the bspIO print plug in.
5 *
6 * This include file defines the user interface to kernel print methods.
7 */
8
9/*
10 *  Copyright (c) 2016 Chris Johns <chrisj@rtems.org>
11 *  All rights reserved.
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_PRINT_H
19#define _RTEMS_PRINT_H
20
21#include <stdbool.h>
22#include <stddef.h>
23#include <stdio.h>
24
25#include <rtems/bspIo.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * @defgroup RTEMS Print Support
33 *
34 * This module contains all methods and support related to providing the user
35 * with an interface to the kernel level print support.
36 */
37
38/**
39 * Type definition for the printer structure used to access the kernel print
40 * support.
41 */
42typedef struct rtems_printer {
43  void                *context;
44  rtems_print_plugin_t printer;
45} rtems_printer;
46
47/**
48 * @brief check if the printer is valid.
49 *
50 * @param[in] printer Pointer to the printer structure.
51 *
52 * @return true The printer is valid else false is returned.
53 */
54static inline bool rtems_print_printer_valid(const rtems_printer *printer)
55{
56  return printer != NULL && printer->printer != NULL;
57}
58
59/**
60 * @brief Print to the kernel plugin handler. This has to be a macro because
61 * there is no vprint version of the plug in handlers.
62 *
63 * @param[in] printer Pointer to the printer structure.
64 * @param[in] fmt Print format string.
65 * @param[in] ... Print variable argument list.
66 *
67 * @return int Number of characters printed.
68 */
69extern int rtems_printf(const rtems_printer *printer,
70                        const char          *format,
71                        ...) RTEMS_PRINTF_ATTRIBUTE(2, 3);
72
73/**
74 * @brief Print to the kernel plugin handler. This has to be a macro because
75 * there is no vprint version of the plug in handlers.
76 *
77 * @param[in] printer Pointer to the printer structure.
78 * @param[in] fmt Print format string.
79 * @param[in] ap Print variable argument list pointer.
80 *
81 * @return int Number of characters printed.
82 */
83extern int rtems_vprintf(const rtems_printer *printer,
84                         const char          *format,
85                         va_list              ap);
86
87/**
88 * @brief Intiialise the rtems_printer struct to empty.
89 *
90 * An empty printer prints nothing. You can use this to implement an enable and
91 * disable type print implementation.
92 *
93 * @param[in] printer Pointer to the printer structure.
94 */
95static inline void rtems_print_printer_empty(rtems_printer *printer)
96{
97  printer->context = NULL;
98  printer->printer = NULL;
99}
100
101/**
102 * @brief Intiialise the rtems_printer struct to printk
103 *
104 * The printer will output to the kernel printk support.
105 *
106 * @param[in] printer Pointer to the printer structure.
107 */
108void rtems_print_printer_printk(rtems_printer *printer);
109
110/**
111 * @brief Intiialise the rtems_printer struct to printf
112 *
113 * The printer will output to the libc printf support.
114 *
115 * @param[in] printer Pointer to the printer structure.
116 */
117extern void rtems_print_printer_printf(rtems_printer *printer);
118
119/**
120 * @brief Intiialise the rtems_printer struct to a fprintf device.
121 *
122 * The printer will output to the libc fprintf file provided.
123 *
124 * @param[in] printer Pointer to the printer structure.
125 */
126extern void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
127
128/**@}*/
129
130#ifdef __cplusplus
131}
132#endif
133
134#endif
Note: See TracBrowser for help on using the repository browser.