Better docs and code commenting
This commit is contained in:
parent
ae253cec83
commit
6e89d6e263
2 changed files with 13 additions and 9 deletions
|
@ -624,6 +624,8 @@ int parseGemtext(gemtextParser *parser, gemtextNodeQueue *nq) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// If we were unable to read a char, assume we're at the end of the
|
||||||
|
// stream and send the node to the queue
|
||||||
if (parser->state != lineStart && parser->state != trimStart) {
|
if (parser->state != lineStart && parser->state != trimStart) {
|
||||||
switch (parser->nodeType) {
|
switch (parser->nodeType) {
|
||||||
case preformattedNode:
|
case preformattedNode:
|
||||||
|
@ -638,6 +640,7 @@ int parseGemtext(gemtextParser *parser, gemtextNodeQueue *nq) {
|
||||||
}
|
}
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
|
// Send an `endOfStream` node since we know we're done
|
||||||
node = calloc(1, sizeof(gemtextNode));
|
node = calloc(1, sizeof(gemtextNode));
|
||||||
if (node == NULL) return errno;
|
if (node == NULL) return errno;
|
||||||
node->nodeType = endOfStream;
|
node->nodeType = endOfStream;
|
||||||
|
|
|
@ -89,6 +89,7 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} gemtextParser;
|
} gemtextParser;
|
||||||
|
|
||||||
|
/** A Gemtext node */
|
||||||
struct _gemtextNode {
|
struct _gemtextNode {
|
||||||
struct _gemtextNode *next; ///< The next line in the queue
|
struct _gemtextNode *next; ///< The next line in the queue
|
||||||
struct _gemtextNode *prev; ///< The previous line in the queue
|
struct _gemtextNode *prev; ///< The previous line in the queue
|
||||||
|
@ -163,30 +164,30 @@ void gemtextParserDestroy(gemtextParser *parser);
|
||||||
int gemtextNodeQueueInit(gemtextNodeQueue *nq);
|
int gemtextNodeQueueInit(gemtextNodeQueue *nq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes a gemtextLine into the queue. This function will not fail, but
|
* Pushes a gemtextNode into the queue. This function will not fail, but
|
||||||
* can block if another thread holds the gemtextQueue's internal mutex.
|
* can block if another thread holds the gemtextQueue's internal mutex.
|
||||||
* \param nq The queue which will receive the gemtext line
|
* \param nq The queue which will receive the gemtext node
|
||||||
* \param node The gemtextNode to be queued
|
* \param node The gemtextNode to be queued
|
||||||
*/
|
*/
|
||||||
void gemtextNodeQueuePush(gemtextNodeQueue *nq, gemtextNode *node);
|
void gemtextNodeQueuePush(gemtextNodeQueue *nq, gemtextNode *node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the oldest line inserted in the queue. This function will either
|
* Gets the oldest node inserted in the queue. This function will either
|
||||||
* return a valid gemtextLine or block until one becomes available.
|
* return a valid gemtextNode or block until one becomes available.
|
||||||
* \param nq The queue from which we are attempting to pop a line
|
* \param nq The queue from which we are attempting to pop a node
|
||||||
*/
|
*/
|
||||||
gemtextNode* gemtextNodeQueuePop(gemtextNodeQueue *nq);
|
gemtextNode* gemtextNodeQueuePop(gemtextNodeQueue *nq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to get the oldest line inserted in the queue. If there are no lines
|
* Attempts to get the oldest node inserted in the queue. If there are no nodes
|
||||||
* left in the queue, returns NULL.
|
* left in the queue, returns NULL.
|
||||||
* \param nq The queue from which we are attempting to pop a line
|
* \param nq The queue from which we are attempting to pop a node
|
||||||
*/
|
*/
|
||||||
gemtextNode* gemtextNodeQueueTryPop(gemtextNodeQueue *nq);
|
gemtextNode* gemtextNodeQueueTryPop(gemtextNodeQueue *nq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees all memory associated with a gemtextLine structure
|
* Frees all memory associated with a gemtextNode structure
|
||||||
* \param lq The gemtextLine to be de-allocated
|
* \param node The gemtextNode to be de-allocated
|
||||||
*/
|
*/
|
||||||
void gemtextNodeDeinit(gemtextNode *node);
|
void gemtextNodeDeinit(gemtextNode *node);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue