home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / c / curses / src / unctrl.c < prev    next >
Text File  |  1994-02-21  |  2KB  |  68 lines

  1. /* -*-C-*-
  2.  *
  3.  *
  4.  * Filename : SRC:lib/curses/src/unctrl.c
  5.  *
  6.  * Author   : Simon J Raybould.    (sie@fulcrum.co.uk).
  7.  *
  8.  * Date     : Wed Jan 20 23:24:03 1993
  9.  *
  10.  * Desc     : converts control caracters to printable sequences of the form
  11.  *            "^A" for control-A
  12.  *
  13.  *
  14.  * THIS CODE IS NOT PUBLIC DOMAIN
  15.  * ==============================
  16.  * 
  17.  * This code is copyright Simon J Raybould 1992, all rights are reserved.
  18.  * All code, ideas, data structures and algorithms remain the property of the
  19.  * author. Neither the whole nor sections of this code may be used as part
  20.  * of other code without the authors consent. If you wish to use some of this
  21.  * code then please email me at (sie@fulcrum.bt.co.uk).
  22.  *
  23.  * This source is not public domain, so you do not have any right to alter it
  24.  * or sell it for personal gain. The source is provided purely for reference
  25.  * purposes. You may re-compile the source with any compiler you choose.
  26.  * You must not distribute altered copies without the authors consent. My
  27.  * intention is that the source will help people isolate any bugs much more
  28.  * effectively.
  29.  *
  30.  * Disclaimer
  31.  * ==========
  32.  *
  33.  * No implication is made as to this code being fit for any purpose at all.
  34.  * I (the author) shall not be held responsible for any loss of data or damage 
  35.  * to property that may result from its use or misuse.
  36.  *
  37.  *
  38.  * Revision History
  39.  * ================
  40.  *
  41.  * $Log: unctrl.c,v $
  42.  * Revision 1.1  1993/05/17  23:33:10  sie
  43.  * Initial revision
  44.  *
  45.  *
  46.  */
  47.  
  48. #ifndef lint
  49. static char *rcsid = "$Header: /SRC/lib/curses/src/RCS/unctrl.c,v 1.1 1993/05/17 23:33:10 sie Exp $";
  50. #endif /* lint */
  51.  
  52.  
  53. char *
  54. unctrl(char ch)
  55. {
  56.   static char buf[3];           /* longest string is 2 chars + terminator */
  57.  
  58.   if(ch < 32) {
  59.     buf[0] = '^';
  60.     buf[1] = ch + '@';          /* control-@ is 0 in ASCII */
  61.     buf[2] = '\0';
  62.   } else {
  63.     buf[0] = ch;
  64.     buf[1] = '\0';
  65.   }
  66.   return buf;
  67. }
  68.