Test for ticket system bug #14.
[bertos.git] / mware / readline.c
old mode 100755 (executable)
new mode 100644 (file)
index 86c1dfd..a8a9281
@@ -1,6 +1,31 @@
-/*!
+/**
  * \file
  * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction.  Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License.  This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
  * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
  * Copyright 2004 Giovanni Bajo
  * All Rights Reserved.
  * \author Giovanni Bajo <rasky@develer.com>
  */
 
-/*#*
- *#* $Log$
- *#* Revision 1.1  2006/06/01 12:27:39  marco
- *#* Added utilities for protocols
- *#*
- *#*/
 
 #include "readline.h"
 
 #include <stdio.h>
 
 
-//! Enable compilation of the unit test code
+/// Enable compilation of the unit test code
 #define DEBUG_UNIT_TEST       0
 
-//! Enable dump of the history after each line
+/// Enable dump of the history after each line
 #define DEBUG_DUMP_HISTORY    0
 
 
-/*! Special keys (escape sequences converted to a single code) */
+/** Special keys (escape sequences converted to a single code) */
 enum RL_KEYS {
        SPECIAL_KEYS = 0x1000,
 
@@ -117,12 +136,12 @@ enum RL_KEYS {
        KEY_F10, KEY_F11, KEY_F12,
 };
 
-/*! Check if \a c is a separator between words.
+/** Check if \a c is a separator between words.
  *  \note Parameter \a c is evaluated multiple times
  */
 #define IS_WORD_SEPARATOR(c) ((c) == ' ' || (c) == '\0')
 
-//! Write the string \a txt to the IO output (without any kind of termination)
+/// Write the string \a txt to the IO output (without any kind of termination)
 INLINE void rl_puts(const struct RLContext* ctx, const char* txt)
 {
        if (!ctx->put)
@@ -132,14 +151,14 @@ INLINE void rl_puts(const struct RLContext* ctx, const char* txt)
                ctx->put(*txt++, ctx->put_param);
 }
 
-//! Write character \a ch to the IO output.
+/// Write character \a ch to the IO output.
 INLINE void rl_putc(const struct RLContext* ctx, char ch)
 {
        if (ctx->put)
                ctx->put(ch, ctx->put_param);
 }
 
-/*! Read a character from the IO into \a ch. This function also takes
+/** Read a character from the IO into \a ch. This function also takes
  *  care of converting the ANSI escape sequences into one of the codes
  *  defined in \c RL_KEYS.
  */
@@ -226,19 +245,19 @@ static bool pop_history(struct RLContext* ctx, int total_len)
        return true;
 }
 
-//! Check if index \a i points to the begin of the history.
+/// Check if index \a i points to the begin of the history.
 INLINE bool is_history_begin(struct RLContext* ctx, int i)
 { return ctx->history + i == ctx->real_history; }
 
-//! Check if index \a i points to the (exclusive) end of history
+/// Check if index \a i points to the (exclusive) end of history
 INLINE bool is_history_end(struct RLContext* ctx, int i)
 { return ctx->history + i == ctx->real_history + HISTORY_SIZE; }
 
-//! Check if index \a i points to the (exclusive) end of history, or somewhere past the end.
+/// Check if index \a i points to the (exclusive) end of history, or somewhere past the end.
 INLINE bool is_history_past_end(struct RLContext* ctx, int i)
 { return ctx->history + i >= ctx->real_history + HISTORY_SIZE; }
 
-/*! Insert \a num_chars characters from \a ch into the history buffer at the
+/** Insert \a num_chars characters from \a ch into the history buffer at the
  *  position indicated by \a curpos. If needed, remove old history to make room.
  *  Returns true if everything was successful, false if there was no room to
  *  add the characters.
@@ -263,14 +282,14 @@ static bool insert_chars(struct RLContext* ctx, size_t *curpos, const char* ch,
        return true;
 }
 
-//! Insert a single character \a ch into the buffer (with the same semantic of \c insert_chars())
+/// Insert a single character \a ch into the buffer (with the same semantic of \c insert_chars())
 static bool insert_char(struct RLContext* ctx, size_t *curpos, char ch)
 {
        return insert_chars(ctx, curpos, &ch, 1);
 }
 
 #if DEBUG_DUMP_HISTORY
-//! Dump the internal history of a context (used only for debug purposes)
+/// Dump the internal history of a context (used only for debug purposes)
 static void dump_history(struct RLContext* ctx)
 {
        int k;
@@ -291,7 +310,7 @@ static void dump_history(struct RLContext* ctx)
 }
 #endif /* DEBUG_DUMP_HISTORY */
 
-//! Complete the current word. Return false if no unambiguous completion was found
+/// Complete the current word. Return false if no unambiguous completion was found
 static bool complete_word(struct RLContext *ctx, size_t *curpos)
 {
        const char* completed_word;
@@ -420,7 +439,7 @@ const char* rl_readline(struct RLContext* ctx)
 
 #if DEBUG_UNIT_TEST
 
-/*! Perform the unit test for the readline library */
+/** Perform the unit test for the readline library */
 void rl_test(void);
 
 #if HISTORY_SIZE != 32
@@ -435,7 +454,7 @@ static int test_getc(void* data)
        return *test_getc_ptr++;
 }
 
-/*! Perform a readline test. The function pipes the characters from \a input_buffer
+/** Perform a readline test. The function pipes the characters from \a input_buffer
  *  through the I/O to \c rl_readline(). After the whole string is sent, \c do_test()
  *  checks if the current history within the context match \a expected_history.
  */