gitout

A static git page generator
git clone https://git.bracken.jp/gitout.git
Log | Files | Refs | Submodules | README | LICENSE

format.h (1608B)


      1 #ifndef GITOUT_FORMAT_H_
      2 #define GITOUT_FORMAT_H_
      3 
      4 #include <stdbool.h>
      5 #include <stdio.h>
      6 #include <sys/types.h>
      7 
      8 /* Prints the formatted time in the local timezone: Wed 5 Dec 2023 23:59:59 +9
      9  *
     10  * time: time, in seconds since the epoch.
     11  * tz_offset: timezone offset from UTC, in minutes.
     12  */
     13 void print_time(FILE* out, time_t time, int tz_offset);
     14 
     15 /* Prints the formatted time in UTC: 2023-12-31T23:59:59Z */
     16 void print_time_z(FILE* out, time_t time);
     17 
     18 /* Prints the formatted time in UTC: 2023-12-31 23:59 */
     19 void print_time_short(FILE* out, time_t time);
     20 
     21 /* Prints a string to out, percent-encoded. See RFC3986 section 2.1. */
     22 void print_percent_encoded(FILE* out, const char* str);
     23 
     24 /* Prints a string to out, encoded HTML 2.0 / XML 1.0.
     25  *
     26  * If str_len >= 0, only the first str_len bytes of str are read.
     27  * If output_crlf is true, also prints '\r' and '\n' characters.
     28  */
     29 void print_xml_encoded(FILE* out, const char* str);
     30 void print_xml_encoded_len(FILE* out,
     31                            const char* str,
     32                            ssize_t str_len,
     33                            bool output_crlf);
     34 
     35 void print_gopher_text(FILE* out, const char* str, bool output_lf);
     36 void print_gopher_text_len(FILE* out,
     37                            const char* str,
     38                            ssize_t str_len,
     39                            bool output_lf);
     40 
     41 void print_gopher_link(FILE* out, const char* str);
     42 void print_gopher_link_padded(FILE* out,
     43                               const char* str,
     44                               size_t width,
     45                               char pad_char);
     46 
     47 #endif  // GITOUT_FORMAT_H_