Home | History | Annotate | Line # | Download | only in roken
      1 /*	$NetBSD: rtbl.h,v 1.3 2019/12/15 22:50:51 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2000,2004 Kungliga Tekniska Hgskolan
      5  * (Royal Institute of Technology, Stockholm, Sweden).
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  *
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  *
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * 3. Neither the name of the Institute nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  */
     35 /* Id */
     36 
     37 #ifndef __rtbl_h__
     38 #define __rtbl_h__
     39 
     40 #ifndef ROKEN_LIB_FUNCTION
     41 #ifdef _WIN32
     42 #define ROKEN_LIB_FUNCTION
     43 #define ROKEN_LIB_CALL     __cdecl
     44 #else
     45 #define ROKEN_LIB_FUNCTION
     46 #define ROKEN_LIB_CALL
     47 #endif
     48 #endif
     49 
     50 #if !defined(__GNUC__) && !defined(__attribute__)
     51 #define __attribute__(x)
     52 #endif
     53 
     54 #ifdef __cplusplus
     55 extern "C" {
     56 #endif
     57 
     58 struct rtbl_data;
     59 typedef struct rtbl_data *rtbl_t;
     60 
     61 #define RTBL_ALIGN_LEFT		0
     62 #define RTBL_ALIGN_RIGHT	1
     63 
     64 /* flags */
     65 #define RTBL_HEADER_STYLE_NONE	1
     66 #define RTBL_JSON		2
     67 
     68 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     69 rtbl_add_column (rtbl_t, const char*, unsigned int);
     70 
     71 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     72 rtbl_add_column_by_id (rtbl_t, unsigned int, const char*, unsigned int);
     73 
     74 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     75 rtbl_add_column_entryv_by_id (rtbl_t table, unsigned int id,
     76 			      const char *fmt, ...)
     77 	__attribute__ ((__format__ (__printf__, 3, 0)));
     78 
     79 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     80 rtbl_add_column_entry (rtbl_t, const char*, const char*);
     81 
     82 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     83 rtbl_add_column_entryv (rtbl_t, const char*, const char*, ...)
     84 	__attribute__ ((__format__ (__printf__, 3, 0)));
     85 
     86 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     87 rtbl_add_column_entry_by_id (rtbl_t, unsigned int, const char*);
     88 
     89 ROKEN_LIB_FUNCTION rtbl_t ROKEN_LIB_CALL
     90 rtbl_create (void);
     91 
     92 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
     93 rtbl_destroy (rtbl_t);
     94 
     95 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
     96 rtbl_format (rtbl_t, FILE*);
     97 
     98 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
     99 rtbl_format_str (rtbl_t);
    100 
    101 ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
    102 rtbl_get_flags (rtbl_t);
    103 
    104 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    105 rtbl_new_row (rtbl_t);
    106 
    107 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    108 rtbl_set_column_affix_by_id (rtbl_t, unsigned int, const char*, const char*);
    109 
    110 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    111 rtbl_set_column_prefix (rtbl_t, const char*, const char*);
    112 
    113 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    114 rtbl_set_flags (rtbl_t, unsigned int);
    115 
    116 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    117 rtbl_set_prefix (rtbl_t, const char*);
    118 
    119 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    120 rtbl_set_separator (rtbl_t, const char*);
    121 
    122 #ifdef __cplusplus
    123 }
    124 #endif
    125 
    126 #endif /* __rtbl_h__ */
    127