home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / utils / sercli.shr / sercli / src / rcs / misc.c,v < prev    next >
Encoding:
Text File  |  1993-06-16  |  3.4 KB  |  243 lines

  1. head    1.5;
  2. access;
  3. symbols
  4.     sercli_v1_10:1.5
  5.     sercli_v1_9:1.4
  6.     sercli_v1_8:1.4
  7.     sercli_v1_7:1.3
  8.     sercli_v1_6:1.2
  9.     sercli_v1_5:1.1;
  10. locks
  11.     rkr:1.5;
  12. comment    @**  @;
  13.  
  14.  
  15. 1.5
  16. date    93.06.16.23.27.57;    author rkr;    state Exp;
  17. branches;
  18. next    1.4;
  19.  
  20. 1.4
  21. date    91.12.20.09.43.36;    author rkr;    state Exp;
  22. branches;
  23. next    1.3;
  24.  
  25. 1.3
  26. date    91.12.10.02.48.02;    author rkr;    state Exp;
  27. branches;
  28. next    1.2;
  29.  
  30. 1.2
  31. date    91.12.02.10.51.20;    author rkr;    state Exp;
  32. branches;
  33. next    1.1;
  34.  
  35. 1.1
  36. date    91.11.28.08.25.11;    author rkr;    state Exp;
  37. branches;
  38. next    ;
  39.  
  40.  
  41. desc
  42. @sercli is a program to permit shell-like interface to the serial port,
  43. while also permitting easy config- and run-time-control over the way the
  44. serial port (or even _which_ serial port) is used.
  45.  
  46. @
  47.  
  48.  
  49. 1.5
  50. log
  51. @Commented on do_nothing()'s existance (be still my beating heart!).
  52. @
  53. text
  54. @/*
  55. **  $Source: WB_2.1:ho/rcs/misc.c,v $
  56. **  $Author: rkr $
  57. **  $Revision: 1.4 $
  58. **  $Locker:  $
  59. **  $State: Exp $
  60. **  $Date: 1991/12/20 09:43:36 $
  61. **
  62. */
  63.  
  64. #include <exec/io.h>
  65. #include <clib/exec_protos.h>
  66.  
  67. #include <ctype.h>
  68. #include <stdio.h>
  69. #include <stdlib.h>
  70.  
  71. #include "defs.h"
  72. #include "ser_supp.h"
  73. #include "misc.h"
  74.  
  75.  
  76.  
  77. /*
  78. **  Borrowed from Mike Oliphant's usenet posting...(and renamed)
  79. **
  80. **  This will safely abort IO requests pending...
  81. **
  82. **  Unlike the regular AbortIO(), and the NiceAbort() from Mike,
  83. **  SafeAbortIO() can even 'abort' an IO request that hasn't been sent
  84. **  yet...this makes it convenient for general cleanup.
  85. **
  86. */
  87. void SafeAbortIO (IO_Request *ior)
  88. {
  89.     Forbid ();
  90.     {
  91.     if (!CheckIO (ior) )
  92.     {
  93.         AbortIO (ior);
  94.         WaitIO (ior);
  95.     }
  96.     }
  97.     Permit ();
  98. }
  99.  
  100.  
  101.  
  102. /*
  103. **  A bit like fgets(), EXCEPT:
  104. **    does not preserve the end-of-line
  105. **    malloc()s the line (and free()s the previous line, if need be).
  106. **
  107. */
  108. char *get_line (FILE *file)
  109. {
  110.     static char *line = 0;
  111.     int c;
  112.     int count;
  113.     long start_pos;
  114.  
  115.     if (line)
  116.     {
  117.     free (line);
  118.     line = 0;
  119.     }
  120.  
  121.     start_pos = ftell (file);
  122.     count = 0;
  123.     do
  124.     {
  125.     ++count;
  126.     c = fgetc (file);
  127.     }
  128.     while ( (c != '\n') && (c != EOF) );
  129.  
  130.     if ( (c != EOF) || (count != 1) )
  131.     {
  132.     line = malloc (count);
  133.     fseek (file, start_pos, SEEK_SET);
  134.     fread (line, 1, count, file);
  135.     line [count - 1] = 0;
  136.     }
  137.     return (line);
  138. }
  139.  
  140.  
  141. /*
  142. **  Stub function for some function call-backs.  E.g.,
  143. **    onbreak (do_nothing);
  144. **
  145. */
  146. int do_nothing (void)
  147. {
  148.     return (0);
  149. }
  150.  
  151.  
  152.  
  153. /*
  154. **  I _think_ this came from the remcli.c that came with fifo:.
  155. **
  156. **  I don't know if it's generally legal to use {.ln_Type} as a flag.  I
  157. **  need to check out remcli.c, as this may've been a peculiarity of the
  158. **  fifo handling of messages, rather than something profound.    It
  159. **  certainly looks odd.
  160. **
  161. **  (Could just test the effects of ReplyMsg() in general...)
  162. **
  163. */
  164. void WaitMsg (Message *msg)
  165. {
  166.     while (msg->mn_Node.ln_Type == NT_MESSAGE)
  167.     Wait (1 << msg->mn_ReplyPort->mp_SigBit);
  168.  
  169.     Forbid ();
  170.     {
  171.     Remove (&msg->mn_Node);
  172.     }
  173.     Permit ();
  174. }
  175.  
  176. @
  177.  
  178.  
  179. 1.4
  180. log
  181. @*** empty log message ***
  182. @
  183. text
  184. @d2 1
  185. a2 1
  186. **  $Source: Workbench:personal/rkr/prog/sercli/src/rcs/misc.c,v $
  187. d4 2
  188. a5 2
  189. **  $Revision: 1.3 $
  190. **  $Locker: rkr $
  191. d7 1
  192. a7 1
  193. **  $Date: 91/12/10 02:48:02 $
  194. a50 1
  195. **
  196. a51 1
  197. **
  198. d88 5
  199. a92 1
  200.  
  201. @
  202.  
  203.  
  204. 1.3
  205. log
  206. @*** empty log message ***
  207. @
  208. text
  209. @d4 1
  210. a4 1
  211. **  $Revision: 1.2 $
  212. d7 1
  213. a7 1
  214. **  $Date: 91/12/02 10:51:20 $
  215. @
  216.  
  217.  
  218. 1.2
  219. log
  220. @*** empty log message ***
  221. @
  222. text
  223. @d7 1
  224. a7 1
  225. **  $Date: 91/12/02 10:41:57 $
  226. @
  227.  
  228.  
  229. 1.1
  230. log
  231. @Initial revision
  232. @
  233. text
  234. @d2 6
  235. a7 6
  236. **  $Source$
  237. **  $Author$
  238. **  $Revision$
  239. **  $Locker$
  240. **  $State$
  241. **  $Date$
  242. @
  243.