home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ADVC12.ZIP / ADVC.DOC next >
Encoding:
Text File  |  1991-11-10  |  13.8 KB  |  635 lines

  1.                               ADVC v1.2, 11/10/91
  2.                              Advanced C Functions
  3.  
  4.                   Copyright (c) Thomas Hanlin III, 1987-1991
  5.  
  6.                           3544 E. Southern Ave. #104
  7.                                 Mesa, AZ 85204
  8.  
  9.  
  10.  Note: This was previously a shareware library.  It was introduced in 1987.
  11.  I looked at it recently, expecting a good chuckle... but to my surprise, it
  12.  has some fairly nice stuff in it.  So, I'm taking this opportunity to make
  13.  it available for free to anyone who may be interested.  Aside from some
  14.  minor updates to the manual, no changes have been made.  I hope it proves of
  15.  use to someone.
  16.  
  17.      These  routines  may  be  freely  distributed, provided that all files are
  18.  included  intact  and unmodified.  A distribution/handling fee of no more than
  19.  $10 may be charged.
  20.  
  21.      The  ADVC  routines  have been tested and appear to be bug-free.  However,
  22.  I can't guarantee as to whether they will work as advertised on your computer,
  23.  using  your  compiler.    Powerful  low-level access techniques are used which
  24.  could  conceivably  cause  havoc  on the wrong machines or wrong compilers, or
  25.  if  you  don't  use  them  properly.  Be warned, and don't use ADVC unless you
  26.  know what you're doing!
  27.  
  28.      The ADVC routines are grouped in files according to their type: Equipment,
  29.  Input,  Misc,  String,  Video.    In  order to use a routine, you will have to
  30.  extract it from the appropriate file using an editor.
  31.  
  32.      You are responsible for setting up any "include" files which may be neces-
  33.  sary for any given routine that you use in your program.
  34.  
  35.      These  routines  have been tested using Microsoft C, version 4.0.  A large
  36.  number  of  the  functions  provide  low-level  access  to  the machine, which
  37.  requires  use  of  nonportable  code.   You will have to convert these to your
  38.  compiler if you use something other than Microsoft C.
  39.  
  40.      These  routines  are  intended  as  a supplemental C library for folks who
  41.  have  some  idea  what  they're  doing.  They are not designed with the novice
  42.  in  mind.   If  you  don't  understand  how to use the functions, you probably
  43.  shouldn't attempt to use them just yet!
  44.  
  45.      Notation: Routines  are  labeled  "Generic"  if they will work on with any
  46.  C  compiler  on any machine.  Routines are labeled "MS C" if they use features
  47.  specific to Microsoft C and/or the IBM PC environment.
  48.  
  49.  Name: ANY2DEC
  50.  
  51.  Type: String / Generic
  52.  
  53.  Description:
  54.      Converts  a  number  in  string form, in any base (2-35), into an unsigned
  55.  integer.    No  checking  for  validity is done-- characters are assumed to be
  56.  within  the  proper  range  for  the base chosen, and the number as a whole is
  57.  assumed to be within unsigned integer range.
  58.  
  59.  Usage:
  60.      include <string.h>
  61.      int any2dec(str,base)
  62.          char *str;
  63.          unsigned int base;
  64.  
  65.  
  66.  
  67.  
  68.  Name: BSQUEEZE
  69.  
  70.  Type: String / Generic
  71.  
  72.  Description:
  73.      Squeezes  a  string  by  replacing  blanks  with a code sequence.  Assumes
  74.  an  input  string  which  only  uses normal ASCII (1-127) codes, with a length
  75.  of  less  than  127  characters.   Outputs a string which may include extended
  76.  ASCII  codes  (128-255).    Typical  space  savings for text is 15%.  A static
  77.  buffer  is  used,  so the result will be overwritten on subsequent calls.  See
  78.  also BUNSQUEEZE (not as bad as it sounds!).
  79.  
  80.  Usage:
  81.      unsigned char *bsqueeze(str)
  82.         unsigned char *str;
  83.  
  84.  Oddities:
  85.      May  not  be  entirely  generic,  as it assumes a useable character set of
  86.  at least 256 characters.
  87.  
  88.  Name: BUNSQUEEZE
  89.  
  90.  Type: String / Generic
  91.  
  92.  Description:
  93.      Unsqueezes  a  string  which was squeezed with BSQUEEZE.  Assumes an input
  94.  string  with  a  length of less than 127 characters.  A static buffer is used,
  95.  so the result will be overwritten on subsequent calls.
  96.  
  97.  Usage:
  98.      unsigned char *bunsqueeze(str)
  99.         unsigned char *str;
  100.  
  101.  Oddities:
  102.      May  not  be  entirely  generic,  as  it  assumes  a useable character set
  103.  comprised of 256 characters.
  104.  
  105.  
  106.  
  107.  
  108.  Name: BKSCROLL
  109.  
  110.  Type: Video / MS C
  111.  
  112.  Description:
  113.      Scrolls  an  area  of  the  screen down by a specified number of lines, or
  114.  clears  it entirely if you specify zero lines.  The screen area to be scrolled
  115.  is defined by its upper left and lower right corners.
  116.  
  117.  Usage:
  118.      #include <dos.h>
  119.      void bkscroll(leftcol,toprow,rightcol,bottomrow,lines)
  120.          int leftcol, toprow, rightcol, bottomrow, lines;
  121.  
  122.  Oddities:
  123.      Uses the BIOS video interrupts.
  124.  
  125.  
  126.  
  127.  
  128.  Name: CLREOL
  129.  
  130.  Type: Video / MS C
  131.  
  132.  Description:
  133.      Clears from the current cursor position to the end of line.
  134.  
  135.  Usage:
  136.       #include <dos.h>
  137.       void clreol()
  138.  
  139.  Oddities:
  140.      Uses the BIOS video interrupts.
  141.  
  142.  Name: COMMPORTS
  143.  
  144.  Type: Equipment / MS C
  145.  
  146.  Description:
  147.      Returns the number of communications (serial) ports that are installed.
  148.  
  149.  Usage:
  150.      #include <dos.h>
  151.      int commports()
  152.  
  153.  Oddities:
  154.      Uses a BIOS interrupt.
  155.  
  156.  
  157.  
  158.  
  159.  Name: DEC2ANY
  160.  
  161.  Type: String / Generic
  162.  
  163.  Description:
  164.      This  function  converts  an  unsigned integer into an ASCII string in the
  165.  base  of  your  choice  (2-35).    It uses a static buffer, so the result will
  166.  be overwritten on subsequent calls.
  167.  
  168.  Usage:
  169.       char *dec2any(number,base)
  170.          unsigned int number, base;
  171.  
  172.  
  173.  
  174.  
  175.  Name: DELAY
  176.  
  177.  Type: Miscellaneous / MS C
  178.  
  179.  Description:
  180.      Delays for a given number of seconds.
  181.  
  182.  Usage:
  183.       #include <stddef.h>
  184.       #include <time.h>
  185.       void delay(seconds)
  186.          unsigned int seconds;
  187.  
  188.  Oddities:
  189.      Uses  a  time  function  specific to Microsoft C, which returns the GMT as
  190.  a number of seconds.
  191.  
  192.  Name: DISPLAYTYPE
  193.  
  194.  Type: Video / MS C
  195.  
  196.  Description:
  197.      Returns the type of the current display: 0 = mono, 1 = color.
  198.  
  199.  Usage:
  200.      #include <dos.h>
  201.      int displaytype()
  202.  
  203.  Oddities:
  204.      Uses a BIOS video interrupt.
  205.  
  206.  
  207.  
  208.  
  209.  Name: DRIVESPACE
  210.  
  211.  Type: Equipment / MS C
  212.  
  213.  Description:
  214.      Returns  the  amount  of  free space left on a given disk drive, in bytes.
  215.  Specify the drive by its letter, or use '@' for the default drive.
  216.  
  217.  Usage:
  218.      #include <ctype.h>
  219.      #include <dos.h>
  220.  
  221.  Oddities:
  222.      Uses a DOS interrupt.
  223.  
  224.  
  225.  
  226.  
  227.  Name: EXTRACT
  228.  
  229.  Type: String / Generic
  230.  
  231.  Description:
  232.      Extracts  a  delimited  substring  from a string.  Substrings are numbered
  233.  starting at one, and may not be over 80 characters in length.  A static buffer
  234.  is used for the substring, so save results if need be before the next use.
  235.  
  236.  Example usage:
  237.      extract("John Doe=1919 Main St=Springfield IL 12345",'=',2)
  238.  would  return  the  second  substring  delimited  by an equal sign, or in this
  239.  case "1919 Main St".
  240.  
  241.  Usage:
  242.       char *extract(str,delimiter,elementnumber)
  243.          char *str, delimiter;
  244.          int elementnumber;
  245.  
  246.  Name: GETDRIVE
  247.  
  248.  Type: Equipment / MS C
  249.  
  250.  Description:
  251.      Returns the current default disk drive.
  252.  
  253.  Usage:
  254.       #include <dos.h>
  255.       char getdrive()
  256.  
  257.  Oddities:
  258.      Uses a DOS interrupt.
  259.  
  260.  Name: GETKEY
  261.  
  262.  Type: Input / MS C
  263.  
  264.  Description:
  265.      Waits  for  one  of  a list of keys to be pressed, and returns the pressed
  266.  key.    The  list  of  valid  keys must be in uppercase; the returned key will
  267.  always  be  converted  to  uppercase.  If the list of valid keys is null, then
  268.  the first key pressed will be returned.
  269.  
  270.  Usage:
  271.       #include <conio.h>
  272.       #include <ctype.h>
  273.       char getkey(str)
  274.          char *str;
  275.  
  276.  Oddities:
  277.      Uses  unbuffered  input  to  get  a  key as soon as it's pressed.  This is
  278.  a common but nonstandard function.
  279.  
  280.  
  281.  
  282.  
  283.  Name: JOYSTICK
  284.  
  285.  Type: Equipment / MS C
  286.  
  287.  Description:
  288.      Returns the number of joystick ports installed (0-1).
  289.  
  290.  Usage:
  291.       #include <dos.h>
  292.       int joystick()
  293.  
  294.  Oddities:
  295.      Uses a BIOS interrupt.
  296.  
  297.  
  298.  
  299.  
  300.  Name: LIMMFREE
  301.  
  302.  Type: Equipment / MS C
  303.  
  304.  Description:
  305.      Returns  the  number  of free pages of installed LIM-spec expanded memory.
  306.  One page is 16k bytes.
  307.  
  308.  Usage:
  309.       #include <dos.h>
  310.       int limmfree()
  311.  
  312.  Oddities:
  313.      Uses a weird interrupt.
  314.  
  315.  Name: LIMMTOTAL
  316.  
  317.  Type: Equipment / MS C
  318.  
  319.  Description:
  320.      Returns  the  total number of installed pages of LIM-spec expanded memory.
  321.  One page is 16k bytes.
  322.  
  323.  Usage:
  324.       #include <dos.h>
  325.       int limmtotal()
  326.  
  327.  Oddities:
  328.      Uses a weird interrupt.
  329.  
  330.  
  331.  
  332.  
  333.  Name: LOCASE
  334.  
  335.  Type: String / Generic
  336.  
  337.  Description:
  338.      Convert a string to lowercase.
  339.  
  340.  Usage:
  341.       #include <ctype.h>
  342.       char *locase(str)
  343.          char *str;
  344.  
  345.  
  346.  
  347.  
  348.  Name: MOUSEBUTTONS
  349.  
  350.  Type: Input / MS C
  351.  
  352.  Description:
  353.      See if mouse buttons are pressed.  The result is returned as follows:
  354.   0: no button pressed
  355.   1: left button is pressed
  356.   2: right button is pressed
  357.   3: both buttons are pressed
  358.  
  359.  Usage:
  360.       #include <dos.h>
  361.       int mousebuttons()
  362.  
  363.  Oddities:
  364.      Uses a weird interrupt.
  365.  
  366.  Name: MOUSECHECK
  367.  
  368.  Type: Input / MS C
  369.  
  370.  Description:
  371.      Sees  if  a  mouse  is  installed.  If not, zero will be returned.  If so,
  372.  the  mouse  is  initialized,  and  the number of buttons the mouse has will be
  373.  returned.
  374.  
  375.  Usage:
  376.       #include <dos.h>
  377.       int mousecheck()
  378.  
  379.  Oddities:
  380.      Uses a weird interrupt.
  381.  
  382.  
  383.  
  384.  
  385.  Name: MOUSECLICK
  386.  
  387.  Type: Input / MS C
  388.  
  389.  Description:
  390.      Tells  you  if  a  mouse  button  has been clicked since you last checked.
  391.  The values returned are the same as for MOUSEBUTTONS.
  392.  
  393.  Usage:
  394.       #include <dos.h>
  395.       int mouseclick
  396.  
  397.  Oddities:
  398.      Uses a weird interrupt.
  399.  
  400.  
  401.  
  402.  
  403.  Name: MOUSECOL
  404.  
  405.  Type: Input / MS C
  406.  
  407.  Description:
  408.      Returns  the  column  where  the  mouse  cursor  is located.  See the file
  409.  MOUSE.TXT for more information (important!).
  410.  
  411.  Usage:
  412.       #include <dos.h>
  413.       int mousecol()
  414.  
  415.  Oddities:
  416.      Uses a weird interrupt.
  417.  
  418.  Name: MOUSECURSOR
  419.  
  420.  Type: Input / MS C
  421.  
  422.  Description:
  423.      Makes  the mouse cursor visible or invisible.  Use zero to turn the cursor
  424.  off, nonzero to turn it back on.
  425.  
  426.  Usage:
  427.       #include <dos.h>
  428.       void mousecursor(toggle)
  429.          int toggle;
  430.  
  431.  Oddities:
  432.      Uses a weird interrupt.
  433.  
  434.  
  435.  
  436.  
  437.  Name: MOUSELOC
  438.  
  439.  Type: Input / MS C
  440.  
  441.  Description:
  442.      Sets  the  location  of the mouse cursor.  See the file MOUSE.TXT for more
  443.  information (important!).
  444.  
  445.  Usage:
  446.       #include <dos.h>
  447.       void mouseloc(column,row)
  448.          int column, row;
  449.  
  450.  Oddities:
  451.      Uses a weird interrupt.
  452.  
  453.  
  454.  
  455.  
  456.  Name: MOUSEROW
  457.  
  458.  Type: Input / MS C
  459.  
  460.  Description:
  461.      Returns the row where the mouse cursor is located.  See the file MOUSE.TXT
  462.  for more information (important!).
  463.  
  464.  Usage:
  465.       #include <dos.h>
  466.       int mouserow()
  467.  
  468.  Oddities:
  469.      Uses a weird interrupt.
  470.  
  471.  Name: MULTIAND
  472.  
  473.  Type: String / Generic
  474.  
  475.  Description:
  476.      Performs  an  AND  on each character of a string with a given value.  Note
  477.  that if this results in a NUL, your string may be prematurely terminated!
  478.  
  479.  Usage:
  480.       char *multiand(str,c)
  481.          char *str, c;
  482.  
  483.  
  484.  
  485.  
  486.  Name: MULTIOR
  487.  
  488.  Type: String / Generic
  489.  
  490.  Description:
  491.      Performs an OR on each character of a string with a given value.
  492.  
  493.  Usage:
  494.       char *multior(str,c)
  495.          char *str, c;
  496.  
  497.  
  498.  
  499.  
  500.  Name: MULTIXOR
  501.  
  502.  Type: String / Generic
  503.  
  504.  Description:
  505.      Performs  an  XOR  on each character of a string with a given value.  Note
  506.  that if this results in a NUL, your string may be prematurely terminated!
  507.  
  508.  Usage:
  509.       char *multixor(str,c)
  510.          char *str, c;
  511.  
  512.  Name: PRINTPORTS
  513.  
  514.  Type: Equipment / MS C
  515.  
  516.  Description:
  517.      Returns the number of printer (parallel) ports installed.
  518.  
  519.  Usage:
  520.       #include <dos.h>
  521.       int printports()
  522.  
  523.  Oddities:
  524.      Uses a BIOS call.
  525.  
  526.  
  527.  
  528.  
  529.  Name: REVERSE
  530.  
  531.  Type: String / Generic
  532.  
  533.  Description:
  534.      Reverses the order of characters in a string.
  535.  
  536.  Usage:
  537.       #include <string.h>
  538.       char *reverse(str)
  539.          char *str;
  540.  
  541.  
  542.  
  543.  
  544.  Name: SCROLL
  545.  
  546.  Type: Video / MS C
  547.  
  548.  Description:
  549.      Scrolls an area of the screen up by a specified number of lines, or clears
  550.  it  entirely  if  you  specify  zero lines.  The screen area to be scrolled is
  551.  defined by its upper left and lower right corners.
  552.  
  553.  Usage:
  554.      #include <dos.h>
  555.      void scroll(leftcol,toprow,rightcol,bottomrow,lines)
  556.         int leftcol, toprow, rightcol, bottomrow, lines;
  557.  
  558.  Oddities:
  559.      Uses BIOS video interrupts.
  560.  
  561.  Name: SOUNDEX
  562.  
  563.  Type: String / Generic
  564.  
  565.  Description:
  566.      Returns a "soundex" code for a string.  This code is based on an algorithm
  567.  for  determining  words  that  sound  alike, and can be used (for instance) to
  568.  index  a  phone directory by names that sound/look similar.  The code returned
  569.  will  be  up to 80 characters long, but never longer than the string for which
  570.  the  code  was  generated.   A static buffer is used, so save the code if need
  571.  be before calling the routine a second time.
  572.  
  573.  Usage:
  574.       #include <ctype.h>
  575.       char *soundex(str)
  576.          char *str;
  577.  
  578.  
  579.  
  580.  
  581.  Name: STRIP
  582.  
  583.  Type: String / Generic
  584.  
  585.  Description:
  586.      Strips all occurrences of a given character from a given string.
  587.  
  588.  Usage:
  589.       char *strip(str,c)
  590.          char *str, c;
  591.  
  592.  
  593.  
  594.  
  595.  Name: STRIPRANGE
  596.  
  597.  Type: String / Generic
  598.  
  599.  Description:
  600.      Strips all characters in a given inclusive range from a given string.
  601.  
  602.  Usage:
  603.       char *striprange(str,lowchr,highchr)
  604.          char *str, lowchr, highchr;
  605.  
  606.  Name: TOTALMEM
  607.  
  608.  Type: Equipment / MS C
  609.  
  610.  Description:
  611.      Returns the total amount of installed memory, in kilobytes.
  612.  
  613.  Usage:
  614.       #include <dos.h>
  615.       int totalmem()
  616.  
  617.  Oddities:
  618.      Uses a BIOS interrupt.
  619.  
  620.  
  621.  
  622.  
  623.  Name: UPCASE
  624.  
  625.  Type: String / Generic
  626.  
  627.  Description:
  628.      Convert a string to uppercase.
  629.  
  630.  Usage:
  631.       #include <ctype.h>
  632.       char *upcase(str)
  633.          char *str;
  634.  
  635.