Browse Source

indent -linux on tinyrl library

git-svn-id: https://klish.googlecode.com/svn/trunk@339 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 14 years ago
parent
commit
7944a585dd
10 changed files with 1384 additions and 1711 deletions
  1. 42 60
      tinyrl/history.h
  2. 285 334
      tinyrl/history/history.c
  3. 29 32
      tinyrl/history/history_entry.c
  4. 3 5
      tinyrl/history/private.h
  5. 31 32
      tinyrl/private.h
  6. 669 739
      tinyrl/tinyrl.c
  7. 80 140
      tinyrl/tinyrl.h
  8. 49 149
      tinyrl/vt100.h
  9. 3 5
      tinyrl/vt100/private.h
  10. 193 215
      tinyrl/vt100/vt100.c

+ 42 - 60
tinyrl/history.h

@@ -13,16 +13,15 @@
 #include "lub/types.h"
 #include "lub/types.h"
 
 
 _BEGIN_C_DECL
 _BEGIN_C_DECL
-
 /**************************************
 /**************************************
  * tinyrl_history_entry class interface
  * tinyrl_history_entry class interface
  ************************************** */
  ************************************** */
 typedef struct _tinyrl_history_entry tinyrl_history_entry_t;
 typedef struct _tinyrl_history_entry tinyrl_history_entry_t;
 
 
-extern const char *
+extern const char *tinyrl_history_entry__get_line(const tinyrl_history_entry_t *
-    tinyrl_history_entry__get_line(const tinyrl_history_entry_t *instance);
+						  instance);
-extern unsigned
+extern unsigned tinyrl_history_entry__get_index(const tinyrl_history_entry_t *
-    tinyrl_history_entry__get_index(const tinyrl_history_entry_t *instance);
+						instance);
 
 
 /**************************************
 /**************************************
  * tinyrl_history class interface
  * tinyrl_history class interface
@@ -36,79 +35,62 @@ typedef struct _tinyrl_history_iterator tinyrl_history_iterator_t;
 /**
 /**
  * CLIENTS MUST NOT USE THESE FIELDS DIRECTLY
  * CLIENTS MUST NOT USE THESE FIELDS DIRECTLY
  */
  */
-struct _tinyrl_history_iterator
+struct _tinyrl_history_iterator {
-{
+	const tinyrl_history_t *history;
-    const tinyrl_history_t *history;
+	unsigned offset;
-    unsigned                offset;
 };
 };
 
 
+extern tinyrl_history_t *tinyrl_history_new(unsigned stifle);
 
 
-extern tinyrl_history_t *
+extern void tinyrl_history_delete(tinyrl_history_t * instance);
-    tinyrl_history_new(unsigned stifle);
-
-extern void
-    tinyrl_history_delete(tinyrl_history_t *instance);
-
-extern void
-    tinyrl_history_add      (tinyrl_history_t *instance, 
-                             const char       *line);
 
 
-extern tinyrl_history_entry_t *
+extern void tinyrl_history_add(tinyrl_history_t * instance, const char *line);
-    tinyrl_history_getfirst (const tinyrl_history_t    *instance,
-                             tinyrl_history_iterator_t *iter);
-extern tinyrl_history_entry_t *
-    tinyrl_history_getlast (const tinyrl_history_t    *instance,
-                             tinyrl_history_iterator_t *iter);
 
 
-extern tinyrl_history_entry_t *
+extern tinyrl_history_entry_t *tinyrl_history_getfirst(const tinyrl_history_t *
-    tinyrl_history_getnext(tinyrl_history_iterator_t *iter);
+						       instance,
+						       tinyrl_history_iterator_t
+						       * iter);
+extern tinyrl_history_entry_t *tinyrl_history_getlast(const tinyrl_history_t *
+						      instance,
+						      tinyrl_history_iterator_t
+						      * iter);
 
 
-extern tinyrl_history_entry_t *
+extern tinyrl_history_entry_t *tinyrl_history_getnext(tinyrl_history_iterator_t
-    tinyrl_history_getprevious(tinyrl_history_iterator_t *iter);
+						      * iter);
- 
 
 
- 
+extern tinyrl_history_entry_t
+    *tinyrl_history_getprevious(tinyrl_history_iterator_t * iter);
 
 
 /*
 /*
 HISTORY LIST MANAGEMENT 
 HISTORY LIST MANAGEMENT 
 */
 */
-extern tinyrl_history_entry_t *
+extern tinyrl_history_entry_t *tinyrl_history_remove(tinyrl_history_t *
-    tinyrl_history_remove(tinyrl_history_t *instance,
+						     instance, unsigned offset);
-                          unsigned          offset);
+extern void tinyrl_history_clear(tinyrl_history_t * instance);
-extern void
+extern void tinyrl_history_stifle(tinyrl_history_t * instance, unsigned stifle);
-    tinyrl_history_clear(tinyrl_history_t *instance);
+extern unsigned tinyrl_history_unstifle(tinyrl_history_t * instance);
-extern void
+extern bool_t tinyrl_history_is_stifled(const tinyrl_history_t * instance);
-    tinyrl_history_stifle(tinyrl_history_t *instance,
-                          unsigned          stifle);
-extern unsigned
-    tinyrl_history_unstifle(tinyrl_history_t *instance);
-extern bool_t
-    tinyrl_history_is_stifled(const tinyrl_history_t *instance);
 
 
     /*
     /*
-INFORMATION ABOUT THE HISTORY LIST 
+       INFORMATION ABOUT THE HISTORY LIST 
-*/    
+     */
-extern tinyrl_history_entry_t **
+extern tinyrl_history_entry_t **tinyrl_history_list(const tinyrl_history_t *
-    tinyrl_history_list(const tinyrl_history_t *instance);
+						    instance);
-extern tinyrl_history_entry_t *
+extern tinyrl_history_entry_t *tinyrl_history_get(const tinyrl_history_t *
-    tinyrl_history_get(const tinyrl_history_t *instance,
+						  instance, unsigned offset);
-                       unsigned                offset);
 
 
 /*
 /*
  * HISTORY EXPANSION 
  * HISTORY EXPANSION 
- */  
+ */
-typedef enum
+typedef enum {
-{
+	tinyrl_history_NO_EXPANSION,
-    tinyrl_history_NO_EXPANSION,
+	tinyrl_history_EXPANDED
-    tinyrl_history_EXPANDED
+} tinyrl_history_expand_t;
-} tinyrl_history_expand_t;  
 
 
 extern tinyrl_history_expand_t
 extern tinyrl_history_expand_t
-    tinyrl_history_expand(const tinyrl_history_t *instance,
+tinyrl_history_expand(const tinyrl_history_t * instance,
-                          const char             *string, 
+		      const char *string, char **output);
-                          char                  **output);
 
 
 _END_C_DECL
 _END_C_DECL
-
+#endif				/* _tinyrl_history_h */
-#endif /* _tinyrl_history_h */
 /** @} tinyrl_history */
 /** @} tinyrl_history */

+ 285 - 334
tinyrl/history/history.c

@@ -13,61 +13,55 @@
 
 
 #include "tinyrl/history.h"
 #include "tinyrl/history.h"
 
 
-struct _tinyrl_history
+struct _tinyrl_history {
-{
+	tinyrl_history_entry_t **entries;	/* pointer entries */
-    tinyrl_history_entry_t **entries;   /* pointer entries */
+	unsigned length;	/* Number of elements within this array */
-    unsigned     length;    /* Number of elements within this array */
+	unsigned size;		/* Number of slots allocated in this array */
-    unsigned     size;      /* Number of slots allocated in this array */
+	unsigned current_index;
-    unsigned     current_index;
+	unsigned stifle;
-    unsigned     stifle;
 };
 };
 
 
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_init(tinyrl_history_t * this, unsigned stifle)
-tinyrl_history_init(tinyrl_history_t *this,
-                    unsigned          stifle)
 {
 {
-    this->entries       = NULL;
+	this->entries = NULL;
-    this->stifle        = stifle;
+	this->stifle = stifle;
-    this->current_index = 1;
+	this->current_index = 1;
-    this->length        = 0;
+	this->length = 0;
-    this->size          = 0;
+	this->size = 0;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_fini(tinyrl_history_t * this)
-tinyrl_history_fini(tinyrl_history_t *this)
 {
 {
-    tinyrl_history_entry_t *entry;
+	tinyrl_history_entry_t *entry;
-    tinyrl_history_iterator_t iter;
+	tinyrl_history_iterator_t iter;
-    
+
-    /* release the resource associated with each entry */
+	/* release the resource associated with each entry */
-    for(entry = tinyrl_history_getfirst(this,&iter);
+	for (entry = tinyrl_history_getfirst(this, &iter);
-        entry;
+	     entry; entry = tinyrl_history_getnext(&iter)) {
-        entry = tinyrl_history_getnext(&iter))
+		tinyrl_history_entry_delete(entry);
-    {
+	}
-        tinyrl_history_entry_delete(entry);
+	/* release the list */
-    }
+	free(this->entries);
-    /* release the list */
+	this->entries = NULL;
-    free(this->entries);
-    this->entries = NULL;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-tinyrl_history_t *
+tinyrl_history_t *tinyrl_history_new(unsigned stifle)
-tinyrl_history_new(unsigned stifle)
 {
 {
-    tinyrl_history_t *this = malloc(sizeof(tinyrl_history_t));
+	tinyrl_history_t *this = malloc(sizeof(tinyrl_history_t));
-    if(NULL != this)
+	if (NULL != this) {
-    {
+		tinyrl_history_init(this, stifle);
-        tinyrl_history_init(this,stifle);
+	}
-    }
+	return this;
-    return this;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_delete(tinyrl_history_t * this)
-tinyrl_history_delete(tinyrl_history_t *this)
 {
 {
-    tinyrl_history_fini(this);
+	tinyrl_history_fini(this);
-    free(this);
+	free(this);
 }
 }
 
 
 /*
 /*
@@ -75,18 +69,17 @@ HISTORY LIST MANAGEMENT
 */
 */
 /*------------------------------------- */
 /*------------------------------------- */
 /* insert a new entry at the current offset */
 /* insert a new entry at the current offset */
-static void
+static void insert_entry(tinyrl_history_t * this, const char *line)
-insert_entry(tinyrl_history_t *this,
-             const char       *line)
 {
 {
-    tinyrl_history_entry_t *new_entry = tinyrl_history_entry_new(line,this->current_index++);
+	tinyrl_history_entry_t *new_entry =
-    assert(this->length);
+	    tinyrl_history_entry_new(line, this->current_index++);
-    assert(this->entries);
+	assert(this->length);
-    if(new_entry)
+	assert(this->entries);
-    {
+	if (new_entry) {
-        this->entries[this->length-1] = new_entry;
+		this->entries[this->length - 1] = new_entry;
-    }
+	}
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 /*
 /*
  * This frees the specified entries from the 
  * This frees the specified entries from the 
@@ -94,23 +87,19 @@ insert_entry(tinyrl_history_t *this,
  * This function is inclusive of start and end
  * This function is inclusive of start and end
  */
  */
 static void
 static void
-free_entries(const tinyrl_history_t *this,
+free_entries(const tinyrl_history_t * this, unsigned start, unsigned end)
-             unsigned                start,
-             unsigned                end)
 {
 {
-    unsigned i;
+	unsigned i;
-    assert(start <= end);
+	assert(start <= end);
-    assert(end < this->length);
+	assert(end < this->length);
-        
+
-    for(i  = start;
+	for (i = start; i <= end; i++) {
-        i <= end;
+		tinyrl_history_entry_t *entry = this->entries[i];
-        i++)
+		tinyrl_history_entry_delete(entry);
-    {
+		entry = NULL;
-        tinyrl_history_entry_t *entry = this->entries[i];
+	}
-        tinyrl_history_entry_delete(entry);
-        entry = NULL;
-    }
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 /*
 /*
  * This removes the specified entries from the 
  * This removes the specified entries from the 
@@ -118,344 +107,306 @@ free_entries(const tinyrl_history_t *this,
  * This function is inclusive of start and end
  * This function is inclusive of start and end
  */
  */
 static void
 static void
-remove_entries(tinyrl_history_t *this,
+remove_entries(tinyrl_history_t * this, unsigned start, unsigned end)
-               unsigned          start,
-               unsigned          end)
 {
 {
-    unsigned delta = (end - start) + 1; /* number of entries being deleted */
+	unsigned delta = (end - start) + 1;	/* number of entries being deleted */
-    /* number of entries to shuffle */
+	/* number of entries to shuffle */
-    unsigned num_entries = (this->length - end) - 1; 
+	unsigned num_entries = (this->length - end) - 1;
-    assert(start <= end);
+	assert(start <= end);
-    assert(end < this->length);
+	assert(end < this->length);
-
+
-    if(num_entries)
+	if (num_entries) {
-    {
+		/* move the remaining entries down to close the array */
-        /* move the remaining entries down to close the array */
+		memmove(&this->entries[start],
-        memmove(&this->entries[start],
+			&this->entries[end + 1],
-                &this->entries[end+1],
+			sizeof(tinyrl_history_entry_t *) * num_entries);
-                sizeof(tinyrl_history_entry_t *) * num_entries);
+	}
-    }
+	/* now fix up the length variables */
-    /* now fix up the length variables */
+	this->length -= delta;
-    this->length -= delta;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 /* 
 /* 
 Search the current history buffer for the specified 
 Search the current history buffer for the specified 
 line and if found remove it.
 line and if found remove it.
 */
 */
-static bool_t
+static bool_t remove_duplicate(tinyrl_history_t * this, const char *line)
-remove_duplicate(tinyrl_history_t *this,
-                 const char       *line)
 {
 {
-    bool_t result = BOOL_FALSE;
+	bool_t result = BOOL_FALSE;
-    unsigned i;
+	unsigned i;
-        
+
-    for(i  = 0;
+	for (i = 0; i < this->length; i++) {
-        i < this->length;
+		tinyrl_history_entry_t *entry = this->entries[i];
-        i++)
+		if (0 == strcmp(line, tinyrl_history_entry__get_line(entry))) {
-    {
+			free_entries(this, i, i);
-        tinyrl_history_entry_t *entry = this->entries[i];
+			remove_entries(this, i, i);
-        if(0 == strcmp(line,tinyrl_history_entry__get_line(entry)))
+			result = BOOL_TRUE;
-        {
+			break;
-            free_entries(this,i,i);
+		}
-            remove_entries(this,i,i);
+	}
-            result = BOOL_TRUE;
+	return result;
-            break;
-        }
-    }
-    return result;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 /* 
 /* 
 add an entry to the end of the current array 
 add an entry to the end of the current array 
 if there is no space returns -1 else 0
 if there is no space returns -1 else 0
 */
 */
-static void
+static void append_entry(tinyrl_history_t * this, const char *line)
-append_entry(tinyrl_history_t *this,
-             const char       *line)
 {
 {
-    if(this->length < this->size)
+	if (this->length < this->size) {
-    {
+		this->length++;
-        this->length++;
 
 
-        insert_entry(this,line);
+		insert_entry(this, line);
-    }
+	}
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 /*
 /*
  add a new history entry replacing the oldest one 
  add a new history entry replacing the oldest one 
  */
  */
-static void
+static void add_n_replace(tinyrl_history_t * this, const char *line)
-add_n_replace(tinyrl_history_t *this,
-              const char       *line)
 {
 {
-    if(BOOL_FALSE == remove_duplicate(this,line))
+	if (BOOL_FALSE == remove_duplicate(this, line)) {
-    {
+		/* free the oldest entry */
-        /* free the oldest entry */
+		free_entries(this, 0, 0);
-        free_entries(this,0,0);
+		/* shuffle the array */
-        /* shuffle the array */
+		remove_entries(this, 0, 0);
-        remove_entries(this,0,0);
+	}
-    }
+	/* add the new entry */
-    /* add the new entry */
+	append_entry(this, line);
-    append_entry(this,line);
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 /* add a new history entry growing the array if necessary */
 /* add a new history entry growing the array if necessary */
-static void
+static void add_n_grow(tinyrl_history_t * this, const char *line)
-add_n_grow(tinyrl_history_t *this,
-           const char       *line)
 {
 {
-    if(this->size == this->length)
+	if (this->size == this->length) {
-    {
+		/* increment the history memory by 10 entries each time we grow */
-        /* increment the history memory by 10 entries each time we grow */
+		unsigned new_size = this->size + 10;
-        unsigned                 new_size = this->size + 10;
+		size_t nbytes;
-        size_t                   nbytes;
+		tinyrl_history_entry_t **new_entries;
-        tinyrl_history_entry_t **new_entries;
+
-        
+		nbytes = sizeof(tinyrl_history_entry_t *) * new_size;
-        nbytes      = sizeof(tinyrl_history_entry_t *)*new_size;
+		new_entries = realloc(this->entries, nbytes);
-        new_entries = realloc(this->entries,nbytes);
+		if (NULL != new_entries) {
-        if(NULL != new_entries)
+			this->size = new_size;
-        {
+			this->entries = new_entries;
-            this->size    = new_size;
+		}
-            this->entries = new_entries;
+	}
-        }
+	(void)remove_duplicate(this, line);
-    }
+	append_entry(this, line);
-    (void)remove_duplicate(this,line);
-    append_entry(this,line);
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_add(tinyrl_history_t * this, const char *line)
-tinyrl_history_add(tinyrl_history_t *this,
-                   const char       *line)
 {
 {
-    if(this->length && (this->length == this->stifle))
+	if (this->length && (this->length == this->stifle)) {
-    {
+		add_n_replace(this, line);
-        add_n_replace(this,line);
+	} else {
-    }
+		add_n_grow(this, line);
-    else
+	}
-    {
-        add_n_grow(this,line);
-    }
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_remove(tinyrl_history_t * this,
-tinyrl_history_remove(tinyrl_history_t *this,
+					      unsigned offset)
-                      unsigned          offset)
 {
 {
-    tinyrl_history_entry_t *result = NULL;
+	tinyrl_history_entry_t *result = NULL;
-    
+
-    if(offset < this->length)
+	if (offset < this->length) {
-    {
+		result = this->entries[offset];
-        result = this->entries[offset];
+		/* do the biz */
-        /* do the biz */
+		remove_entries(this, offset, offset);
-        remove_entries(this,offset,offset);
+	}
-    }
+	return result;
-    return result;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_clear(tinyrl_history_t * this)
-tinyrl_history_clear(tinyrl_history_t *this)
 {
 {
-    /* free all the entries */
+	/* free all the entries */
-    free_entries(this,0,this->length-1);
+	free_entries(this, 0, this->length - 1);
-    /* and shuffle the array */
+	/* and shuffle the array */
-    remove_entries(this,0,this->length-1);
+	remove_entries(this, 0, this->length - 1);
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_stifle(tinyrl_history_t * this, unsigned stifle)
-tinyrl_history_stifle(tinyrl_history_t *this,
-                      unsigned          stifle)
 {
 {
-    /* 
+	/* 
-     * if we are stifling (i.e. non zero value) then 
+	 * if we are stifling (i.e. non zero value) then 
-     * delete the obsolete entries
+	 * delete the obsolete entries
-     */
+	 */
-    if(stifle)
+	if (stifle) {
-    {
+		if (stifle < this->length) {
-        if(stifle < this->length)
+			unsigned num_deletes = this->length - stifle;
-        {
+			/* free the entries */
-            unsigned num_deletes = this->length - stifle;
+			free_entries(this, 0, num_deletes - 1);
-            /* free the entries */
+			/* shuffle the array shut */
-            free_entries(this,0,num_deletes-1);
+			remove_entries(this, 0, num_deletes - 1);
-            /* shuffle the array shut */
+		}
-            remove_entries(this,0,num_deletes-1);
+		this->stifle = stifle;
-        }
+	}
-        this->stifle = stifle;
-    }
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-unsigned
+unsigned tinyrl_history_unstifle(tinyrl_history_t * this)
-tinyrl_history_unstifle(tinyrl_history_t *this)
 {
 {
-    unsigned result = this->stifle;
+	unsigned result = this->stifle;
 
 
-    this->stifle = 0;
+	this->stifle = 0;
 
 
-    return result;
+	return result;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-bool_t
+bool_t tinyrl_history_is_stifled(const tinyrl_history_t * this)
-tinyrl_history_is_stifled(const tinyrl_history_t *this)
 {
 {
-    return this->stifle ? BOOL_TRUE : BOOL_FALSE;
+	return this->stifle ? BOOL_TRUE : BOOL_FALSE;
 }
 }
+
 /*
 /*
 INFORMATION ABOUT THE HISTORY LIST 
 INFORMATION ABOUT THE HISTORY LIST 
-*/    
+*/
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_get(const tinyrl_history_t * this,
-tinyrl_history_get(const tinyrl_history_t *this,
+					   unsigned position)
-                   unsigned                position)
 {
 {
-    unsigned i;
+	unsigned i;
-    tinyrl_history_entry_t *entry = NULL;
+	tinyrl_history_entry_t *entry = NULL;
-    for(i = 0;
+	for (i = 0; i < this->length; i++) {
-        i < this->length;
+		entry = this->entries[i];
-        i++)
+		if (position == tinyrl_history_entry__get_index(entry)) {
-    {
+			/* found it */
-        entry = this->entries[i];
+			break;
-        if(position == tinyrl_history_entry__get_index(entry))
+		}
-        {
+		entry = NULL;
-            /* found it */
+	}
-            break;
+	return entry;
-        }
-        entry = NULL;
-    }
-    return entry;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
 tinyrl_history_expand_t
 tinyrl_history_expand_t
-tinyrl_history_expand(const tinyrl_history_t *this,
+tinyrl_history_expand(const tinyrl_history_t * this,
-                      const char             *string, 
+		      const char *string, char **output)
-                      char                  **output)
 {
 {
-    tinyrl_history_expand_t result = tinyrl_history_NO_EXPANSION; /* no expansion */
+	tinyrl_history_expand_t result = tinyrl_history_NO_EXPANSION;	/* no expansion */
-    const char             *p,*start;
+	const char *p, *start;
-    char                   *buffer = NULL;
+	char *buffer = NULL;
-    unsigned                len;
+	unsigned len;
-    
+
-    for(p = string,start=string,len=0;
+	for (p = string, start = string, len = 0; *p; p++, len++) {
-        *p;
+		/* perform pling substitution */
-        p++,len++)
+		if (*p == '!') {
-    {
+			/* assume the last command to start with... */
-        /* perform pling substitution */
+			unsigned offset = this->current_index - 1;
-        if(*p == '!')
+			unsigned skip;
-        {
+			tinyrl_history_entry_t *entry;
-            /* assume the last command to start with... */
+
-            unsigned                offset = this->current_index - 1;
+			/* this could be an escape sequence */
-            unsigned                skip;
+			if (p[1] != '!') {
-            tinyrl_history_entry_t *entry;
+				int tmp;
-         
+				int res;
-            /* this could be an escape sequence */
+				/* read the numeric identifier */
-            if(p[1] != '!')
+				res = sscanf(p, "!%d", &tmp);
-            {
+				if ((0 == res) || (EOF == res)) {
-                int tmp;
+					/* error so ignore it */
-                int res;
+					break;
-                /* read the numeric identifier */
+				}
-                res = sscanf(p,"!%d",&tmp);
+
-                if((0 == res) || (EOF == res))
+				if (tmp < 0) {
-                {
+					/* this is a relative reference */
-                    /* error so ignore it */
+					/*lint -e737 Loss of sign in promotion from int to unsigend int */
-                    break;
+					offset += tmp;	/* adding a negative substracts... */
-                }
+					/*lint +e737 */
-                
+				} else {
-                if(tmp < 0)
+					/* this is an absolute reference */
-                {
+					offset = (unsigned)tmp;
-                    /* this is a relative reference */
+				}
-                    /*lint -e737 Loss of sign in promotion from int to unsigend int */
+			}
-                    offset += tmp; /* adding a negative substracts... */
+			if (len > 0) {
-                    /*lint +e737 */
+				/* we need to add in some previous plain text */
-                }
+				lub_string_catn(&buffer, start, len);
-                else
+			}
-                {
+
-                    /* this is an absolute reference */
+			/* skip the escaped chars */
-                    offset = (unsigned)tmp;
+			p += skip = strspn(p, "!-0123456789");
-                }
+
-            }
+			/* try and find the history entry */
-            if(len > 0)
+			entry = tinyrl_history_get(this, offset);
-            {
+			if (NULL != entry) {
-                /* we need to add in some previous plain text */
+				/* reset the non-escaped references */
-                lub_string_catn(&buffer,start,len);
+				start = p;
-            }
+				len = 0;
-            
+				/* add the expanded text to the buffer */
-            /* skip the escaped chars */
+				result = tinyrl_history_EXPANDED;
-            p += skip = strspn(p,"!-0123456789");
+				lub_string_cat(&buffer,
-
+					       tinyrl_history_entry__get_line
-            /* try and find the history entry */
+					       (entry));
-            entry = tinyrl_history_get(this,offset);
+			} else {
-            if(NULL != entry)
+				/* we simply leave the unexpanded sequence */
-            {
+				len += skip;
-                /* reset the non-escaped references */
+			}
-                start = p;
+		}
-                len   = 0;
+	}
-                /* add the expanded text to the buffer */
+	/* add any left over plain text */
-                result = tinyrl_history_EXPANDED;
+	lub_string_catn(&buffer, start, len);
-                lub_string_cat(&buffer,tinyrl_history_entry__get_line(entry));
+	*output = buffer;
-            }
+
-            else
+	return result;
-            {
-                /* we simply leave the unexpanded sequence */
-                len += skip;
-            }
-        }
-    }
-    /* add any left over plain text */
-    lub_string_catn(&buffer,start,len);
-    *output = buffer;
-    
-    return result;
 }
 }
+
 /*-------------------------------------*/
 /*-------------------------------------*/
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_getfirst(const tinyrl_history_t * this,
-tinyrl_history_getfirst(const tinyrl_history_t    *this,
+						tinyrl_history_iterator_t *
-                        tinyrl_history_iterator_t *iter)
+						iter)
 {
 {
-    tinyrl_history_entry_t *result = NULL;
+	tinyrl_history_entry_t *result = NULL;
 
 
-    iter->history = this;
+	iter->history = this;
-    iter->offset  = 0;
+	iter->offset = 0;
 
 
-    if(this->length)
+	if (this->length) {
-    {
+		result = this->entries[iter->offset];
-        result = this->entries[iter->offset];
+	}
-    }    
+	return result;
-    return result;
 }
 }
+
 /*-------------------------------------*/
 /*-------------------------------------*/
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_getnext(tinyrl_history_iterator_t * iter)
-tinyrl_history_getnext(tinyrl_history_iterator_t *iter)
 {
 {
-    tinyrl_history_entry_t *result = NULL;
+	tinyrl_history_entry_t *result = NULL;
 
 
-    if(iter->offset < iter->history->length - 1)
+	if (iter->offset < iter->history->length - 1) {
-    {
+		iter->offset++;
-        iter->offset++;
+		result = iter->history->entries[iter->offset];
-        result = iter->history->entries[iter->offset];
+	}
-    }
 
 
-    return result;
+	return result;
 }
 }
+
 /*-------------------------------------*/
 /*-------------------------------------*/
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_getlast(const tinyrl_history_t * this,
-tinyrl_history_getlast (const tinyrl_history_t    *this,
+					       tinyrl_history_iterator_t * iter)
-                        tinyrl_history_iterator_t *iter)
 {
 {
-    iter->history = this;
+	iter->history = this;
-    iter->offset  = this->length;
+	iter->offset = this->length;
-    
+
-    return tinyrl_history_getprevious(iter);
+	return tinyrl_history_getprevious(iter);
 }
 }
+
 /*-------------------------------------*/
 /*-------------------------------------*/
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_getprevious(tinyrl_history_iterator_t *
-tinyrl_history_getprevious(tinyrl_history_iterator_t *iter)
+						   iter)
 {
 {
-    tinyrl_history_entry_t *result = NULL;
+	tinyrl_history_entry_t *result = NULL;
 
 
-    if(iter->offset)
+	if (iter->offset) {
-    {
+		iter->offset--;
-        iter->offset--;
+		result = iter->history->entries[iter->offset];
-        result = iter->history->entries[iter->offset];
+	}
-    }
 
 
-    return result;    
+	return result;
 }
 }
+
 /*-------------------------------------*/
 /*-------------------------------------*/

+ 29 - 32
tinyrl/history/history_entry.c

@@ -3,56 +3,53 @@
 #include "lub/string.h"
 #include "lub/string.h"
 #include <stdlib.h>
 #include <stdlib.h>
 
 
-struct _tinyrl_history_entry
+struct _tinyrl_history_entry {
-{
+	char *line;
-    char       *line;
+	unsigned index;
-    unsigned    index;
 };
 };
 /*------------------------------------- */
 /*------------------------------------- */
 static void
 static void
-entry_init(tinyrl_history_entry_t *this,
+entry_init(tinyrl_history_entry_t * this, const char *line, unsigned index)
-           const char             *line,
-           unsigned                index)
 {
 {
-    this->line = lub_string_dup(line);
+	this->line = lub_string_dup(line);
-    this->index = index;
+	this->index = index;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-static void
+static void entry_fini(tinyrl_history_entry_t * this)
-entry_fini(tinyrl_history_entry_t *this)
 {
 {
-    lub_string_free(this->line);
+	lub_string_free(this->line);
-    this->line = NULL;
+	this->line = NULL;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-tinyrl_history_entry_t *
+tinyrl_history_entry_t *tinyrl_history_entry_new(const char *line,
-tinyrl_history_entry_new(const char *line,
+						 unsigned index)
-                         unsigned    index)
 {
 {
-    tinyrl_history_entry_t *this = malloc(sizeof(tinyrl_history_entry_t));
+	tinyrl_history_entry_t *this = malloc(sizeof(tinyrl_history_entry_t));
-    if(NULL != this)
+	if (NULL != this) {
-    {
+		entry_init(this, line, index);
-        entry_init(this,line,index);
+	}
-    }
+	return this;
-    return this;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-void
+void tinyrl_history_entry_delete(tinyrl_history_entry_t * this)
-tinyrl_history_entry_delete(tinyrl_history_entry_t *this)
 {
 {
-    entry_fini(this);
+	entry_fini(this);
-    free(this);
+	free(this);
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-const char *
+const char *tinyrl_history_entry__get_line(const tinyrl_history_entry_t * this)
-tinyrl_history_entry__get_line(const tinyrl_history_entry_t *this)
 {
 {
-    return this->line;
+	return this->line;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */
-unsigned
+unsigned tinyrl_history_entry__get_index(const tinyrl_history_entry_t * this)
-tinyrl_history_entry__get_index(const tinyrl_history_entry_t *this)
 {
 {
-    return this->index;
+	return this->index;
 }
 }
+
 /*------------------------------------- */
 /*------------------------------------- */

+ 3 - 5
tinyrl/history/private.h

@@ -3,9 +3,7 @@
 /**************************************
 /**************************************
  * protected interface to tinyrl_history_entry class
  * protected interface to tinyrl_history_entry class
  ************************************** */
  ************************************** */
-extern tinyrl_history_entry_t *
+extern tinyrl_history_entry_t *tinyrl_history_entry_new(const char *line,
-    tinyrl_history_entry_new(const char *line,
+							unsigned index);
-                             unsigned    index);
 
 
-extern void
+extern void tinyrl_history_entry_delete(tinyrl_history_entry_t * instance);
-    tinyrl_history_entry_delete(tinyrl_history_entry_t *instance);

+ 31 - 32
tinyrl/private.h

@@ -4,39 +4,38 @@
 #include "tinyrl/vt100.h"
 #include "tinyrl/vt100.h"
 
 
 /* define the class member data and virtual methods */
 /* define the class member data and virtual methods */
-struct _tinyrl
+struct _tinyrl {
-{
+	const char *line;
-    const char               *line;
+	unsigned max_line_length;
-    unsigned                  max_line_length;
+	const char *prompt;
-    const char               *prompt;
+	size_t prompt_size;
-    size_t                    prompt_size;
+	char *buffer;
-    char                     *buffer;
+	size_t buffer_size;
-    size_t                    buffer_size;
+	bool_t done;
-    bool_t                    done;
+	bool_t completion_over;
-    bool_t                    completion_over;
+	bool_t completion_error_over;
-    bool_t                    completion_error_over;
+	unsigned point;
-    unsigned                  point;
+	unsigned end;
-    unsigned                  end;
+	tinyrl_completion_func_t *attempted_completion_function;
-    tinyrl_completion_func_t *attempted_completion_function;
+	int state;
-    int                       state;
 #define RL_STATE_COMPLETING (0x00000001)
 #define RL_STATE_COMPLETING (0x00000001)
-    char                     *kill_string;
+	char *kill_string;
 #define NUM_HANDLERS 256
 #define NUM_HANDLERS 256
-    tinyrl_key_func_t        *handlers[NUM_HANDLERS];
+	tinyrl_key_func_t *handlers[NUM_HANDLERS];
 
 
-    tinyrl_history_t         *history;
+	tinyrl_history_t *history;
-    tinyrl_history_iterator_t hist_iter;
+	tinyrl_history_iterator_t hist_iter;
-    tinyrl_vt100_t           *term;
+	tinyrl_vt100_t *term;
-    void                     *context; /* context supplied by caller
+	void *context;		/* context supplied by caller
-                                        * to tinyrl_readline()
+				 * to tinyrl_readline()
-                                        */
+				 */
-    char                      echo_char;
+	char echo_char;
-    bool_t                    echo_enabled;
+	bool_t echo_enabled;
-    struct termios            default_termios;
+	struct termios default_termios;
-    bool_t                    isatty;
+	bool_t isatty;
-    char                     *last_buffer; /* hold record of the previous 
+	char *last_buffer;	/* hold record of the previous 
-                                              buffer for redisplay purposes */
+				   buffer for redisplay purposes */
-    unsigned                  last_point; /* hold record of the previous 
+	unsigned last_point;	/* hold record of the previous 
-                                              cursor position for redisplay purposes */
+				   cursor position for redisplay purposes */
-    bool_t                    utf8; /* Is the encoding UTF-8 */
+	bool_t utf8;		/* Is the encoding UTF-8 */
 };
 };

File diff suppressed because it is too large
+ 669 - 739
tinyrl/tinyrl.c


+ 80 - 140
tinyrl/tinyrl.h

@@ -15,176 +15,127 @@ from a CLI in a "readline" like fashion.
 #include "lub/c_decl.h"
 #include "lub/c_decl.h"
 #include "tinyrl/history.h"
 #include "tinyrl/history.h"
 
 
-_BEGIN_C_DECL
+_BEGIN_C_DECL typedef struct _tinyrl tinyrl_t;
-
+typedef enum {
-typedef struct _tinyrl tinyrl_t;
-typedef enum
-{
     /**
     /**
      * no possible completions were found
      * no possible completions were found
      */
      */
-    TINYRL_NO_MATCH = 0,
+	TINYRL_NO_MATCH = 0,
     /**
     /**
      * the provided string was already an exact match
      * the provided string was already an exact match
      */
      */
-    TINYRL_MATCH,
+	TINYRL_MATCH,
     /**
     /**
      * the provided string was ambiguous and produced
      * the provided string was ambiguous and produced
      * more than one possible completion
      * more than one possible completion
      */
      */
-    TINYRL_AMBIGUOUS,
+	TINYRL_AMBIGUOUS,
     /**
     /**
      * the provided string was unambiguous and a 
      * the provided string was unambiguous and a 
      * completion was performed
      * completion was performed
      */
      */
-    TINYRL_COMPLETED_MATCH,
+	TINYRL_COMPLETED_MATCH,
     /**
     /**
      * the provided string was ambiguous but a partial
      * the provided string was ambiguous but a partial
      * completion was performed.
      * completion was performed.
      */
      */
-    TINYRL_COMPLETED_AMBIGUOUS,
+	TINYRL_COMPLETED_AMBIGUOUS,
     /**
     /**
      * the provided string was an exact match for one
      * the provided string was an exact match for one
      * possible value but there are other exetensions
      * possible value but there are other exetensions
      * of the string available.
      * of the string available.
      */
      */
-    TINYRL_MATCH_WITH_EXTENSIONS
+	TINYRL_MATCH_WITH_EXTENSIONS
 } tinyrl_match_e;
 } tinyrl_match_e;
 
 
 /* virtual methods */
 /* virtual methods */
-typedef char  *
+typedef char *tinyrl_compentry_func_t(tinyrl_t * instance,
-    tinyrl_compentry_func_t(tinyrl_t   *instance,
+				      const char *text,
-                            const char *text,
+				      unsigned offset, unsigned state);
-                            unsigned    offset,
+typedef int tinyrl_hook_func_t(tinyrl_t * instance);
-                            unsigned    state);
+
-typedef int
+typedef char **tinyrl_completion_func_t(tinyrl_t * instance,
-    tinyrl_hook_func_t(tinyrl_t *instance);
+					const char *text,
-
+					unsigned start, unsigned end);
-typedef char **
-    tinyrl_completion_func_t(tinyrl_t   *instance,
-                             const char *text, 
-                             unsigned    start,
-                             unsigned    end);
 /**
 /**
  * \return
  * \return
  * - BOOL_TRUE if the action associated with the key has
  * - BOOL_TRUE if the action associated with the key has
  *   been performed successfully
  *   been performed successfully
  * - BOOL_FALSE if the action was not successful
  * - BOOL_FALSE if the action was not successful
  */
  */
-typedef bool_t
+typedef bool_t tinyrl_key_func_t(tinyrl_t * instance, int key);
-    tinyrl_key_func_t(tinyrl_t *instance,
-                      int       key);
-
 
 
 /* exported functions */
 /* exported functions */
-extern tinyrl_t *
+extern tinyrl_t *tinyrl_new(FILE * instream,
-    tinyrl_new(FILE                     *instream,
+			    FILE * outstream,
-               FILE                     *outstream,
+			    unsigned stifle,
-               unsigned                  stifle,
+			    tinyrl_completion_func_t * complete_fn);
-               tinyrl_completion_func_t *complete_fn);
+
-               
 /*lint -esym(534,tinyrl_printf)  Ignoring return value of function */
 /*lint -esym(534,tinyrl_printf)  Ignoring return value of function */
-extern int
+extern int tinyrl_printf(const tinyrl_t * instance, const char *fmt, ...);
-    tinyrl_printf(const tinyrl_t *instance,
-                  const char     *fmt,
-                  ...);
 
 
-extern void
+extern void tinyrl_delete(tinyrl_t * instance);
-    tinyrl_delete(tinyrl_t *instance);
 
 
-extern tinyrl_history_t *
+extern tinyrl_history_t *tinyrl__get_history(const tinyrl_t * instance);
-    tinyrl__get_history(const tinyrl_t *instance);
 
 
-extern const char *
+extern const char *tinyrl__get_prompt(const tinyrl_t * instance);
-    tinyrl__get_prompt(const tinyrl_t *instance);
 
 
-extern void
+extern void tinyrl_done(tinyrl_t * instance);
-    tinyrl_done(tinyrl_t *instance);
 
 
-extern void
+extern void tinyrl_completion_over(tinyrl_t * instance);
-    tinyrl_completion_over(tinyrl_t *instance);
 
 
-extern void
+extern void tinyrl_completion_error_over(tinyrl_t * instance);
-    tinyrl_completion_error_over(tinyrl_t *instance);
 
 
-extern bool_t
+extern bool_t tinyrl_is_completion_error_over(const tinyrl_t * instance);
-    tinyrl_is_completion_error_over(const tinyrl_t *instance);
 
 
-extern void *
+extern void *tinyrl__get_context(const tinyrl_t * instance);
-    tinyrl__get_context(const tinyrl_t *instance);
 
 
 /**
 /**
  * This operation returns the current line in use by the tinyrl instance
  * This operation returns the current line in use by the tinyrl instance
  * NB. the pointer will become invalid after any further operation on the 
  * NB. the pointer will become invalid after any further operation on the 
  * instance.
  * instance.
  */
  */
-extern const char *
+extern const char *tinyrl__get_line(const tinyrl_t * instance);
-    tinyrl__get_line(const tinyrl_t *instance);
 
 
-extern void
+extern void tinyrl__set_istream(tinyrl_t * instance, FILE * istream);
-    tinyrl__set_istream(tinyrl_t *instance,
-                        FILE     *istream);
 
 
-extern bool_t
+extern bool_t tinyrl__get_isatty(const tinyrl_t * instance);
-    tinyrl__get_isatty(const tinyrl_t *instance);
 
 
-extern FILE *
+extern FILE *tinyrl__get_istream(const tinyrl_t * instance);
-    tinyrl__get_istream(const tinyrl_t *instance);
 
 
-extern FILE *
+extern FILE *tinyrl__get_ostream(const tinyrl_t * instance);
-    tinyrl__get_ostream(const tinyrl_t *instance);
 
 
-extern bool_t
+extern bool_t tinyrl__get_utf8(const tinyrl_t * instance);
-    tinyrl__get_utf8(const tinyrl_t *instance);
 
 
-extern void
+extern void tinyrl__set_utf8(tinyrl_t * instance, bool_t utf8);
-    tinyrl__set_utf8(tinyrl_t *instance, bool_t utf8);
 
 
-extern char *
+extern char *tinyrl_readline(tinyrl_t * instance,
-    tinyrl_readline(tinyrl_t   *instance,
+			     const char *prompt, void *context);
-                    const char *prompt,
-                    void       *context);
 
 
-extern char *
+extern char *tinyrl_forceline(tinyrl_t * instance,
-    tinyrl_forceline(tinyrl_t   *instance,
+			      const char *prompt,
-                     const char *prompt,
+			      void *context, const char *line);
-                     void       *context,
-                     const char *line);
 
 
 extern bool_t
 extern bool_t
-    tinyrl_bind_key(tinyrl_t          *instance,
+tinyrl_bind_key(tinyrl_t * instance, int key, tinyrl_key_func_t * fn);
-                    int                key,
+extern void tinyrl_delete_matches(char **instance);
-                    tinyrl_key_func_t *fn);
+extern char **tinyrl_completion(tinyrl_t * instance,
-extern void
+				const char *line,
-    tinyrl_delete_matches(char **instance);
+				unsigned start,
-extern char **
+				unsigned end,
-    tinyrl_completion(tinyrl_t                *instance,
+				tinyrl_compentry_func_t * generator);
-                      const char              *line,
+extern void tinyrl_crlf(const tinyrl_t * instance);
-                      unsigned                 start,
+extern void tinyrl_ding(const tinyrl_t * instance);
-                      unsigned                 end,
-                      tinyrl_compentry_func_t *generator);
-extern void
-    tinyrl_crlf(const tinyrl_t *instance);
-extern void
-    tinyrl_ding(const tinyrl_t *instance);
 
 
-extern void
+extern void tinyrl_reset_line_state(tinyrl_t * instance);
-    tinyrl_reset_line_state(tinyrl_t *instance);
 
 
-extern bool_t
+extern bool_t tinyrl_insert_text(tinyrl_t * instance, const char *text);
-    tinyrl_insert_text(tinyrl_t   *instance,
-                       const char *text);
 extern void
 extern void
-    tinyrl_delete_text(tinyrl_t *instance,
+tinyrl_delete_text(tinyrl_t * instance, unsigned start, unsigned end);
-                       unsigned  start,
+extern void tinyrl_redisplay(tinyrl_t * instance);
-                       unsigned  end);
-extern void
-    tinyrl_redisplay(tinyrl_t *instance);
 
 
 extern void
 extern void
-    tinyrl_replace_line(tinyrl_t *instance,
+tinyrl_replace_line(tinyrl_t * instance, const char *text, int clear_undo);
-                        const char    *text,
-                        int            clear_undo);
 
 
 /**
 /**
  * Complete the current word in the input buffer, displaying
  * Complete the current word in the input buffer, displaying
@@ -196,9 +147,8 @@ extern void
  * - If the current word is ambiguous then a list of 
  * - If the current word is ambiguous then a list of 
  *   possible completions will be displayed.
  *   possible completions will be displayed.
  */
  */
-extern tinyrl_match_e
+extern tinyrl_match_e tinyrl_complete(tinyrl_t * instance);
-    tinyrl_complete(tinyrl_t *instance);
+
-    
 /**
 /**
  * Complete the current word in the input buffer, displaying
  * Complete the current word in the input buffer, displaying
  * a prompt to clarify any abiguity or extra extensions if necessary.
  * a prompt to clarify any abiguity or extra extensions if necessary.
@@ -211,64 +161,54 @@ extern tinyrl_match_e
  * - If the current word is complete but there are extra
  * - If the current word is complete but there are extra
  *   completions which are an extension of that word then
  *   completions which are an extension of that word then
  *   a list of these will be displayed.
  *   a list of these will be displayed.
- */                        
+ */
-extern tinyrl_match_e
+extern tinyrl_match_e tinyrl_complete_with_extensions(tinyrl_t * instance);
-    tinyrl_complete_with_extensions(tinyrl_t *instance);
 
 
 /**
 /**
  * Disable echoing of input characters when a line in input.
  * Disable echoing of input characters when a line in input.
  * 
  * 
- */                    
+ */
-extern void
+extern void tinyrl_disable_echo(
-    tinyrl_disable_echo(
+	 /** 
-         /** 
           * The instance on which to operate
           * The instance on which to operate
           */
           */
-         tinyrl_t *instance,
+				       tinyrl_t * instance,
-         /**
+	 /**
           * The character to display instead of a key press.
           * The character to display instead of a key press.
           *
           *
           * If this has the special value '/0' then the insertion point will not 
           * If this has the special value '/0' then the insertion point will not 
           * be moved when keys are pressed.
           * be moved when keys are pressed.
           */
           */
-          char echo_char
+				       char echo_char);
-    ); 
 /**
 /**
  * Enable key echoing for this instance. (This is the default behaviour)
  * Enable key echoing for this instance. (This is the default behaviour)
  */
  */
-extern void
+extern void tinyrl_enable_echo(
-    tinyrl_enable_echo(
+	/** 
-        /** 
          * The instance on which to operate
          * The instance on which to operate
          */
          */
-        tinyrl_t *instance
+				      tinyrl_t * instance);
-    );
 /**
 /**
  * Indicate whether the current insertion point is quoting or not
  * Indicate whether the current insertion point is quoting or not
  */
  */
-extern bool_t 
+extern bool_t tinyrl_is_quoting(
-    tinyrl_is_quoting(
+	/** 
-        /** 
          * The instance on which to operate
          * The instance on which to operate
          */
          */
-        const tinyrl_t *instance
+				       const tinyrl_t * instance);
-    );
 /**
 /**
  * Limit maximum line length
  * Limit maximum line length
  */
  */
-extern void
+extern void tinyrl_limit_line_length(
-    tinyrl_limit_line_length(
+	/** 
-        /** 
          * The instance on which to operate
          * The instance on which to operate
          */
          */
-	tinyrl_t *instance,
+					    tinyrl_t * instance,
-        /** 
+	/** 
          * The length to limit to (0) is unlimited
          * The length to limit to (0) is unlimited
          */
          */
-        unsigned length
+					    unsigned length);
-    );
-    
-_END_C_DECL
 
 
-#endif /* _tinyrl_tinyrl_h */
+_END_C_DECL
+#endif				/* _tinyrl_tinyrl_h */
 /** @} tinyrl_tinyrl */
 /** @} tinyrl_tinyrl */

+ 49 - 149
tinyrl/vt100.h

@@ -25,9 +25,7 @@ doesn't support all the features of a VT100 terminal.
 #include "lub/c_decl.h"
 #include "lub/c_decl.h"
 #include "lub/types.h"
 #include "lub/types.h"
 
 
-_BEGIN_C_DECL
+_BEGIN_C_DECL typedef struct _tinyrl_vt100 tinyrl_vt100_t;
-
-typedef struct _tinyrl_vt100 tinyrl_vt100_t;
 
 
 /* define the Key codes */
 /* define the Key codes */
 #define KEY_NUL	0	/**< ^@	Null character */
 #define KEY_NUL	0	/**< ^@	Null character */
@@ -68,161 +66,63 @@ typedef struct _tinyrl_vt100 tinyrl_vt100_t;
 /**
 /**
  * This enumeration is used to identify the types of escape code 
  * This enumeration is used to identify the types of escape code 
  */
  */
-typedef enum
+typedef enum {
-{
+	tinyrl_vt100_UNKNOWN,  /**< Undefined escape sequence */
-    tinyrl_vt100_UNKNOWN,      /**< Undefined escape sequence */
+	tinyrl_vt100_CURSOR_UP,/**< Move the cursor up        */
-    tinyrl_vt100_CURSOR_UP,    /**< Move the cursor up        */
+	tinyrl_vt100_CURSOR_DOWN,
-    tinyrl_vt100_CURSOR_DOWN,  /**< Move the cursor down      */
+			       /**< Move the cursor down      */
-    tinyrl_vt100_CURSOR_LEFT,  /**< Move the cursor left      */
+	tinyrl_vt100_CURSOR_LEFT,
-    tinyrl_vt100_CURSOR_RIGHT  /**< Move the cursor right     */      
+			       /**< Move the cursor left      */
+	tinyrl_vt100_CURSOR_RIGHT
+			       /**< Move the cursor right     */
 } tinyrl_vt100_escape_t;
 } tinyrl_vt100_escape_t;
 
 
-extern tinyrl_vt100_t *
+extern tinyrl_vt100_t *tinyrl_vt100_new(FILE * instream, FILE * outstream);
-    tinyrl_vt100_new(
+extern void tinyrl_vt100_delete(tinyrl_vt100_t * instance);
-        FILE               *instream,
-        FILE               *outstream
-    );
-extern void
-    tinyrl_vt100_delete(tinyrl_vt100_t *instance);
 
 
 /*lint -esym(534,tinyrl_vt100_printf) Ignoring return value of function */
 /*lint -esym(534,tinyrl_vt100_printf) Ignoring return value of function */
-extern int
+extern int tinyrl_vt100_printf(const tinyrl_vt100_t * instance, const char *fmt, ...
-    tinyrl_vt100_printf(
-        const tinyrl_vt100_t *instance,
-        const char           *fmt,
-        ...
     );
     );
 extern int
 extern int
-    tinyrl_vt100_vprintf(
+tinyrl_vt100_vprintf(const tinyrl_vt100_t * instance,
-        const tinyrl_vt100_t *instance,
+		     const char *fmt, va_list args);
-        const char           *fmt, 
-        va_list               args
-    );
 
 
-extern int
+extern int tinyrl_vt100_oflush(const tinyrl_vt100_t * instance);
-    tinyrl_vt100_oflush(
+extern int tinyrl_vt100_ierror(const tinyrl_vt100_t * instance);
-        const tinyrl_vt100_t *instance
+extern int tinyrl_vt100_oerror(const tinyrl_vt100_t * instance);
-    );
+extern int tinyrl_vt100_ieof(const tinyrl_vt100_t * instance);
-extern int
+extern int tinyrl_vt100_getchar(const tinyrl_vt100_t * instance);
-    tinyrl_vt100_ierror(
+extern unsigned tinyrl_vt100__get_width(const tinyrl_vt100_t * instance);
-        const tinyrl_vt100_t *instance
+extern unsigned tinyrl_vt100__get_height(const tinyrl_vt100_t * instance);
-    );
-extern int
-    tinyrl_vt100_oerror(
-        const tinyrl_vt100_t *instance
-    );
-extern int
-    tinyrl_vt100_ieof(
-        const tinyrl_vt100_t *instance
-    );
-extern int
-    tinyrl_vt100_getchar(
-        const tinyrl_vt100_t *instance
-    );
-extern unsigned
-    tinyrl_vt100__get_width(
-        const tinyrl_vt100_t *instance
-    );
-extern unsigned
-    tinyrl_vt100__get_height(
-        const tinyrl_vt100_t *instance
-    );
 extern void
 extern void
-    tinyrl_vt100__set_istream(
+tinyrl_vt100__set_istream(tinyrl_vt100_t * instance, FILE * istream);
-        tinyrl_vt100_t *instance,
+extern FILE *tinyrl_vt100__get_istream(const tinyrl_vt100_t * instance);
-        FILE           *istream
+extern FILE *tinyrl_vt100__get_ostream(const tinyrl_vt100_t * instance);
-    );
-extern FILE *
-    tinyrl_vt100__get_istream(
-        const tinyrl_vt100_t *instance
-    );
-extern FILE *
-    tinyrl_vt100__get_ostream(
-        const tinyrl_vt100_t *instance
-    );
 
 
 extern tinyrl_vt100_escape_t
 extern tinyrl_vt100_escape_t
-    tinyrl_vt100_escape_decode(
+tinyrl_vt100_escape_decode(const tinyrl_vt100_t * instance);
-        const tinyrl_vt100_t *instance
+extern void tinyrl_vt100_ding(const tinyrl_vt100_t * instance);
-    );
+extern void tinyrl_vt100_attribute_reset(const tinyrl_vt100_t * instance);
-extern void
+extern void tinyrl_vt100_attribute_bright(const tinyrl_vt100_t * instance);
-    tinyrl_vt100_ding(
+extern void tinyrl_vt100_attribute_dim(const tinyrl_vt100_t * instance);
-        const tinyrl_vt100_t *instance
+extern void tinyrl_vt100_attribute_underscore(const tinyrl_vt100_t * instance);
-    );
+extern void tinyrl_vt100_attribute_blink(const tinyrl_vt100_t * instance);
-extern void
+extern void tinyrl_vt100_attribute_reverse(const tinyrl_vt100_t * instance);
-    tinyrl_vt100_attribute_reset(
+extern void tinyrl_vt100_attribute_hidden(const tinyrl_vt100_t * instance);
-        const tinyrl_vt100_t *instance
+extern void tinyrl_vt100_erase_line(const tinyrl_vt100_t * instance);
-    );
+extern void tinyrl_vt100_clear_screen(const tinyrl_vt100_t * instance);
-extern void
+extern void
-    tinyrl_vt100_attribute_bright(
+tinyrl_vt100_cursor_back(const tinyrl_vt100_t * instance, unsigned count);
-        const tinyrl_vt100_t *instance
+extern void
-    );
+tinyrl_vt100_cursor_forward(const tinyrl_vt100_t * instance, unsigned count);
-extern void
+extern void
-    tinyrl_vt100_attribute_dim(
+tinyrl_vt100_cursor_up(const tinyrl_vt100_t * instance, unsigned count);
-        const tinyrl_vt100_t *instance
+extern void
-    );
+tinyrl_vt100_cursor_down(const tinyrl_vt100_t * instance, unsigned count);
-extern void
+extern void tinyrl_vt100_cursor_home(const tinyrl_vt100_t * instance);
-    tinyrl_vt100_attribute_underscore(
+extern void tinyrl_vt100_cursor_save(const tinyrl_vt100_t * instance);
-        const tinyrl_vt100_t *instance
+extern void tinyrl_vt100_cursor_restore(const tinyrl_vt100_t * instance);
-    );
+extern void tinyrl_vt100_erase(const tinyrl_vt100_t * instance, unsigned count);
-extern void
-    tinyrl_vt100_attribute_blink(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_attribute_reverse(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_attribute_hidden(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_erase_line(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_clear_screen(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_cursor_back(
-        const tinyrl_vt100_t *instance,
-        unsigned              count
-    );
-extern void
-    tinyrl_vt100_cursor_forward(
-        const tinyrl_vt100_t *instance,
-        unsigned              count
-    );
-extern void
-    tinyrl_vt100_cursor_up(
-        const tinyrl_vt100_t *instance,
-        unsigned              count
-    );
-extern void
-    tinyrl_vt100_cursor_down(
-        const tinyrl_vt100_t *instance,
-        unsigned              count
-    );
-extern void
-    tinyrl_vt100_cursor_home(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_cursor_save(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_cursor_restore(
-        const tinyrl_vt100_t *instance
-    );
-extern void
-    tinyrl_vt100_erase(
-        const tinyrl_vt100_t *instance,
-        unsigned              count
-    );
 _END_C_DECL
 _END_C_DECL
-
+#endif				/* _tinyrl_vt100_h */
-#endif /* _tinyrl_vt100_h */
 /** @} tinyrl_vt100 */
 /** @} tinyrl_vt100 */

+ 3 - 5
tinyrl/vt100/private.h

@@ -1,8 +1,6 @@
 #include "tinyrl/vt100.h"
 #include "tinyrl/vt100.h"
 
 
-
+struct _tinyrl_vt100 {
-struct _tinyrl_vt100
+	FILE *istream;
-{
+	FILE *ostream;
-    FILE *istream;
-    FILE *ostream;   
 };
 };

+ 193 - 215
tinyrl/vt100/vt100.c

@@ -1,338 +1,316 @@
-#undef __STRICT_ANSI__ /* we need to use fileno() */
+#undef __STRICT_ANSI__		/* we need to use fileno() */
 #include <stdlib.h>
 #include <stdlib.h>
 # include <unistd.h>
 # include <unistd.h>
 # include <fcntl.h>
 # include <fcntl.h>
 
 
 #include "private.h"
 #include "private.h"
 
 
-typedef struct
+typedef struct {
-{
+	const char terminator;
-    const char            terminator;
+	tinyrl_vt100_escape_t code;
-    tinyrl_vt100_escape_t code;
 } vt100_decode_t;
 } vt100_decode_t;
 
 
 /* This table maps the vt100 escape codes to an enumeration */
 /* This table maps the vt100 escape codes to an enumeration */
-static vt100_decode_t cmds[] =
+static vt100_decode_t cmds[] = {
-{
+	{'A', tinyrl_vt100_CURSOR_UP},
-    {'A',    tinyrl_vt100_CURSOR_UP},
+	{'B', tinyrl_vt100_CURSOR_DOWN},
-    {'B',    tinyrl_vt100_CURSOR_DOWN},
+	{'C', tinyrl_vt100_CURSOR_RIGHT},
-    {'C',    tinyrl_vt100_CURSOR_RIGHT},
+	{'D', tinyrl_vt100_CURSOR_LEFT},
-    {'D',    tinyrl_vt100_CURSOR_LEFT},
 };
 };
+
 /*--------------------------------------------------------- */
 /*--------------------------------------------------------- */
-static void
+static void _tinyrl_vt100_setInputNonBlocking(const tinyrl_vt100_t * this)
-_tinyrl_vt100_setInputNonBlocking(const tinyrl_vt100_t *this)
 {
 {
 #if defined(STDIN_FILENO)
 #if defined(STDIN_FILENO)
-    int flags = (fcntl(STDIN_FILENO,F_GETFL,0) | O_NONBLOCK);
+	int flags = (fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK);
-    fcntl(STDIN_FILENO,F_SETFL,flags);
+	fcntl(STDIN_FILENO, F_SETFL, flags);
-#endif /* STDIN_FILENO */
+#endif				/* STDIN_FILENO */
 }
 }
+
 /*--------------------------------------------------------- */
 /*--------------------------------------------------------- */
-static void
+static void _tinyrl_vt100_setInputBlocking(const tinyrl_vt100_t * this)
-_tinyrl_vt100_setInputBlocking(const tinyrl_vt100_t *this)
 {
 {
 #if defined(STDIN_FILENO)
 #if defined(STDIN_FILENO)
-    int flags = (fcntl(STDIN_FILENO,F_GETFL,0) & ~O_NONBLOCK);
+	int flags = (fcntl(STDIN_FILENO, F_GETFL, 0) & ~O_NONBLOCK);
-    fcntl(STDIN_FILENO,F_SETFL,flags);
+	fcntl(STDIN_FILENO, F_SETFL, flags);
-#endif /* STDIN_FILENO */
+#endif				/* STDIN_FILENO */
 }
 }
+
 /*--------------------------------------------------------- */
 /*--------------------------------------------------------- */
-tinyrl_vt100_escape_t
+tinyrl_vt100_escape_t tinyrl_vt100_escape_decode(const tinyrl_vt100_t * this)
-tinyrl_vt100_escape_decode(const tinyrl_vt100_t *this)
+{
-{
+	tinyrl_vt100_escape_t result = tinyrl_vt100_UNKNOWN;
-    tinyrl_vt100_escape_t result = tinyrl_vt100_UNKNOWN;
+	char sequence[10], *p = sequence;
-    char                  sequence[10],*p=sequence;
+	int c;
-    int                   c;
+	unsigned i;
-    unsigned              i;
+	/* before the while loop, set the input as non-blocking */
-    /* before the while loop, set the input as non-blocking */
+	_tinyrl_vt100_setInputNonBlocking(this);
-    _tinyrl_vt100_setInputNonBlocking(this); 
+
-
+	/* dump the control sequence into our sequence buffer 
-    /* dump the control sequence into our sequence buffer 
+	 * ANSI standard control sequences will end 
-     * ANSI standard control sequences will end 
+	 * with a character between 64 - 126
-     * with a character between 64 - 126
+	 */
-     */
+	while (1) {
-    while(1)
+		c = getc(this->istream);
-    {
+
-        c = getc(this->istream);
+		/* ignore no-character condition */
-
+		if (-1 != c) {
-        /* ignore no-character condition */
+			*p++ = (c & 0xFF);
-        if(-1 != c)
+			if ((c != '[') && (c > 63)) {
-        {
+				/* this is an ANSI control sequence terminator code */
-            *p++ = (c & 0xFF);
+				result = tinyrl_vt100_CURSOR_UP;	/* just a non-UNKNOWN value */
-            if( (c != '[') && (c > 63) ) 
+				break;
-            {
+			}
-                /* this is an ANSI control sequence terminator code */
+		} else {
-                result = tinyrl_vt100_CURSOR_UP; /* just a non-UNKNOWN value */
+			result = tinyrl_vt100_UNKNOWN;
-                break;
+			break;
-            }
+		}
-        } else { 
+	}
-            result = tinyrl_vt100_UNKNOWN;
+	/* terminate the string (for debug purposes) */
-            break;
+	*p = '\0';
-        }
+
-    }
+	/* restore the blocking status */
-    /* terminate the string (for debug purposes) */
+	_tinyrl_vt100_setInputBlocking(this);
-    *p = '\0';
+
-    
+	if (tinyrl_vt100_UNKNOWN != result) {
-    /* restore the blocking status */
+		/* now decode the sequence */
-    _tinyrl_vt100_setInputBlocking(this);
+		for (i = 0; i < sizeof(cmds) / sizeof(vt100_decode_t); i++) {
-
+			if (cmds[i].terminator == c) {
-    if(tinyrl_vt100_UNKNOWN != result)
+				/* found the code in the lookup table */
-    {
+				result = cmds[i].code;
-        /* now decode the sequence */
+				break;
-        for(i = 0;
+			}
-            i < sizeof(cmds)/sizeof(vt100_decode_t);
+		}
-            i++)
+	}
-        {
+
-            if(cmds[i].terminator == c)
+	return result;
-            {
-                /* found the code in the lookup table */
-                result = cmds[i].code;
-                break;
-            }
-        }
-    }
-    
-    return result;
-}
-/*-------------------------------------------------------- */
-int 
-tinyrl_vt100_printf(const tinyrl_vt100_t *this,
-                    const char           *fmt,
-                    ...)
-{
-    va_list args;
-    int len;
-
-    va_start(args, fmt);
-    len = tinyrl_vt100_vprintf(this, fmt, args);
-    va_end(args);
-
-    return len;
 }
 }
 
 
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-int
+int tinyrl_vt100_printf(const tinyrl_vt100_t * this, const char *fmt, ...)
-tinyrl_vt100_vprintf(const tinyrl_vt100_t *this,
-                     const char           *fmt,
-                     va_list               args)
 {
 {
-    return vfprintf(this->ostream, fmt, args);
+	va_list args;
+	int len;
+
+	va_start(args, fmt);
+	len = tinyrl_vt100_vprintf(this, fmt, args);
+	va_end(args);
+
+	return len;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
 int
 int
-tinyrl_vt100_getchar(const tinyrl_vt100_t *this)
+tinyrl_vt100_vprintf(const tinyrl_vt100_t * this, const char *fmt, va_list args)
 {
 {
-    return getc(this->istream);
+	return vfprintf(this->ostream, fmt, args);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-int
+int tinyrl_vt100_getchar(const tinyrl_vt100_t * this)
-tinyrl_vt100_oflush(const tinyrl_vt100_t *this)
 {
 {
-    return fflush(this->ostream);
+	return getc(this->istream);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-int
+int tinyrl_vt100_oflush(const tinyrl_vt100_t * this)
-tinyrl_vt100_ierror(const tinyrl_vt100_t *this)
 {
 {
-    return ferror(this->istream);
+	return fflush(this->ostream);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-int
+int tinyrl_vt100_ierror(const tinyrl_vt100_t * this)
-tinyrl_vt100_oerror(const tinyrl_vt100_t *this)
 {
 {
-    return ferror(this->ostream);
+	return ferror(this->istream);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-int
+int tinyrl_vt100_oerror(const tinyrl_vt100_t * this)
-tinyrl_vt100_ieof(const tinyrl_vt100_t *this)
 {
 {
-    return feof(this->istream);
+	return ferror(this->ostream);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-int
+int tinyrl_vt100_ieof(const tinyrl_vt100_t * this)
-tinyrl_vt100_eof(const tinyrl_vt100_t *this)
 {
 {
-    return feof(this->istream);
+	return feof(this->istream);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-unsigned
+int tinyrl_vt100_eof(const tinyrl_vt100_t * this)
-tinyrl_vt100__get_width(const tinyrl_vt100_t *this)
 {
 {
-    this=this;
+	return feof(this->istream);
-    /* hard code until we suss out how to do it properly */
-    return 80;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-static void
+unsigned tinyrl_vt100__get_width(const tinyrl_vt100_t * this)
-tinyrl_vt100_init(tinyrl_vt100_t     *this,
-                  FILE               *istream,
-                  FILE               *ostream)
 {
 {
-    this->istream  = istream;
+	this = this;
-    this->ostream = ostream;
+	/* hard code until we suss out how to do it properly */
+	return 80;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
 static void
 static void
-tinyrl_vt100_fini(tinyrl_vt100_t *this)
+tinyrl_vt100_init(tinyrl_vt100_t * this, FILE * istream, FILE * ostream)
 {
 {
-    /* nothing to do yet... */
+	this->istream = istream;
-    this=this;
+	this->ostream = ostream;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-tinyrl_vt100_t *
+static void tinyrl_vt100_fini(tinyrl_vt100_t * this)
-tinyrl_vt100_new(FILE               *istream,
-                 FILE               *ostream)
 {
 {
-    tinyrl_vt100_t *this = NULL;
+	/* nothing to do yet... */
-    
+	this = this;
-    this = malloc(sizeof(tinyrl_vt100_t));
-    if(NULL != this)
-    {
-        tinyrl_vt100_init(this,istream,ostream);
-    }
-    
-    return this;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+tinyrl_vt100_t *tinyrl_vt100_new(FILE * istream, FILE * ostream)
-tinyrl_vt100_delete(tinyrl_vt100_t *this)
 {
 {
-    tinyrl_vt100_fini(this);
+	tinyrl_vt100_t *this = NULL;
-    /* release the memory */
+
-    free(this);
+	this = malloc(sizeof(tinyrl_vt100_t));
+	if (NULL != this) {
+		tinyrl_vt100_init(this, istream, ostream);
+	}
+
+	return this;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_delete(tinyrl_vt100_t * this)
-tinyrl_vt100_ding(const tinyrl_vt100_t *this)
 {
 {
-    tinyrl_vt100_printf(this,"%c",KEY_BEL);
+	tinyrl_vt100_fini(this);
-    (void)tinyrl_vt100_oflush(this);
+	/* release the memory */
+	free(this);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_ding(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_reset(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[0m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c", KEY_BEL);
+	(void)tinyrl_vt100_oflush(this);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_attribute_reset(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_bright(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[1m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[0m", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_attribute_bright(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_dim(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[2m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[1m", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_attribute_dim(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_underscore(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[4m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[2m", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_attribute_underscore(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_blink(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[5m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[4m", KEY_ESC);
 }
 }
+
+/*-------------------------------------------------------- */
+void tinyrl_vt100_attribute_blink(const tinyrl_vt100_t * this)
+{
+	tinyrl_vt100_printf(this, "%c[5m", KEY_ESC);
+}
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_attribute_reverse(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_reverse(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[7m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[7m", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_attribute_hidden(const tinyrl_vt100_t * this)
-tinyrl_vt100_attribute_hidden(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[8m",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[8m", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_erase_line(const tinyrl_vt100_t * this)
-tinyrl_vt100_erase_line(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[2K",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[2K", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_clear_screen(const tinyrl_vt100_t * this)
-tinyrl_vt100_clear_screen(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[2J",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[2J", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_save(const tinyrl_vt100_t * this)
-tinyrl_vt100_cursor_save(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c7",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c7", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_restore(const tinyrl_vt100_t * this)
-tinyrl_vt100_cursor_restore(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c8",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c8", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_forward(const tinyrl_vt100_t * this, unsigned count)
-tinyrl_vt100_cursor_forward(const tinyrl_vt100_t *this,
-                            unsigned              count)
 {
 {
-        tinyrl_vt100_printf(this,"%c[%dC",KEY_ESC,count);
+	tinyrl_vt100_printf(this, "%c[%dC", KEY_ESC, count);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_back(const tinyrl_vt100_t * this, unsigned count)
-tinyrl_vt100_cursor_back(const tinyrl_vt100_t *this,
-                         unsigned              count)
 {
 {
-        tinyrl_vt100_printf(this,"%c[%dD",KEY_ESC,count);
+	tinyrl_vt100_printf(this, "%c[%dD", KEY_ESC, count);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_up(const tinyrl_vt100_t * this, unsigned count)
-tinyrl_vt100_cursor_up(const tinyrl_vt100_t *this,
-                       unsigned              count)
 {
 {
-        tinyrl_vt100_printf(this,"%c[%dA",KEY_ESC,count);
+	tinyrl_vt100_printf(this, "%c[%dA", KEY_ESC, count);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_down(const tinyrl_vt100_t * this, unsigned count)
-tinyrl_vt100_cursor_down(const tinyrl_vt100_t *this,
-                         unsigned              count)
 {
 {
-        tinyrl_vt100_printf(this,"%c[%dB",KEY_ESC,count);
+	tinyrl_vt100_printf(this, "%c[%dB", KEY_ESC, count);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_cursor_home(const tinyrl_vt100_t * this)
-tinyrl_vt100_cursor_home(const tinyrl_vt100_t *this)
 {
 {
-        tinyrl_vt100_printf(this,"%c[H",KEY_ESC);
+	tinyrl_vt100_printf(this, "%c[H", KEY_ESC);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100_erase(const tinyrl_vt100_t * this, unsigned count)
-tinyrl_vt100_erase(const tinyrl_vt100_t *this,
-                   unsigned              count)
 {
 {
-        tinyrl_vt100_printf(this,"%c[%dP",KEY_ESC,count);
+	tinyrl_vt100_printf(this, "%c[%dP", KEY_ESC, count);
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-void
+void tinyrl_vt100__set_istream(tinyrl_vt100_t * this, FILE * istream)
-tinyrl_vt100__set_istream(tinyrl_vt100_t *this,
-                          FILE           *istream)
 {
 {
-        this->istream = istream;
+	this->istream = istream;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-FILE *
+FILE *tinyrl_vt100__get_istream(const tinyrl_vt100_t * this)
-tinyrl_vt100__get_istream(const tinyrl_vt100_t *this)
 {
 {
-        return this->istream;
+	return this->istream;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */
-FILE *
+FILE *tinyrl_vt100__get_ostream(const tinyrl_vt100_t * this)
-tinyrl_vt100__get_ostream(const tinyrl_vt100_t *this)
 {
 {
-        return this->ostream;
+	return this->ostream;
 }
 }
+
 /*-------------------------------------------------------- */
 /*-------------------------------------------------------- */

Some files were not shown because too many files changed in this diff