home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 344_01 / cirque.doc < prev    next >
Text File  |  1991-03-05  |  2KB  |  67 lines

  1. File on the enclosed disk:
  2.    cirque.c
  3.    cirqtest.c
  4.    cirque.doc
  5.  
  6. Conrad Thornton
  7. RR1 Box 87C
  8. Downsville,La. 71234
  9. (318)982 5201
  10.  
  11. Usage:
  12.  
  13. This code is for a circular queue of any size
  14. and any data type.
  15. It can be used for event trapping........ect
  16.  
  17. It stores 2 items for each record.
  18.    (1) The 1st byte of a record is user-data-type.
  19.        This type number is user supplied.
  20.     ( should be min 1 to max 100 ? ).
  21.        When a record is read from the queue, this type
  22.        controls how you use the pointer. (see cirqtest.c)
  23.    (2) A char * to a memory address returned from malloc.
  24. ----------------------------------------------------------
  25. Defines:
  26.  
  27. ITEMSIZE  will equal 3 or 5 depending on sizeof(char *);
  28. return codes:
  29. ITSOK      0
  30. ERROR     -1
  31. QUEFULL  -2
  32. QUEEMPTY -3
  33. ----------------------------------------------------
  34. functions:
  35.  
  36. int setupque(int)
  37. Set up the queue of size (arg).
  38. Quesize in bytes is (int arg * ITEMSIZE + 1).
  39. Returns ITSOK (0) or ERROR (-1)
  40. ---------------------------------------
  41. int quewrite(char *,int)
  42. Write "type" and "data" (ITEMSIZE) to the queue.
  43. Returns ITSOK (0) on success.
  44. Returns QUEFULL (-2) if cannot write.
  45. ---------------------------------------
  46. int queovwrite(char *,int)
  47. Same basic fun as quewrite() Execpt it will over-write
  48. existing records.
  49. Return values ITSOK (0) or ERROR (-1) ONLY.
  50. NOTE: If this function is used, and it must overwrite
  51.       an existing record for needed space, IT FREES
  52.       THE PREVIOUS MALLOC FOR THE DATA-AREA THAT IS
  53.       BEING OVERWRITTEN.
  54. ---------------------------------------
  55. int queread(char **,int *)
  56. Read a record from the queue.
  57. NOTE: Send the address of users char *.
  58.       The record (address) will be copied to the char *.
  59.       The pointer can then be used as usual.
  60. The record type (users type) will be assigned to int *.
  61. Returns ITSOK (0) or QUEEMPTY (-3).
  62. ---------------------------------------
  63. int quekill(void)
  64. Free previous malloc for "cir_que" string.
  65. NOTE: Returns ERROR (-1) if  itemsinque is true.
  66. ---------------------------------------
  67.