-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.txt
128 lines (82 loc) · 2.64 KB
/
readme.txt
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## Introduction
Simple markdown hoster.
Upload tar.gz containing your markdown files and assets. Displays as html.
This is only my learning projects to learn more about C :D
Feel free to use and modify.
Cheers :D
FYI:
This project (repo) is used for my personal website (https://www.kokobow.fun)
So please expects you will find unrelated things:
- me/ (holds welcoming page)
- heroku.yml (for my personal website deployment platform)
## How to use
prerequisite: Compile cli & server (please go to section #compile)
Suppose you have directory with the following structures
```
+ pages /
+ index.md
+ page1.md
```
Archive it first using provided cli binary (see section #Uploading)
It will output the file in format [uuid].tar.gz
Upload your files, use postman collection provided in misc/postman_collection.json
Once upload done, server will store your tar.gz and extract the archives to
```
md/out/[your_file].tar.gz/
```
To access your site, simply go to:
```
[base_url]/md/out/test.tar.gz/index.md
```
Note:
Server doesn't save any states of uploading files.
So if you deploy in a platform that uses ephemeral storage, your uploaded files will be lost if you reboot the server
## compile
- dependencies
+ https://www.libarchive.org/
+ https://sourceforge.net/projects/libuuid/
+ https://www.gnu.org/software/libmicrohttpd/
+ https://github.com/mity/md4c
```
gcc cmd/cli.c -o bin/cli -larchive -luuid
```
## compile server
```
gcc cmd/server.c -o bin/server -larchive -luuid -lmicrohttpd -lmd4c-html
```
## Uploading
ls -d -1 sample_md/* | ./cli
## Server
```
./bin/server
```
It will serve HTTP on PORT 8080
To terminate, simply type any character then press enter.
Note:
If you have successfully compiled server.c but when running you encounter message like this:
```
./bin/server: error while loading shared libraries: libmd4c-html.so.0: cannot open shared object file: No such file or directory
```
The workaround I use is to specify LD_LIBRARY_PATH to /usr/local/lib64:
```
[kenny_void@(none) md-hoster]$ LD_LIBRARY_PATH=/usr/local/lib64
[kenny_void@(none) md-hoster]$ export LD_LIBRARY_PATH
[kenny_void@(none) md-hoster]$ sudo ldconfig
```
## Valgrind
Version: 3.20.0
```
valgrind --leak-check=yes --track-origins=yes ./bin/server
```
Latest report
```
==30205==
==30205== HEAP SUMMARY:
==30205== in use at exit: 0 bytes in 0 blocks
==30205== total heap usage: 1,018 allocs, 1,018 frees, 844,804 bytes allocated
==30205==
==30205== All heap blocks were freed -- no leaks are possible
==30205==
==30205== For lists of detected and suppressed errors, rerun with: -s
==30205== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```