summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c378
1 files changed, 189 insertions, 189 deletions
diff --git a/src/input.c b/src/input.c
index fa797f90..df6120c3 100644
--- a/src/input.c
+++ b/src/input.c
@@ -37,26 +37,26 @@
#define true 1
#define false 0
-RunBuf *newRunBuf()
+RunBuf *new_run_buf()
{
RunBuf *rb = (RunBuf*)malloc(sizeof(RunBuf));
memset( rb, 0, sizeof(RunBuf) );
return rb;
}
-void initFdFuncs();
-void initFileFuncs();
-void initPatFuncs();
-void initConsFuncs();
+void init_fd_funcs();
+void init_file_funcs();
+void init_pat_funcs();
+void init_cons_funcs();
-extern struct StreamFuncs fileFuncs;
-extern struct StreamFuncs fdFuncs;
-extern struct StreamFuncs streamFuncs;
+extern struct StreamFuncs file_funcs;
+extern struct StreamFuncs fd_funcs;
+extern struct StreamFuncs stream_funcs;
void colm_clear_source_stream( struct colm_program *prg,
- tree_t **sp, struct stream_impl *sourceStream )
+ tree_t **sp, struct stream_impl *source_stream )
{
- RunBuf *buf = sourceStream->queue;
+ RunBuf *buf = source_stream->queue;
while ( buf != 0 ) {
switch ( buf->type ) {
case RunBufDataType:
@@ -75,7 +75,7 @@ void colm_clear_source_stream( struct colm_program *prg,
buf = next;
}
- sourceStream->queue = 0;
+ source_stream->queue = 0;
}
void colm_stream_destroy( program_t *prg, tree_t **sp, struct_t *s )
@@ -93,7 +93,7 @@ void colm_stream_destroy( program_t *prg, tree_t **sp, struct_t *s )
/* Keep the position up to date after consuming text. */
-void updatePosition( struct stream_impl *is, const char *data, long length )
+void update_position( struct stream_impl *is, const char *data, long length )
{
int i;
for ( i = 0; i < length; i++ ) {
@@ -109,7 +109,7 @@ void updatePosition( struct stream_impl *is, const char *data, long length )
}
/* Keep the position up to date after sending back text. */
-void undoPosition( struct stream_impl *is, const char *data, long length )
+void undo_position( struct stream_impl *is, const char *data, long length )
{
/* FIXME: this needs to fetch the position information from the parsed
* token and restore based on that.. */
@@ -123,42 +123,42 @@ void undoPosition( struct stream_impl *is, const char *data, long length )
}
-static RunBuf *sourceStreamPopHead( struct stream_impl *ss )
+static RunBuf *source_stream_pop_head( struct stream_impl *ss )
{
RunBuf *ret = ss->queue;
ss->queue = ss->queue->next;
if ( ss->queue == 0 )
- ss->queueTail = 0;
+ ss->queue_tail = 0;
else
ss->queue->prev = 0;
return ret;
}
-static void sourceStreamAppend( struct stream_impl *ss, RunBuf *runBuf )
+static void source_stream_append( struct stream_impl *ss, RunBuf *run_buf )
{
if ( ss->queue == 0 ) {
- runBuf->prev = runBuf->next = 0;
- ss->queue = ss->queueTail = runBuf;
+ run_buf->prev = run_buf->next = 0;
+ ss->queue = ss->queue_tail = run_buf;
}
else {
- ss->queueTail->next = runBuf;
- runBuf->prev = ss->queueTail;
- runBuf->next = 0;
- ss->queueTail = runBuf;
+ ss->queue_tail->next = run_buf;
+ run_buf->prev = ss->queue_tail;
+ run_buf->next = 0;
+ ss->queue_tail = run_buf;
}
}
-static void sourceStreamPrepend( struct stream_impl *ss, RunBuf *runBuf )
+static void source_stream_prepend( struct stream_impl *ss, RunBuf *run_buf )
{
if ( ss->queue == 0 ) {
- runBuf->prev = runBuf->next = 0;
- ss->queue = ss->queueTail = runBuf;
+ run_buf->prev = run_buf->next = 0;
+ ss->queue = ss->queue_tail = run_buf;
}
else {
- ss->queue->prev = runBuf;
- runBuf->prev = 0;
- runBuf->next = ss->queue;
- ss->queue = runBuf;
+ ss->queue->prev = run_buf;
+ run_buf->prev = 0;
+ run_buf->next = ss->queue;
+ ss->queue = run_buf;
}
}
@@ -166,7 +166,7 @@ static void sourceStreamPrepend( struct stream_impl *ss, RunBuf *runBuf )
* Base run-time input streams.
*/
-int fdGetParseBlock( struct stream_impl *ss, int skip, char **pdp, int *copied )
+int fd_get_parse_block( struct stream_impl *ss, int skip, char **pdp, int *copied )
{
int ret = 0;
*copied = 0;
@@ -176,17 +176,17 @@ int fdGetParseBlock( struct stream_impl *ss, int skip, char **pdp, int *copied )
while ( true ) {
if ( buf == 0 ) {
/* Got through the in-mem buffers without copying anything. */
- RunBuf *runBuf = newRunBuf();
- sourceStreamAppend( ss, runBuf );
- int received = ss->funcs->getDataSource( ss, runBuf->data, FSM_BUFSIZE );
+ RunBuf *run_buf = new_run_buf();
+ source_stream_append( ss, run_buf );
+ int received = ss->funcs->get_data_source( ss, run_buf->data, FSM_BUFSIZE );
if ( received == 0 ) {
ret = INPUT_EOD;
break;
}
- runBuf->length = received;
+ run_buf->length = received;
int slen = received;
- *pdp = runBuf->data;
+ *pdp = run_buf->data;
*copied = slen;
ret = INPUT_DATA;
break;
@@ -225,7 +225,7 @@ int fdGetParseBlock( struct stream_impl *ss, int skip, char **pdp, int *copied )
return ret;
}
-int fdGetData( struct stream_impl *ss, char *dest, int length )
+int fd_get_data( struct stream_impl *ss, char *dest, int length )
{
int copied = 0;
@@ -234,14 +234,14 @@ int fdGetData( struct stream_impl *ss, char *dest, int length )
while ( true ) {
if ( buf == 0 ) {
/* Got through the in-mem buffers without copying anything. */
- RunBuf *runBuf = newRunBuf();
- sourceStreamAppend( ss, runBuf );
- int received = ss->funcs->getDataSource( ss, runBuf->data, FSM_BUFSIZE );
- runBuf->length = received;
+ RunBuf *run_buf = new_run_buf();
+ source_stream_append( ss, run_buf );
+ int received = ss->funcs->get_data_source( ss, run_buf->data, FSM_BUFSIZE );
+ run_buf->length = received;
if ( received == 0 )
break;
- buf = runBuf;
+ buf = run_buf;
}
int avail = buf->length - buf->offset;
@@ -268,7 +268,7 @@ int fdGetData( struct stream_impl *ss, char *dest, int length )
return copied;
}
-int fdConsumeData( program_t *prg, tree_t **sp, struct stream_impl *ss, int length, location_t *loc )
+int fd_consume_data( program_t *prg, tree_t **sp, struct stream_impl *ss, int length, location_t *loc )
{
int consumed = 0;
@@ -298,7 +298,7 @@ int fdConsumeData( program_t *prg, tree_t **sp, struct stream_impl *ss, int leng
int slen = avail <= length ? avail : length;
consumed += slen;
length -= slen;
- updatePosition( ss, buf->data + buf->offset, slen );
+ update_position( ss, buf->data + buf->offset, slen );
buf->offset += slen;
ss->consumed += slen;
}
@@ -307,20 +307,20 @@ int fdConsumeData( program_t *prg, tree_t **sp, struct stream_impl *ss, int leng
if ( length == 0 )
break;
- RunBuf *runBuf = sourceStreamPopHead( ss );
- free( runBuf );
+ RunBuf *run_buf = source_stream_pop_head( ss );
+ free( run_buf );
}
return consumed;
}
-int fdUndoConsumeData( struct stream_impl *ss, const char *data, int length )
+int fd_undo_consume_data( struct stream_impl *ss, const char *data, int length )
{
- RunBuf *newBuf = newRunBuf();
- newBuf->length = length;
- memcpy( newBuf->data, data, length );
- sourceStreamPrepend( ss, newBuf );
- undoPosition( ss, data, length );
+ RunBuf *new_buf = new_run_buf();
+ new_buf->length = length;
+ memcpy( new_buf->data, data, length );
+ source_stream_prepend( ss, new_buf );
+ undo_position( ss, data, length );
ss->consumed -= length;
return length;
@@ -330,23 +330,23 @@ int fdUndoConsumeData( struct stream_impl *ss, const char *data, int length )
* File
*/
-int fileGetDataSource( struct stream_impl *ss, char *dest, int length )
+int file_get_data_source( struct stream_impl *ss, char *dest, int length )
{
//debug( REALM_INPUT, "inputStreamFileGetDataSource length = %ld\n", length );
size_t res = fread( dest, 1, length, ss->file );
return res;
}
-void initFileFuncs()
+void init_file_funcs()
{
- memset( &fileFuncs, 0, sizeof(struct StreamFuncs) );
+ memset( &file_funcs, 0, sizeof(struct StreamFuncs) );
}
/*
* FD
*/
-int fdGetDataSource( struct stream_impl *ss, char *dest, int length )
+int fd_get_data_source( struct stream_impl *ss, char *dest, int length )
{
if ( ss->eof )
return 0;
@@ -362,7 +362,7 @@ int fdGetDataSource( struct stream_impl *ss, char *dest, int length )
* StreamImpl struct, this wraps the list of input streams.
*/
-void initStreamImpl( struct stream_impl *is, const char *name )
+void init_stream_impl( struct stream_impl *is, const char *name )
{
memset( is, 0, sizeof(struct stream_impl) );
@@ -372,9 +372,9 @@ void initStreamImpl( struct stream_impl *is, const char *name )
is->byte = 0;
}
-void colm_clear_stream_impl( struct colm_program *prg, tree_t **sp, struct stream_impl *inputStream )
+void colm_clear_stream_impl( struct colm_program *prg, tree_t **sp, struct stream_impl *input_stream )
{
- RunBuf *buf = inputStream->queue;
+ RunBuf *buf = input_stream->queue;
while ( buf != 0 ) {
switch ( buf->type ) {
case RunBufDataType:
@@ -394,60 +394,60 @@ void colm_clear_stream_impl( struct colm_program *prg, tree_t **sp, struct strea
buf = next;
}
- inputStream->queue = 0;
+ input_stream->queue = 0;
}
-static void inputStreamPrepend( struct stream_impl *is, RunBuf *runBuf )
+static void input_stream_prepend( struct stream_impl *is, RunBuf *run_buf )
{
if ( is->queue == 0 ) {
- runBuf->prev = runBuf->next = 0;
- is->queue = is->queueTail = runBuf;
+ run_buf->prev = run_buf->next = 0;
+ is->queue = is->queue_tail = run_buf;
}
else {
- is->queue->prev = runBuf;
- runBuf->prev = 0;
- runBuf->next = is->queue;
- is->queue = runBuf;
+ is->queue->prev = run_buf;
+ run_buf->prev = 0;
+ run_buf->next = is->queue;
+ is->queue = run_buf;
}
}
-static RunBuf *inputStreamPopHead( struct stream_impl *is )
+static RunBuf *input_stream_pop_head( struct stream_impl *is )
{
RunBuf *ret = is->queue;
is->queue = is->queue->next;
if ( is->queue == 0 )
- is->queueTail = 0;
+ is->queue_tail = 0;
else
is->queue->prev = 0;
return ret;
}
-static void inputStreamAppend( struct stream_impl *is, RunBuf *runBuf )
+static void input_stream_append( struct stream_impl *is, RunBuf *run_buf )
{
if ( is->queue == 0 ) {
- runBuf->prev = runBuf->next = 0;
- is->queue = is->queueTail = runBuf;
+ run_buf->prev = run_buf->next = 0;
+ is->queue = is->queue_tail = run_buf;
}
else {
- is->queueTail->next = runBuf;
- runBuf->prev = is->queueTail;
- runBuf->next = 0;
- is->queueTail = runBuf;
+ is->queue_tail->next = run_buf;
+ run_buf->prev = is->queue_tail;
+ run_buf->next = 0;
+ is->queue_tail = run_buf;
}
}
-static RunBuf *inputStreamPopTail( struct stream_impl *is )
+static RunBuf *input_stream_pop_tail( struct stream_impl *is )
{
- RunBuf *ret = is->queueTail;
- is->queueTail = is->queueTail->prev;
- if ( is->queueTail == 0 )
+ RunBuf *ret = is->queue_tail;
+ is->queue_tail = is->queue_tail->prev;
+ if ( is->queue_tail == 0 )
is->queue = 0;
else
- is->queueTail->next = 0;
+ is->queue_tail->next = 0;
return ret;
}
-static int isSourceStream( struct stream_impl *is )
+static int is_source_stream( struct stream_impl *is )
{
if ( is->queue != 0 && is->queue->type == RunBufSourceType )
return true;
@@ -462,8 +462,8 @@ static void _setEof( struct stream_impl *is )
static void _unsetEof( struct stream_impl *is )
{
- if ( isSourceStream( is ) ) {
- struct stream_impl *si = streamToImpl( (stream_t*)is->queue->tree );
+ if ( is_source_stream( is ) ) {
+ struct stream_impl *si = stream_to_impl( (stream_t*)is->queue->tree );
si->eof = false;
}
else {
@@ -486,8 +486,8 @@ static int _getParseBlock( struct stream_impl *is, int skip, char **pdp, int *co
}
if ( buf->type == RunBufSourceType ) {
- struct stream_impl *si = streamToImpl( (stream_t*)buf->tree );
- int type = si->funcs->getParseBlock( si, skip, pdp, copied );
+ struct stream_impl *si = stream_to_impl( (stream_t*)buf->tree );
+ int type = si->funcs->get_parse_block( si, skip, pdp, copied );
// if ( type == INPUT_EOD && !si->eosSent ) {
// si->eosSent = 1;
@@ -583,8 +583,8 @@ static int _getData( struct stream_impl *is, char *dest, int length )
}
if ( buf->type == RunBufSourceType ) {
- struct stream_impl *si = streamToImpl( (stream_t*)buf->tree );
- int glen = si->funcs->getData( si, dest+copied, length );
+ struct stream_impl *si = stream_to_impl( (stream_t*)buf->tree );
+ int glen = si->funcs->get_data( si, dest+copied, length );
if ( glen == 0 ) {
//debug( REALM_INPUT, "skipping over input\n" );
@@ -641,8 +641,8 @@ static int _consumeData( program_t *prg, tree_t **sp, struct stream_impl *is,
break;
if ( buf->type == RunBufSourceType ) {
- struct stream_impl *si = streamToImpl( (stream_t*)buf->tree );
- int slen = si->funcs->consumeData( prg, sp, si, length, loc );
+ struct stream_impl *si = stream_to_impl( (stream_t*)buf->tree );
+ int slen = si->funcs->consume_data( prg, sp, si, length, loc );
//debug( REALM_INPUT, " got %d bytes from source\n", slen );
consumed += slen;
@@ -670,12 +670,12 @@ static int _consumeData( program_t *prg, tree_t **sp, struct stream_impl *is,
break;
}
- RunBuf *runBuf = inputStreamPopHead( is );
+ RunBuf *run_buf = input_stream_pop_head( is );
//if ( runBuf->type == RunBufSourceType ) {
// stream_t *stream = (stream_t*)runBuf->tree;
// colm_tree_downref( prg, sp, (tree_t*) stream );
//}
- free( runBuf );
+ free( run_buf );
}
return consumed;
@@ -685,16 +685,16 @@ static int _undoConsumeData( struct stream_impl *is, const char *data, int lengt
{
//debug( REALM_INPUT, "undoing consume of %ld bytes\n", length );
- if ( is->consumed == 0 && isSourceStream( is ) ) {
- struct stream_impl *si = streamToImpl( (stream_t*)is->queue->tree );
- int len = si->funcs->undoConsumeData( si, data, length );
+ if ( is->consumed == 0 && is_source_stream( is ) ) {
+ struct stream_impl *si = stream_to_impl( (stream_t*)is->queue->tree );
+ int len = si->funcs->undo_consume_data( si, data, length );
return len;
}
else {
- RunBuf *newBuf = newRunBuf();
- newBuf->length = length;
- memcpy( newBuf->data, data, length );
- inputStreamPrepend( is, newBuf );
+ RunBuf *new_buf = new_run_buf();
+ new_buf->length = length;
+ memcpy( new_buf->data, data, length );
+ input_stream_prepend( is, new_buf );
is->consumed -= length;
return length;
@@ -706,18 +706,18 @@ static tree_t *_consumeTree( struct stream_impl *is )
while ( is->queue != 0 && is->queue->type == RunBufDataType &&
is->queue->offset == is->queue->length )
{
- RunBuf *runBuf = inputStreamPopHead( is );
- free( runBuf );
+ RunBuf *run_buf = input_stream_pop_head( is );
+ free( run_buf );
}
if ( is->queue != 0 && (is->queue->type == RunBufTokenType ||
is->queue->type == RunBufIgnoreType) )
{
- RunBuf *runBuf = inputStreamPopHead( is );
+ RunBuf *run_buf = input_stream_pop_head( is );
/* FIXME: using runbufs here for this is a poor use of memory. */
- tree_t *tree = runBuf->tree;
- free(runBuf);
+ tree_t *tree = run_buf->tree;
+ free(run_buf);
return tree;
}
@@ -729,18 +729,18 @@ static void _undoConsumeTree( struct stream_impl *is, tree_t *tree, int ignore )
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
* data that can be pushed back to the inputStream. */
- RunBuf *newBuf = newRunBuf();
- newBuf->type = ignore ? RunBufIgnoreType : RunBufTokenType;
- newBuf->tree = tree;
- inputStreamPrepend( is, newBuf );
+ RunBuf *new_buf = new_run_buf();
+ new_buf->type = ignore ? RunBufIgnoreType : RunBufTokenType;
+ new_buf->tree = tree;
+ input_stream_prepend( is, new_buf );
}
-static struct LangEl *_consumeLangEl( struct stream_impl *is, long *bindId,
+static struct LangEl *_consumeLangEl( struct stream_impl *is, long *bind_id,
char **data, long *length )
{
- if ( isSourceStream( is ) ) {
- struct stream_impl *si = streamToImpl( (stream_t*)is->queue->tree );
- return si->funcs->consumeLangEl( si, bindId, data, length );
+ if ( is_source_stream( is ) ) {
+ struct stream_impl *si = stream_to_impl( (stream_t*)is->queue->tree );
+ return si->funcs->consume_lang_el( si, bind_id, data, length );
}
else {
assert( false );
@@ -749,9 +749,9 @@ static struct LangEl *_consumeLangEl( struct stream_impl *is, long *bindId,
static void _undoConsumeLangEl( struct stream_impl *is )
{
- if ( isSourceStream( is ) ) {
- struct stream_impl *si = streamToImpl( (stream_t*)is->queue->tree );
- return si->funcs->undoConsumeLangEl( si );
+ if ( is_source_stream( is ) ) {
+ struct stream_impl *si = stream_to_impl( (stream_t*)is->queue->tree );
+ return si->funcs->undo_consume_lang_el( si );
}
else {
assert( false );
@@ -760,10 +760,10 @@ static void _undoConsumeLangEl( struct stream_impl *is )
static void _prependData( struct stream_impl *is, const char *data, long length )
{
- if ( isSourceStream( is ) &&
- streamToImpl((stream_t*)is->queue->tree)->funcs == &streamFuncs )
+ if ( is_source_stream( is ) &&
+ stream_to_impl((stream_t*)is->queue->tree)->funcs == &stream_funcs )
{
- _prependData( streamToImpl( (stream_t*)is->queue->tree ), data, length );
+ _prependData( stream_to_impl( (stream_t*)is->queue->tree ), data, length );
}
else {
/* Create a new buffer for the data. This is the easy implementation.
@@ -771,11 +771,11 @@ static void _prependData( struct stream_impl *is, const char *data, long length
* data that can be pushed back to the inputStream. */
assert( length < FSM_BUFSIZE );
- RunBuf *newBuf = newRunBuf();
- newBuf->length = length;
- memcpy( newBuf->data, data, length );
+ RunBuf *new_buf = new_run_buf();
+ new_buf->length = length;
+ memcpy( new_buf->data, data, length );
- inputStreamPrepend( is, newBuf );
+ input_stream_prepend( is, new_buf );
}
}
@@ -784,10 +784,10 @@ static void _prependTree( struct stream_impl *is, tree_t *tree, int ignore )
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
* data that can be pushed back to the inputStream. */
- RunBuf *newBuf = newRunBuf();
- newBuf->type = ignore ? RunBufIgnoreType : RunBufTokenType;
- newBuf->tree = tree;
- inputStreamPrepend( is, newBuf );
+ RunBuf *new_buf = new_run_buf();
+ new_buf->type = ignore ? RunBufIgnoreType : RunBufTokenType;
+ new_buf->tree = tree;
+ input_stream_prepend( is, new_buf );
}
static void _prependStream( struct stream_impl *in, struct colm_tree *tree )
@@ -795,10 +795,10 @@ static void _prependStream( struct stream_impl *in, struct colm_tree *tree )
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
* data that can be pushed back to the inputStream. */
- RunBuf *newBuf = newRunBuf();
- newBuf->type = RunBufSourceType;
- newBuf->tree = tree;
- inputStreamPrepend( in, newBuf );
+ RunBuf *new_buf = new_run_buf();
+ new_buf->type = RunBufSourceType;
+ new_buf->tree = tree;
+ input_stream_prepend( in, new_buf );
}
static int _undoPrependData( struct stream_impl *is, int length )
@@ -815,8 +815,8 @@ static int _undoPrependData( struct stream_impl *is, int length )
break;
if ( buf->type == RunBufSourceType ) {
- struct stream_impl *si = streamToImpl( (stream_t*)buf->tree );
- int slen = si->funcs->undoPrependData( si, length );
+ struct stream_impl *si = stream_to_impl( (stream_t*)buf->tree );
+ int slen = si->funcs->undo_prepend_data( si, length );
consumed += slen;
length -= slen;
@@ -840,8 +840,8 @@ static int _undoPrependData( struct stream_impl *is, int length )
if ( length == 0 )
break;
- RunBuf *runBuf = inputStreamPopHead( is );
- free( runBuf );
+ RunBuf *run_buf = input_stream_pop_head( is );
+ free( run_buf );
}
return consumed;
@@ -852,18 +852,18 @@ static tree_t *_undoPrependTree( struct stream_impl *is )
while ( is->queue != 0 && is->queue->type == RunBufDataType &&
is->queue->offset == is->queue->length )
{
- RunBuf *runBuf = inputStreamPopHead( is );
- free( runBuf );
+ RunBuf *run_buf = input_stream_pop_head( is );
+ free( run_buf );
}
if ( is->queue != 0 && (is->queue->type == RunBufTokenType ||
is->queue->type == RunBufIgnoreType) )
{
- RunBuf *runBuf = inputStreamPopHead( is );
+ RunBuf *run_buf = input_stream_pop_head( is );
/* FIXME: using runbufs here for this is a poor use of memory. */
- tree_t *tree = runBuf->tree;
- free(runBuf);
+ tree_t *tree = run_buf->tree;
+ free(run_buf);
return tree;
}
@@ -873,8 +873,8 @@ static tree_t *_undoPrependTree( struct stream_impl *is )
static void _appendData( struct stream_impl *is, const char *data, long len )
{
while ( len > 0 ) {
- RunBuf *ad = newRunBuf();
- inputStreamAppend( is, ad );
+ RunBuf *ad = new_run_buf();
+ input_stream_append( is, ad );
long consume =
len <= (long)sizeof(ad->data) ?
@@ -894,7 +894,7 @@ static tree_t *_undoAppendData( struct stream_impl *is, int length )
/* Move over skip bytes. */
while ( true ) {
- RunBuf *buf = is->queueTail;
+ RunBuf *buf = is->queue_tail;
if ( buf == 0 )
break;
@@ -918,8 +918,8 @@ static tree_t *_undoAppendData( struct stream_impl *is, int length )
if ( length == 0 )
break;
- RunBuf *runBuf = inputStreamPopTail( is );
- free( runBuf );
+ RunBuf *run_buf = input_stream_pop_tail( is );
+ free( run_buf );
}
return 0;
@@ -927,9 +927,9 @@ static tree_t *_undoAppendData( struct stream_impl *is, int length )
static void _appendTree( struct stream_impl *is, tree_t *tree )
{
- RunBuf *ad = newRunBuf();
+ RunBuf *ad = new_run_buf();
- inputStreamAppend( is, ad );
+ input_stream_append( is, ad );
ad->type = RunBufTokenType;
ad->tree = tree;
@@ -938,9 +938,9 @@ static void _appendTree( struct stream_impl *is, tree_t *tree )
static void _appendStream( struct stream_impl *in, struct colm_tree *tree )
{
- RunBuf *ad = newRunBuf();
+ RunBuf *ad = new_run_buf();
- inputStreamAppend( in, ad );
+ input_stream_append( in, ad );
ad->type = RunBufSourceType;
ad->tree = tree;
@@ -949,21 +949,21 @@ static void _appendStream( struct stream_impl *in, struct colm_tree *tree )
static tree_t *_undoAppendTree( struct stream_impl *is )
{
- RunBuf *runBuf = inputStreamPopTail( is );
- tree_t *tree = runBuf->tree;
- free( runBuf );
+ RunBuf *run_buf = input_stream_pop_tail( is );
+ tree_t *tree = run_buf->tree;
+ free( run_buf );
return tree;
}
static tree_t *_undoAppendStream( struct stream_impl *is )
{
- RunBuf *runBuf = inputStreamPopTail( is );
- tree_t *tree = runBuf->tree;
- free( runBuf );
+ RunBuf *run_buf = input_stream_pop_tail( is );
+ tree_t *tree = run_buf->tree;
+ free( run_buf );
return tree;
}
-struct StreamFuncs streamFuncs =
+struct StreamFuncs stream_funcs =
{
&_getParseBlock,
&_getData,
@@ -990,30 +990,30 @@ struct StreamFuncs streamFuncs =
&_undoAppendStream,
};
-struct StreamFuncs fdFuncs =
+struct StreamFuncs fd_funcs =
{
- .getData = &fdGetData,
- .getParseBlock = &fdGetParseBlock,
- .consumeData = &fdConsumeData,
- .undoConsumeData = &fdUndoConsumeData,
- .getDataSource = &fdGetDataSource,
+ .get_data = &fd_get_data,
+ .get_parse_block = &fd_get_parse_block,
+ .consume_data = &fd_consume_data,
+ .undo_consume_data = &fd_undo_consume_data,
+ .get_data_source = &fd_get_data_source,
};
-struct StreamFuncs fileFuncs =
+struct StreamFuncs file_funcs =
{
- .getData = &fdGetData,
- .getParseBlock = &fdGetParseBlock,
- .consumeData = &fdConsumeData,
- .undoConsumeData = &fdUndoConsumeData,
- .getDataSource = &fileGetDataSource,
+ .get_data = &fd_get_data,
+ .get_parse_block = &fd_get_parse_block,
+ .consume_data = &fd_consume_data,
+ .undo_consume_data = &fd_undo_consume_data,
+ .get_data_source = &file_get_data_source,
};
struct stream_impl *colm_impl_new_file( const char *name, FILE *file )
{
struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
- initStreamImpl( ss, name );
- ss->funcs = &fileFuncs;
+ init_stream_impl( ss, name );
+ ss->funcs = &file_funcs;
ss->file = file;
@@ -1023,8 +1023,8 @@ struct stream_impl *colm_impl_new_file( const char *name, FILE *file )
struct stream_impl *colm_impl_new_fd( const char *name, long fd )
{
struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
- initStreamImpl( ss, name );
- ss->funcs = &fdFuncs;
+ init_stream_impl( ss, name );
+ ss->funcs = &fd_funcs;
ss->fd = fd;
@@ -1034,8 +1034,8 @@ struct stream_impl *colm_impl_new_fd( const char *name, long fd )
struct stream_impl *colm_impl_new_generic( const char *name )
{
struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
- initStreamImpl( ss, name );
- ss->funcs = &streamFuncs;
+ init_stream_impl( ss, name );
+ ss->funcs = &stream_funcs;
return ss;
}
@@ -1062,30 +1062,30 @@ stream_t *colm_stream_open_fd( program_t *prg, char *name, long fd )
stream_t *colm_stream_open_file( program_t *prg, tree_t *name, tree_t *mode )
{
- head_t *headName = ((str_t*)name)->value;
- head_t *headMode = ((str_t*)mode)->value;
+ head_t *head_name = ((str_t*)name)->value;
+ head_t *head_mode = ((str_t*)mode)->value;
stream_t *stream = 0;
- const char *givenMode = stringData(headMode);
- const char *fopenMode = 0;
- if ( memcmp( givenMode, "r", stringLength(headMode) ) == 0 )
- fopenMode = "rb";
- else if ( memcmp( givenMode, "w", stringLength(headMode) ) == 0 )
- fopenMode = "wb";
- else if ( memcmp( givenMode, "a", stringLength(headMode) ) == 0 )
- fopenMode = "ab";
+ const char *given_mode = string_data(head_mode);
+ const char *fopen_mode = 0;
+ if ( memcmp( given_mode, "r", string_length(head_mode) ) == 0 )
+ fopen_mode = "rb";
+ else if ( memcmp( given_mode, "w", string_length(head_mode) ) == 0 )
+ fopen_mode = "wb";
+ else if ( memcmp( given_mode, "a", string_length(head_mode) ) == 0 )
+ fopen_mode = "ab";
else {
- fatal( "unknown file open mode: %s\n", givenMode );
+ fatal( "unknown file open mode: %s\n", given_mode );
}
/* Need to make a C-string (null terminated). */
- char *fileName = (char*)malloc(stringLength(headName)+1);
- memcpy( fileName, stringData(headName), stringLength(headName) );
- fileName[stringLength(headName)] = 0;
- FILE *file = fopen( fileName, fopenMode );
+ char *file_name = (char*)malloc(string_length(head_name)+1);
+ memcpy( file_name, string_data(head_name), string_length(head_name) );
+ file_name[string_length(head_name)] = 0;
+ FILE *file = fopen( file_name, fopen_mode );
if ( file != 0 ) {
stream = colm_stream_new_struct( prg );
- stream->impl = colm_impl_new_file( fileName, file );
+ stream->impl = colm_impl_new_file( file_name, file );
}
return stream;
@@ -1105,7 +1105,7 @@ struct stream_impl *colm_stream_impl( struct colm_struct *s )
return ((stream_t*)s)->impl;
}
-struct stream_impl *streamToImpl( stream_t *ptr )
+struct stream_impl *stream_to_impl( stream_t *ptr )
{
return ptr->impl;
}