home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / ADVC10.ZIP / ADVC.DOC next >
Encoding:
Text File  |  1987-02-09  |  13.7 KB  |  858 lines

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