-
Notifications
You must be signed in to change notification settings - Fork 59
/
GLibFacade.h
100 lines (82 loc) · 3.24 KB
/
GLibFacade.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* GLibFacade.h
* MultiMarkdown
*
* Created by Daniel Jalkut on 7/26/11.
* Modified by Fletcher T. Penney on 9/15/11 and 12/3/13.
* Modified by Dan Lowe on 1/3/12.
*
* License for original code by Daniel Jalkut:
*
* Copyright 2011 Daniel Jalkut. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the “Software”), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __MARKDOWN_GLIB_FACADE__
#define __MARKDOWN_GLIB_FACADE__
/* peg_markdown uses the link symbol for its own purposes */
#define link MARKDOWN_LINK_IGNORED
#include <unistd.h>
#undef link
#include <stdbool.h>
#include <ctype.h>
typedef int gboolean;
typedef char gchar;
/* This style of bool is used in shared source code */
#if !defined(FALSE)
#define FALSE false
#endif
#if !defined(TRUE)
#define TRUE true
#endif
/* WE implement minimal mirror implementations of GLib's GString and GSList
* sufficient to cover the functionality required by MultiMarkdown.
*
* NOTE: THese are 100% clean, from-scratch implementations using only the
* GLib function prototype as guide for behavior.
*/
typedef struct
{
/* Current UTF8 byte stream this string represents */
char* str;
/* Where in the str buffer will we add new characters */
/* or append new strings? */
unsigned long currentStringBufferSize;
unsigned long currentStringLength;
} GString;
GString* g_string_new(char *startingString);
char* g_string_free(GString* ripString, bool freeCharacterData);
void g_string_append_c(GString* baseString, char appendedCharacter);
void g_string_append(GString* baseString, char *appendedString);
void g_string_prepend(GString* baseString, char* prependedString);
void g_string_append_printf(GString* baseString, char* format, ...);
void g_string_insert(GString* baseString, size_t pos, char * insertedString);
void g_string_insert_c(GString* baseString, size_t pos, char insertedCharacter);
void g_string_insert_printf(GString* baseString, size_t pos, char* format, ...);
void g_string_erase(GString* baseString, size_t pos, size_t len);
/* Just implement a very simple singly linked list. */
typedef struct _GSList
{
void* data;
struct _GSList* next;
} GSList;
void g_slist_free(GSList* ripList);
GSList* g_slist_prepend(GSList* targetElement, void* newElementData);
GSList* g_slist_reverse(GSList* theList);
#endif