7 * protect some information, not that I care, but this is just to stay
10 #define SECURITY_BASE "\
11 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
12 #define SECURITY_TOKEN "\
13 P29hdXRoX2NvbnN1bWVyX2tleT03NnZoM3E0Mmhudm16bTMmb2F1dGhfdG9rZW49\
14 dzBieHpmMGRmdDhlZGZxJm9hdXRoX3NpZ25hdHVyZV9tZXRob2Q9UExBSU5URVhU\
15 Jm9hdXRoX3NpZ25hdHVyZT10bWVlY2h0MmNtaDcyeGElMjY5dm9zeDd4OGd5NGtn\
16 amsmb2F1dGhfdGltZXN0YW1wPSZvYXV0aF9ub25jZT0xMjE2NQo="
18 int isbase64(char c) {
19 return !!(c && strchr(SECURITY_BASE, c) != NULL);
22 const char *load = SECURITY_BASE;
23 const char *find = strchr(load, c);
25 return (find) ? find - load : 0;
28 int security_decode(unsigned char *dest, const unsigned char *src, int srclen) {
38 *p++ = (value(src[0]) << 2) | (value(src[1]) >> 4);
39 *p++ = (value(src[1]) << 4) | (value(src[2]) >> 2);
40 *p++ = (value(src[2]) << 6) | (value(src[3]) >> 0);
42 if(!isbase64(src[1])) {
46 else if(!isbase64(src[2])) {
50 else if(!isbase64(src[3])) {
56 while(*src && (*src == 13 || *src == 10))
64 #define BASEURL " https://api-content.dropbox.com/1/files/sandbox/"
67 * If more platforms are supported add the entries between the start
68 * tag here, and the end tag below. Nothing else needs to be done
69 * <tag> (the table needs to match the HTML too)
71 #define ARCHLINUX_32_REF "%sgmqcc-%c.%c.%c-1-i686.pkg.tar.xz%s"
72 #define ARCHLINUX_64_REF "%sgmqcc-%c.%c.%c-1-x86_64.pkg.tar.xz%s"
73 #define DEBIAN_32_REF "%sgmqcc-%c.%c.%c-i686.deb%s"
74 #define DEBIAN_64_REF "%sgmqcc-%c.%c.%c-x86_64.deb%s"
75 #define WINDOWS_32_REF "%sgmqcc-%c.%c.%c-win32.zip%s"
76 #define WINDOWS_64_REF "%sgmqcc-%c.%c.%c-win64.zip%s"
82 <meta charset=\"utf-8\">\
83 <meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\">\
85 <link rel=\"stylesheet\" href=\"stylesheets/styles.css\">\
86 <link rel=\"stylesheet\" href=\"stylesheets/pygment_trac.css\">\
87 <script src=\"javascripts/scale.fix.js\"></script>\
88 <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">\
90 <script src=\"//html5shiv.googlecode.com/svn/trunk/html5.js\"></script>\
94 <a href=\"https://github.com/graphitemaster/gmqcc\"><div class=\"fork\"></div></a>\
95 <div class=\"wrapper\">\
97 <h1 class=\"header\">GMQCC</h1>\
98 <p class=\"header\">An Improved Quake C Compiler</p>\
100 <li class=\"buttons\"><a href=index.html>Index</a></li>\
101 <li class=\"download\"><a href=\"download.html\">Download</a></li>\
102 <li class=\"buttons\"><a href=\"https://github.com/graphitemaster/gmqcc/issues\">Issues</a></li>\
103 <li class=\"buttons\"><a href=\"doc.html\">Documentation</a></li>\
104 <li class=\"buttons\"><a href=\"https://github.com/graphitemaster/gmqcc\">View On GitHub</a></li>\
110 <th>Operating System / Distribution</th>\
111 <th>x86 Architecture</th>\
112 <th>x86_64 Architecture</th>\
116 <td><a href=\"%s\">Download</a></td>\
117 <td><a href=\"%s\">Download</a></td>\
121 <td><a href=\"%s\">Download</a></td>\
122 <td><a href=\"%s\">Download</a></td>\
126 <td><a href=\"%s\">Download</a></td>\
127 <td><a href=\"%s\">Download</a></td>\
132 <script type=\"text/javascript\" src=\"http://www.ohloh.net/p/602517/widgets/project_partner_badge.js\"></script>\
135 <!--[if !IE]><script>fixScale(document);</script><![endif]-->\
140 static char build_table[][4096] = {
141 ARCHLINUX_32_REF, ARCHLINUX_64_REF,
142 DEBIAN_32_REF, DEBIAN_64_REF,
143 WINDOWS_32_REF, WINDOWS_64_REF
147 #define ISXDIGIT(c) ((c >= 48 && c <= 57) || ((c & ~0x20) >= 65 && (c & ~0x20) <= 70))
153 void escape(url_t *str) {
160 for(i=0; i < str->len; i++) {
161 if((p - str->data) >= str->len)
164 ((p - str->data)+2) < str->len &&
172 l = strtoul(hexstr, &ptr, 16);
173 str->data[i] = (char)(l & 0x7f);
185 void version(const char *directory, char *major, char *minor, char *patch) {
190 snprintf(file, sizeof(file), "%s/gmqcc.h", directory);
192 handle = fopen(file, "r");
194 fprintf(stderr, "failed to open %s for reading version (%s)\n",
195 file, strerror(errno)
200 while (getline(&data, &size, handle) != EOF) {
202 #define TEST(TYPE, STORE) \
203 if (strstr(data, "#define GMQCC_VERSION_" TYPE )) { \
205 while (!isdigit(*get)) \
221 FILE *fp = fopen("download.html", "w");
223 fprintf(stderr, "failed to generate HTML: %s\n", strerror(errno));
228 build_table[0], build_table[1],
229 build_table[2], build_table[3],
230 build_table[4], build_table[5]
236 * Builds a list of download links with the right version and handles the
239 void build(const char *directory) {
240 /* Figure out version number */
244 version(directory, &find[0], &find[1], &find[2]);
247 * decode the secuity stuff for preparing the URLs which will be used
250 memset(decode, 0, sizeof(decode));
251 security_decode(decode, SECURITY_TOKEN, strlen(SECURITY_TOKEN));
253 for (size = 0; size < sizeof(build_table) / sizeof(*build_table); size++) {
254 char *load = strdup(build_table[size]);
255 url_t esc = { NULL, 0 };
257 snprintf(build_table[size], 4096, load, BASEURL, find[0], find[1], find[2], decode);
258 esc.data = strdup(build_table[size]);
259 esc.size = strlen(build_table[size]);
262 /* Yes we also need to escape URLs just incase */
268 * Now generate the HTML file for those download links by asking tinyurl to
273 int main(int argc, char **argv) {
279 printf("usage: %s [gmqcc.h location]\n", argv[-1]);