CVS: libraries/include/mspgcc util.h,1.1,1.2

Chris Liechti <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/libraries/include/mspgcc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27929/libraries/include/mspgcc

Modified Files:
	util.h 
Log Message:
- add string escape encode and decode functions
- fix fo hex_encode signature

Index: util.h
===================================================================
RCS file: /cvsroot/mspgcc/libraries/include/mspgcc/util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- util.h	22 Aug 2005 11:24:00 -0000	1.1
+++ util.h	13 Sep 2005 14:09:43 -0000	1.2
@@ -47,7 +47,7 @@
  * @param maxsize       available number of bytes in the output string
  * @param src           source string of hex digits
  * @param size          number of characters that should be decoded. this is an
- *                      even number as each hex encoded byte consists of two characters
+ *                      even number as each hex encoded byte consists of two characters.
  * @return              Number of binary bytes that got decoded. The return value
  *                      is equal to size on success, smaller if the dst buffer
  *                      was too small.
@@ -79,6 +79,46 @@
 
 
 /**
+ * Decode an escaped, null terminated string to a binary buffer.
+ *
+ * \n \r \t \a \b are output for the respecutve control characters, \xNN
+ * for control characters. unlike C's escape rules \xNN uses exactly two digits
+ * the next character does not belong to the number even if it is a hex digit.
+ *
+ * dst == src is allowed to decode the string inline. This is possible as
+ * the string with escapes is of the same length or longer than the resulting
+ * binary buffer data.
+ *
+ * @param dst           the resulting binary
+ * @param maxsize       available number of bytes in the output buffer dst
+ * @param src           source string with escapes
+ * @param size          number of characters that should be decoded. this is an
+ * @return              Number of characters in the dst buffer
+ *                      The return value is equal to size on success, smaller
+ *                      if the dst buffer was too small.
+ */
+unsigned int escape_decode(void *dst, unsigned int maxsize, const char *src);
+
+/**
+ * Encode an binary buffer to a escaped string.
+ *
+ * \n \r \t \a \b are output for the respecitve control characters, \xNN
+ * for control characters. unlike C's escape rules \xNN generates two digits
+ * the next character does not belong to the number even if it is a hex digit.
+ *
+ * @param dst           the resulting null terminated string
+ * @param maxsize       available number of bytes in the output string dst
+ * @param src           source (binary) string
+ * @param size          number of characters that should be encoded.
+ * @return              Number of characters in the dst buffer
+ *                      The return value is equal to size on success, smaller
+ *                      if the dst buffer was too small.
+ */
+unsigned int escape_encode(char *dst, unsigned int maxsize, const void *src, unsigned int size);
+
+
+
+/**
  * Simple line reader. Reads with getchar(), prcoesses with 
  * ::lineeditor_simple_process_key
  *



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.