Use stylesheet transformations to output HTML, for example

This commit is contained in:
David Baer
2015-08-11 15:33:08 -04:00
parent cfc0ba7e9a
commit 10927bee25
19 changed files with 725 additions and 92 deletions

View File

@@ -30,6 +30,7 @@
*/
#ifndef _QUEUE_H
#define _QUEUE_H
#include <stdio.h>
#include <stdlib.h>
#define DEFINE_QUEUE(T, N) \
@@ -45,6 +46,13 @@ typedef struct { \
#define NEW_QUEUE(T, N) \
T N = (T) { .length = 0, .head = NULL, .tail = NULL }
/* WARNING: this is probably not what you want -- see DESTROY_QUEUE below */
#define REINIT_QUEUE(N) { \
(N).length = 0; \
(N).head = NULL; \
(N).tail = NULL; \
}
#define APPEND_QUEUE(T, Q, E) { \
struct _##T##Node* n = (struct _##T##Node*)malloc(sizeof(struct _##T##Node)); \
if (!n) { perror ("Could not allocate space for new queue element."); exit(1); } \
@@ -56,7 +64,7 @@ typedef struct { \
(Q).length++; \
}
#define QUEUE_LENGTH(Q) Q.length
#define QUEUE_LENGTH(Q) (Q).length
#define FOREACH_QUEUE(T, Q, N) { \
struct _##T##Node* N = NULL; \
@@ -89,10 +97,10 @@ typedef struct { \
#define QUEUE_TO_ARRAY(QT, Q, T, DST) { \
int i = 0; \
DST = (T*)calloc(Q.length,sizeof(T)); \
if (!DST) { perror("Could not allocate space for array."); exit(1); } \
(DST) = (T*)calloc((Q).length,sizeof(T)); \
if (!(DST)) { perror("Could not allocate space for array."); exit(1); } \
FOREACH_QUEUE(QT, Q, ptr) \
DST[i++] = ptr->data; \
(DST)[i++] = ptr->data; \
FOREACH_QUEUE_END; \
}