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"
77 #define SLACKWARE_32_REF "%sgmqcc-%c.%c.%c-i686.txz%s"
78 #define SLACKWARE_64_REF "%sgmqcc-%c.%c.%c-x86_64.txz%s"
85 <meta charset=\"utf-8\">\
86 <meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\">\
88 <link rel=\"stylesheet\" href=\"stylesheets/styles.css\">\
89 <link rel=\"stylesheet\" href=\"stylesheets/pygment_trac.css\">\
90 <script src=\"javascripts/scale.fix.js\"></script>\
91 <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">\
93 <script src=\"//html5shiv.googlecode.com/svn/trunk/html5.js\"></script>\
97 <a href=\"https://github.com/graphitemaster/gmqcc\"><div class=\"fork\"></div></a>\
98 <div class=\"wrapper\">\
100 <h1 class=\"header\">GMQCC</h1>\
101 <p class=\"header\">An Improved Quake C Compiler</p>\
103 <li class=\"buttons\"><a href=index.html>Index</a></li>\
104 <li class=\"download\"><a href=\"download.html\">Download</a></li>\
105 <li class=\"buttons\"><a href=\"https://github.com/graphitemaster/gmqcc/issues\">Issues</a></li>\
106 <li class=\"buttons\"><a href=\"doc.html\">Documentation</a></li>\
107 <li class=\"buttons\"><a href=\"https://github.com/graphitemaster/gmqcc\">View On GitHub</a></li>\
113 <th>Operating System / Distribution</th>\
114 <th>x86 Architecture</th>\
115 <th>x86_64 Architecture</th>\
119 <td><a href=\"%s\">Download</a></td>\
120 <td><a href=\"%s\">Download</a></td>\
124 <td><a href=\"%s\">Download</a></td>\
125 <td><a href=\"%s\">Download</a></td>\
129 <td><a href=\"%s\">Download</a></td>\
130 <td><a href=\"%s\">Download</a></td>\
133 <td><a href=\"%s\">Download</a></td>\
134 <td><a href=\"%s\">Download</a></td>\
139 <script type=\"text/javascript\" src=\"http://www.ohloh.net/p/602517/widgets/project_partner_badge.js\"></script>\
142 <!--[if !IE]><script>fixScale(document);</script><![endif]-->\
147 static char build_table[][4096] = {
148 ARCHLINUX_32_REF, ARCHLINUX_64_REF,
149 DEBIAN_32_REF, DEBIAN_64_REF,
150 SLACKWARE_32_REF, SLACKWARE_64_REF,
151 WINDOWS_32_REF, WINDOWS_64_REF
155 #define ISXDIGIT(c) ((c >= 48 && c <= 57) || ((c & ~0x20) >= 65 && (c & ~0x20) <= 70))
161 void escape(url_t *str) {
168 for(i=0; i < str->len; i++) {
169 if((p - str->data) >= str->len)
172 ((p - str->data)+2) < str->len &&
180 l = strtoul(hexstr, &ptr, 16);
181 str->data[i] = (char)(l & 0x7f);
193 void version(const char *directory, char *major, char *minor, char *patch) {
198 snprintf(file, sizeof(file), "%s/gmqcc.h", directory);
200 handle = fopen(file, "r");
202 fprintf(stderr, "failed to open %s for reading version (%s)\n",
203 file, strerror(errno)
208 while (getline(&data, &size, handle) != EOF) {
210 #define TEST(TYPE, STORE) \
211 if (strstr(data, "#define GMQCC_VERSION_" TYPE )) { \
213 while (!isdigit(*get)) \
229 FILE *fp = fopen("download.html", "w");
231 fprintf(stderr, "failed to generate HTML: %s\n", strerror(errno));
236 build_table[0], build_table[1],
237 build_table[2], build_table[3],
238 build_table[4], build_table[5],
239 build_table[6], build_table[7]
245 * Builds a list of download links with the right version and handles the
248 void build(const char *directory) {
249 /* Figure out version number */
253 version(directory, &find[0], &find[1], &find[2]);
256 * decode the secuity stuff for preparing the URLs which will be used
259 memset(decode, 0, sizeof(decode));
260 security_decode(decode, SECURITY_TOKEN, strlen(SECURITY_TOKEN));
262 for (size = 0; size < sizeof(build_table) / sizeof(*build_table); size++) {
263 char *load = strdup(build_table[size]);
264 url_t esc = { NULL, 0 };
266 snprintf(build_table[size], 4096, load, BASEURL, find[0], find[1], find[2], decode);
267 esc.data = strdup(build_table[size]);
268 esc.size = strlen(build_table[size]);
271 /* Yes we also need to escape URLs just incase */
277 * Now generate the HTML file for those download links by asking tinyurl to
282 int main(int argc, char **argv) {
288 printf("usage: %s [gmqcc.h location]\n", argv[-1]);