home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / networking / otpapsampleserver / stringutils.h < prev   
Encoding:
C/C++ Source or Header  |  2000-06-23  |  24.4 KB  |  745 lines

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Header file for collection of String Utilities for DTS Sample code
  5. **
  6. **    Copyright © 1988-1992 Apple Computer, Inc.
  7. **    All rights reserved.
  8. */
  9.  
  10.  
  11. #ifndef __STRINGUTILS__
  12. #define __STRINGUTILS__
  13.  
  14. #ifndef __TYPES__
  15. #include <Types.h>
  16. #endif
  17.  
  18.  
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24.  
  25.  
  26. /*    These are duplicates of c-library functions.  The reason for duplicating them
  27. **    is so that the StringUtils code can be small and linked in with other code that
  28. **    stays resident at all times.  It is possible that when you call code to do
  29. **    something as seemingly innocent as getting the length of a string, memory can
  30. **    move.  This is because the code you are calling isn't necessarily in memory.
  31. **    If the code segment that contains the code you are calling isn't in ram, then
  32. **    it has to be loaded.  Loading the code may cause memory compaction, and therefore
  33. **    memory can move.  The pointer to the string is already pushed on the stack prior
  34. **    to the call, so if you passed a pointer into an unlocked handle, after calling
  35. **    the code, that handle may have moved, and therefore the pointer is invalid.
  36. **
  37. **    To prevent the above problem, alternate names were used for these common library
  38. **    functions.  Link this code into the same segment that holds main(), and you will
  39. **    be guaranteed that they will be in memory whenever you call them. */
  40.  
  41. short    clen(char *cptr);
  42.     /*
  43.     **    ¶ Return the length of the c-string.
  44.     **
  45.     **    INPUT:    cptr        Pointer to c-string to get length for.
  46.     **    RESULT:    short        Length of c-string.
  47.     **
  48.     **    Return the length of the c-string. */
  49.  
  50. char    *ccat(char *s1, char *s2);
  51.     /*
  52.     **    ¶ Catenate two c-strings.
  53.     **
  54.     **    INPUT:    s1            Destination string to catenate onto.
  55.     **            s2            String to catenate with.
  56.     **    RESULT:    char *        Pointer to target string.
  57.     **
  58.     **    Catenate two c-strings (s2 onto end of s1). */
  59.  
  60. char    *ccpy(char *s1, char *s2);
  61.     /*
  62.     **    ¶ Copy a c-string.
  63.     **
  64.     **    INPUT:    s1            Destination string for copy.
  65.     **            s2            String to copy.
  66.     **    RESULT:    char *        Pointer to target string.
  67.     **
  68.     **    Copy a c-string (s2 onto s1). */
  69.  
  70. short    pcmp(StringPtr s1, StringPtr s2);
  71.     /*
  72.     **    ¶ Compare two pascal-strings.
  73.     **
  74.     **    INPUT:    s1        String effectively to the "left" of the compare.
  75.     **            s2        String effectively to the "right" of the compare.
  76.     **    RESULT:    short    Signed value.  If < 0, then s1 < s2.
  77.     **                                   If > 0, then s1 > s2.
  78.     **                                   if = 0, then strings are equal.
  79.     **
  80.     **    Compare two pascal-strings. */
  81.  
  82. void    pcat(StringPtr d, StringPtr s);
  83.     /*
  84.     **    ¶ Catenate two pascal-strings.
  85.     **
  86.     **    INPUT:    d        Destination string to catenate onto.
  87.     **            s        String to catenate with.
  88.     **
  89.     **    Catenate two pascal-strings (s onto end of d). */
  90.  
  91. void    pcpy(StringPtr d, StringPtr s);
  92.     /*
  93.     **    ¶ Copy a pascal-string.
  94.     **
  95.     **    INPUT:    d        Destination string for copy.
  96.     **            s        String to copy.
  97.     **
  98.     **    Copy a pascal-string (s onto d). */
  99.  
  100. void    c2p(char *cptr);
  101.     /*
  102.     **    ¶ Convert a c-string to a pascal-string.
  103.     **
  104.     **    INPUT:    cptr    The string to convert.
  105.     **
  106.     **    Convert a c-string to a pascal-string.
  107.     **
  108.     **    __________
  109.     **
  110.     **    Also see:    p2c. */
  111.  
  112. void    p2c(StringPtr cptr);
  113.     /*
  114.     **    ¶ Convert a pascal-string to a c-string.
  115.     **
  116.     **    INPUT:    cptr    The string to convert.
  117.     **
  118.     **    Convert a pascal-string to a c-string.
  119.     **
  120.     **    __________
  121.     **
  122.     **    Also see:    c2p. */
  123.  
  124. /*****************************************************************************/
  125.  
  126. /*    These are useful, relatively small routines for string manipulation.  As with the above calls,
  127. **    link them into the code segment that holds main().
  128. **
  129. **    With the below functions, you will have most of the functionality of sprintf using shorts and
  130. **    longs.  It will take more calls, but only what you call is linked in. */
  131.  
  132.  
  133. /**/
  134.  
  135. void    ccatchr(char *cptr, char c, short count);
  136.     /*
  137.     **    ¶ Catenate a single character multiple times onto the designated string.
  138.     **
  139.     **    INPUT:    cptr        String to catenate character to.
  140.     **            c            Character to catenate.
  141.     **            count        Number of times to catenate char.
  142.     **
  143.     **    Catenate a single character multiple times onto the designated string.
  144.     **
  145.     **    __________
  146.     **
  147.     **    Also see:    ccpychr, pcatchr, pcpychr. */
  148.  
  149. void    ccatpaddec(char *cptr, char padChr, short minApnd, short maxApnd, long v);
  150.     /*
  151.     **    ¶ Convert value into base-10 text and catenate it onto the string, with padding.
  152.     **
  153.     **    INPUT:    cptr        String to catenate to.
  154.     **            padChr        Character to pad with (or 0 for none).
  155.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  156.     **            maxApnd        Maximum length of string, including padding.
  157.     **            v            Value to convert to text and catenate.
  158.     **
  159.     **    Convert the value into text for the base-10 number and catenate it to the designated string
  160.     **    with padding.  The value is assumed to be signed.  If you wish to have an unsigned decimal
  161.     **    value, call ccatnum with a base of 10.
  162.     **
  163.     **    __________
  164.     **
  165.     **    Also see:    ccatdec. */
  166.  
  167. void    ccatdec(char *cptr, long v);
  168.     /*
  169.     **    ¶ Convert value into base-10 text and catenate it onto the string.
  170.     **
  171.     **    INPUT:    cptr        String to catenate to.
  172.     **            v            Value to convert to text and catenate.
  173.     **
  174.     **    Convert the value into text for the base-10 number and catenate it to
  175.     **    the designated string.  The value is assumed to be signed.  If you wish
  176.     **    to have an unsigned decimal value, call ccatnum with a base of 10.
  177.     **
  178.     **    __________
  179.     **
  180.     **    Also see:    ccatpaddec. */
  181.  
  182. void    ccatpadhex(char *cptr, char padChr, short minApnd, short maxApnd, long v);
  183.     /*
  184.     **    ¶ Convert value into base-16 text and catenate it onto the string, with padding.
  185.     **
  186.     **    INPUT:    cptr        String to catenate to.
  187.     **            padChr        Character to pad with (or 0 for none).
  188.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  189.     **            maxApnd        Maximum length of string, including padding.
  190.     **            v            Value to convert to text and catenate.
  191.     **
  192.     **    Convert the value into text for the base-16 number and catenate it to the designated
  193.     **    string with padding.  The value is assumed to be unsigned.
  194.     **
  195.     **    __________
  196.     **
  197.     **    Also see:    ccathex. */
  198.  
  199. void    ccathex(char *cptr, long v);
  200.     /*
  201.     **    ¶ Convert value into base-16 text and catenate it onto the string, with no padding.
  202.     **
  203.     **    INPUT:    cptr        String to catenate to.
  204.     **            v            Value to convert to text and catenate.
  205.     **
  206.     **    Convert the value into text for the base-16 number and catenate it to the designated
  207.     **    string with no padding options.  The value is assumed to be unsigned.
  208.     **
  209.     **    __________
  210.     **
  211.     **    Also see:    ccatpadhex. */
  212.  
  213. void    ccatpadnum(char *cptr, char padChr, short minApnd, short maxApnd, long v, short base);
  214.     /*
  215.     **    ¶ Convert value into designated base text and catenate it onto the string, with padding.
  216.     **
  217.     **    INPUT:    cptr        String to catenate to.
  218.     **            padChr        Character to pad with (or 0 for none).
  219.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  220.     **            maxApnd        Maximum length of string, including padding.
  221.     **            v            Value to convert to text and catenate.
  222.     **            base        Base number is to be represented in.
  223.     **
  224.     **    Convert the value into text for the designated base and catenate it to the designated string
  225.     **    with padding.  If the base is negative, then the output is a signed number.
  226.     **
  227.     **    __________
  228.     **
  229.     **    Also see:    ccatnum. */
  230.  
  231. void    ccatnum(char *cptr, long v, short base);
  232.     /*
  233.     **    ¶ Convert value into designated text and catenate it onto the string, with no padding.
  234.     **
  235.     **    INPUT:    cptr        String to catenate to.
  236.     **            v            Value to convert to text and catenate.
  237.     **            base        Designated base for conversion.  (If negative, conversion is signed.)
  238.     **
  239.     **    Convert the value into text of the designated base and catenate it to the
  240.     **    string with no padding options.  If the base is negative, then the conversion is signed.
  241.     **
  242.     **    __________
  243.     **
  244.     **    Also see:    ccatpadnum. */
  245.  
  246. void    ccpychr(char *cptr, char c, short count);
  247.     /*
  248.     **    ¶ Copy a single character multiple times into the designated string.
  249.     **
  250.     **    INPUT:    cptr    String to replace.
  251.     **            c        Character to place in string.
  252.     **            count    Number of times character should be copied.
  253.     **
  254.     **    Copy a single character multiple times onto the designated string.
  255.     **
  256.     **    __________
  257.     **
  258.     **    Also see:    ccatchr. */
  259.  
  260. void    ccpypaddec(char *cptr, char padChr, short minApnd, short maxApnd, long v);
  261.     /*
  262.     **    ¶ Convert value into base-10 text and copy it into the string, with padding.
  263.     **
  264.     **    INPUT:    cptr        String to copy into.
  265.     **            padChr        Character to pad with (or 0 for none).
  266.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  267.     **            maxApnd        Maximum length of string, including padding.
  268.     **            v            Value to convert to text and copy.
  269.     **
  270.     **    Convert the value into text for the base-10 number and copy it into the designated string
  271.     **    with padding.  The value is assumed to be signed.  If you wish to have an unsigned decimal
  272.     **    value, call ccpypadnum with a base of 10.
  273.     **
  274.     **    __________
  275.     **
  276.     **    Also see:    ccpydec. */
  277.  
  278. void    ccpydec(char *cptr, long v);
  279.     /*
  280.     **    ¶ Convert value into base-10 text and copy it into the string.
  281.     **
  282.     **    INPUT:    cptr        String to copy into.
  283.     **            v            Value to convert to text and copy.
  284.     **
  285.     **    Convert the value into text for the base-10 number and copy it into
  286.     **    the designated string.  The value is assumed to be signed.  If you wish
  287.     **    to have an unsigned decimal value, call ccatnum with a base of 10.
  288.     **
  289.     **    __________
  290.     **
  291.     **    Also see:    ccpypaddec. */
  292.  
  293. void    ccpypadhex(char *cptr, char padChr, short minApnd, short maxApnd, long v);
  294.     /*
  295.     **    ¶ Convert value into base-16 text and copy it into the string, with padding.
  296.     **
  297.     **    INPUT:    cptr        String to copy into.
  298.     **            padChr        Character to pad with (or 0 for none).
  299.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  300.     **            maxApnd        Maximum length of string, including padding.
  301.     **            v            Value to convert to text and copy.
  302.     **
  303.     **    Convert the value into text for the base-16 number and copy it into the designated
  304.     **    string with padding.  The value is assumed to be unsigned.
  305.     **
  306.     **    __________
  307.     **
  308.     **    Also see:    ccpyhex. */
  309.  
  310. void    ccpyhex(char *cptr, long v);
  311.     /*
  312.     **    ¶ Convert value into base-16 text and copy it into the string, with no padding.
  313.     **
  314.     **    INPUT:    cptr        String to copy into.
  315.     **            v            Value to convert to text and copy.
  316.     **
  317.     **    Convert the value into text for the base-16 number and copy it into the designated
  318.     **    string with no padding options.  The value is assumed to be unsigned.
  319.     **
  320.     **    __________
  321.     **
  322.     **    Also see:    ccpypadhex. */
  323.  
  324. void    ccpypadnum(char *cptr, char padChr, short minApnd, short maxApnd, long v, short base);
  325.     /*
  326.     **    ¶ Convert value into designated base text and copy it into the string, with padding.
  327.     **
  328.     **    INPUT:    cptr        String to copy into.
  329.     **            padChr        Character to pad with (or 0 for none).
  330.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  331.     **            maxApnd        Maximum length of string, including padding.
  332.     **            v            Value to convert to text and copy.
  333.     **            base        Base number is to be represented in.
  334.     **
  335.     **    Convert the value into text for the designated base and copy it into the designated string
  336.     **    with padding.  If the base is negative, then the output is a signed number.
  337.     **
  338.     **    __________
  339.     **
  340.     **    Also see:    ccpynum. */
  341.  
  342. void    ccpynum(char *cptr, long v, short base);
  343.     /*
  344.     **    ¶ Convert value into designated text and copy it into the string, with no padding.
  345.     **
  346.     **    INPUT:    cptr        String to copy into.
  347.     **            v            Value to convert to text and copy.
  348.     **            base        Designated base for conversion.  (If negative, conversion is signed.)
  349.     **
  350.     **    Convert the value into text of the designated base and copy it into the
  351.     **    string with no padding options.  If the base is negative, then the conversion is signed.
  352.     **
  353.     **    __________
  354.     **
  355.     **    Also see:    ccpypadnum. */
  356.  
  357. long    c2dec(char *cptr, short *charsUsed);
  358.     /*
  359.     **    ¶ Convert the c-string to a decimal number.
  360.     **
  361.     **    INPUT:    cptr        String to convert to a decimal number.
  362.     **            charsUsed    Pointer to short to hold # of chars scanned in the conversion.
  363.     **                        (Pass in nil if you don’t care.)
  364.     **    RESULT:    long        Decimal value.
  365.     **
  366.     **    Convert the c-string to a decimal number.
  367.     **
  368.     **    __________
  369.     **
  370.     **    Also see:    c2hex, c2num. */
  371.  
  372. long    c2hex(char *cptr, short *charsUsed);
  373.     /*
  374.     **    ¶ Convert the c-string to a hex number.
  375.     **
  376.     **    INPUT:    cptr        String to convert to a hex number.
  377.     **            charsUsed    Pointer to short to hold # of chars scanned in the conversion.
  378.     **                        (Pass in nil if you don’t care.)
  379.     **    RESULT:    long        Hex value.
  380.     **
  381.     **    Convert the c-string to a hex number.
  382.     **
  383.     **    __________
  384.     **
  385.     **    Also see:    c2dec, c2num. */
  386.  
  387. long    c2num(char *cptr, short base, short *charsUsed);
  388.     /*
  389.     **    ¶ Convert the c-string to a number of the designated base.
  390.     **
  391.     **    INPUT:    cptr        String to convert to a number of the designated base.
  392.     **            base        Number for the conversion.  (If base is negative, conversion is signed.)
  393.     **            charsUsed    Pointer to short to hold # of chars scanned in the conversion.
  394.     **                        (Pass in nil if you don’t care.)
  395.     **    RESULT:    long        Numeric value.
  396.     **
  397.     **    Convert the c-string to a number of the designated base.  If there are characters
  398.     **    found that determine the base, they will be used instead of the indicated base.
  399.     **
  400.     **    __________
  401.     **
  402.     **    Also see:    c2dec, c2hex. */
  403.  
  404. short    GetLastBase(Boolean handleChars);
  405.     /*
  406.     **    ¶ Returns what base was used when text is converted to a num and sets mode.
  407.     **
  408.     **    INPUT:    handleChars        True if you want c2num or p2num (directly or indirectly)
  409.     **                            to handle character constants.
  410.     **
  411.     **    Sometimes the string being analyzed indicates what base the conversion should be
  412.     **    (i.e., starting with a $).  Also, a common string data type is the 1 to 4 char string,
  413.     **    surrounded by single ticks.  If you want to find out what the base was for the
  414.     **    string, just call GetLastBase.  You also pass in a handleChars value of true or
  415.     **    false.  (The default is false.)  If you pass in true, then c2num, called directly or
  416.     **    indirectly, will convert these strings to numbers. */
  417.  
  418. /**/
  419.  
  420. void    pcatchr(StringPtr pptr, char c, short count);
  421.     /*
  422.     **    ¶ Catenate a single character multiple times onto the designated string.
  423.     **
  424.     **    INPUT:    pptr        String to catenate character to.
  425.     **            c            Character to catenate.
  426.     **            count        Number of times to catenate char.
  427.     **
  428.     **    Catenate a single character multiple times onto the designated string.
  429.     **
  430.     **    __________
  431.     **
  432.     **    Also see:    pcpychr. */
  433.  
  434. void    pcatpaddec(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v);
  435.     /*
  436.     **    ¶ Convert value into base-10 text and catenate it onto the string, with padding.
  437.     **
  438.     **    INPUT:    pptr        String to catenate to.
  439.     **            padChr        Character to pad with (or 0 for none).
  440.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  441.     **            maxApnd        Maximum length of string, including padding.
  442.     **            v            Value to convert to text and catenate.
  443.     **
  444.     **    Convert the value into text for the base-10 number and catenate it to the designated string
  445.     **    with padding.  The value is assumed to be signed.  If you wish to have an unsigned decimal
  446.     **    value, call pcatnum with a base of 10.
  447.     **
  448.     **    __________
  449.     **
  450.     **    Also see:    pcatdec. */
  451.  
  452. void    pcatdec(StringPtr pptr, long v);
  453.     /*
  454.     **    ¶ Convert value into base-10 text and catenate it onto the string.
  455.     **
  456.     **    INPUT:    pptr        String to catenate to.
  457.     **            v            Value to convert to text and catenate.
  458.     **
  459.     **    Convert the value into text for the base-10 number and catenate it to
  460.     **    the designated string.  The value is assumed to be signed.  If you wish
  461.     **    to have an unsigned decimal value, call pcatnum with a base of 10.
  462.     **
  463.     **    __________
  464.     **
  465.     **    Also see:    pcatpaddec. */
  466.  
  467. void    pcatpadhex(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v);
  468.     /*
  469.     **    ¶ Convert value into base-16 text and catenate it onto the string, with padding.
  470.     **
  471.     **    INPUT:    pptr        String to catenate to.
  472.     **            padChr        Character to pad with (or 0 for none).
  473.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  474.     **            maxApnd        Maximum length of string, including padding.
  475.     **            v            Value to convert to text and catenate.
  476.     **
  477.     **    Convert the value into text for the base-16 number and catenate it to the designated
  478.     **    string with padding.  The value is assumed to be unsigned.
  479.     **
  480.     **    __________
  481.     **
  482.     **    Also see:    pcathex. */
  483.  
  484. void    pcathex(StringPtr pptr, long v);
  485.     /*
  486.     **    ¶ Convert value into base-16 text and catenate it onto the string, with no padding.
  487.     **
  488.     **    INPUT:    pptr        String to catenate to.
  489.     **            v            Value to convert to text and catenate.
  490.     **
  491.     **    Convert the value into text for the base-16 number and catenate it to the designated
  492.     **    string with no padding options.  The value is assumed to be unsigned.
  493.     **
  494.     **    __________
  495.     **
  496.     **    Also see:    pcatpadhex. */
  497.  
  498. long    pcatnum(StringPtr pptr, long v, short base);
  499.     /*
  500.     **    ¶ Convert value into designated text and catenate it onto the string, with no padding.
  501.     **
  502.     **    INPUT:    pptr        String to catenate to.
  503.     **            v            Value to convert to text and catenate.
  504.     **            base        Designated base for conversion.  (If negative, conversion is signed.)
  505.     **
  506.     **    Convert the value into text of the designated base and catenate it to the
  507.     **    string with no padding options.  If the base is negative, then the conversion is signed.
  508.     **
  509.     **    __________
  510.     **
  511.     **    Also see:    pcatpadnum. */
  512.  
  513. void    pcatpadnum(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v, short base);
  514.     /*
  515.     **    ¶ Convert value into designated base text and catenate it onto the string, with padding.
  516.     **
  517.     **    INPUT:    pptr        String to catenate to.
  518.     **            padChr        Character to pad with (or 0 for none).
  519.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  520.     **            maxApnd        Maximum length of string, including padding.
  521.     **            v            Value to convert to text and catenate.
  522.     **            base        Base number is to be represented in.
  523.     **
  524.     **    Convert the value into text for the designated base and catenate it to the designated string
  525.     **    with padding.  If the base is negative, then the output is a signed number.
  526.     **
  527.     **    __________
  528.     **
  529.     **    Also see:    pcatnum. */
  530.  
  531. void    pcpychr(StringPtr pptr, char c, short count);
  532.     /*
  533.     **    ¶ Copy a single character multiple times into the designated string.
  534.     **
  535.     **    INPUT:    pptr    String to replace.
  536.     **            c        Character to place in string.
  537.     **            count    Number of times character should be copied.
  538.     **
  539.     **    Copy a single character multiple times onto the designated string.
  540.     **
  541.     **    __________
  542.     **
  543.     **    Also see:    pcatchr. */
  544.  
  545. void    pcpypaddec(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v);
  546.     /*
  547.     **    ¶ Convert value into base-10 text and copy it into the string, with padding.
  548.     **
  549.     **    INPUT:    pptr        String to copy into.
  550.     **            padChr        Character to pad with (or 0 for none).
  551.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  552.     **            maxApnd        Maximum length of string, including padding.
  553.     **            v            Value to convert to text and copy.
  554.     **
  555.     **    Convert the value into text for the base-10 number and copy it into the designated string
  556.     **    with padding.  The value is assumed to be signed.  If you wish to have an unsigned decimal
  557.     **    value, call pcpypadnum with a base of 10.
  558.     **
  559.     **    __________
  560.     **
  561.     **    Also see:    pcpydec. */
  562.  
  563. void    pcpydec(StringPtr pptr, long v);
  564.     /*
  565.     **    ¶ Convert value into base-10 text and copy it into the string.
  566.     **
  567.     **    INPUT:    pptr        String to copy into.
  568.     **            v            Value to convert to text and copy.
  569.     **
  570.     **    Convert the value into text for the base-10 number and copy it into
  571.     **    the designated string.  The value is assumed to be signed.  If you wish
  572.     **    to have an unsigned decimal value, call ccatnum with a base of 10.
  573.     **
  574.     **    __________
  575.     **
  576.     **    Also see:    pcpypaddec. */
  577.  
  578. void    pcpypadnum(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v, short base);
  579.     /*
  580.     **    ¶ Convert value into designated base text and copy it into the string, with padding.
  581.     **
  582.     **    INPUT:    pptr        String to copy into.
  583.     **            padChr        Character to pad with (or 0 for none).
  584.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  585.     **            maxApnd        Maximum length of string, including padding.
  586.     **            v            Value to convert to text and copy.
  587.     **            base        Base number is to be represented in.
  588.     **
  589.     **    Convert the value into text for the designated base and copy it into the designated string
  590.     **    with padding.  If the base is negative, then the output is a signed number.
  591.     **
  592.     **    __________
  593.     **
  594.     **    Also see:    pcpynum. */
  595.  
  596. void    pcpynum(StringPtr pptr, long v, short base);
  597.     /*
  598.     **    ¶ Convert value into designated text and copy it into the string, with no padding.
  599.     **
  600.     **    INPUT:    pptr        String to copy into.
  601.     **            v            Value to convert to text and copy.
  602.     **            base        Designated base for conversion.  (If negative, conversion is signed.)
  603.     **
  604.     **    Convert the value into text of the designated base and copy it into the
  605.     **    string with no padding options.  If the base is negative, then the conversion is signed.
  606.     **
  607.     **    __________
  608.     **
  609.     **    Also see:    pcpypadnum. */
  610.  
  611. void    pcpypadhex(StringPtr pptr, char padChr, short minApnd, short maxApnd, long v);
  612.     /*
  613.     **    ¶ Convert value into base-16 text and copy it into the string, with padding.
  614.     **
  615.     **    INPUT:    pptr        String to copy into.
  616.     **            padChr        Character to pad with (or 0 for none).
  617.     **            minApnd        Minimum length of string, if there is a non-0 pad char.
  618.     **            maxApnd        Maximum length of string, including padding.
  619.     **            v            Value to convert to text and copy.
  620.     **
  621.     **    Convert the value into text for the base-16 number and copy it into the designated
  622.     **    string with padding.  The value is assumed to be unsigned.
  623.     **
  624.     **    __________
  625.     **
  626.     **    Also see:    pcpyhex. */
  627.  
  628. void    pcpyhex(StringPtr pptr, long v);
  629.     /*
  630.     **    ¶ Convert value into base-16 text and copy it into the string, with no padding.
  631.     **
  632.     **    INPUT:    pptr        String to copy into.
  633.     **            v            Value to convert to text and copy.
  634.     **
  635.     **    Convert the value into text for the base-16 number and copy it into the designated
  636.     **    string with no padding options.  The value is assumed to be unsigned.
  637.     **
  638.     **    __________
  639.     **
  640.     **    Also see:    pcpypadhex. */
  641.  
  642. long    p2dec(StringPtr pptr, short *charsUsed);
  643.     /*
  644.     **    ¶ Convert the pascal-string to a decimal number.
  645.     **
  646.     **    INPUT:    pptr        String to convert to a decimal number.
  647.     **            charsUsed    Pointer to short to hold # of chars scanned in the conversion.
  648.     **                        (Pass in nil if you don’t care.)
  649.     **    RESULT:    long        Decimal value.
  650.     **
  651.     **    Convert the pascal-string to a decimal number.
  652.     **
  653.     **    __________
  654.     **
  655.     **    Also see:    p2hex, p2num. */
  656.  
  657. long    p2hex(StringPtr pptr, short *charsUsed);
  658.     /*
  659.     **    ¶ Convert the pascal-string to a hex number.
  660.     **
  661.     **    INPUT:    pptr        String to convert to a hex number.
  662.     **            charsUsed    Pointer to short to hold # of chars scanned in the conversion.
  663.     **                        (Pass in nil if you don’t care.)
  664.     **    RESULT:    long        Hex value.
  665.     **
  666.     **    Convert the pascal-string to a hex number.
  667.     **
  668.     **    __________
  669.     **
  670.     **    Also see:    p2dec, p2num. */
  671.  
  672. long    p2num(StringPtr pptr, short base, short *charsUsed);
  673.     /*
  674.     **    ¶ Convert the pascal-string to a number of the designated base.
  675.     **
  676.     **    INPUT:    pptr        String to convert to a number of the designated base.
  677.     **            base        Number for the conversion.  (If base is negative, conversion is signed.)
  678.     **            charsUsed    Pointer to short to hold # of chars scanned in the conversion.
  679.     **                        (Pass in nil if you don’t care.)
  680.     **    RESULT:    long        Numeric value.
  681.     **
  682.     **    Convert the pascal-string to a number of the designated base.  If there are characters
  683.     **    found that determine the base, they will be used instead of the indicated base.
  684.     **
  685.     **    __________
  686.     **
  687.     **    Also see:    p2dec, p2hex. */
  688.  
  689. /**/
  690.  
  691. short    GetHexByte(char *cptr);
  692.     /*
  693.     **    ¶ Internal function for returning a hex value from 2 characters.
  694.     **
  695.     **
  696.     **    INPUT:    cptr    Pointer to characters to analyze.
  697.     **    RESULT:    short    Hex value obtained from characters.
  698.     **
  699.     **    This does not analyze just true hex values.  The first character has special meaning for
  700.     **    AppsToGo functions.  (This is really meant to be an internal function.)  If the first
  701.     **    character is a “=”, then the next character’s ascii value is returned as the hex value
  702.     **    for the two characters.  If the first character is a “≈”, then the second character
  703.     **    is upper-cased, and then the ascii value of that is returned. */
  704.  
  705. Boolean    EqualHandle(void *h1, void *h2);
  706.     /*
  707.     **    ¶ Checks to see if two handles are identical.
  708.     **
  709.     **    INPUT:    h1            First handle for compare.
  710.     **            h2            Second handle for compare.
  711.     **    RESULT:    Boolean        Returns true if handles are equal.
  712.     **
  713.     **    This function checks to see if two handles are identical. */
  714.  
  715. Boolean    EqualData(void *v1, void *v2, long size);
  716.     /*
  717.     **    ¶ Checks to see if two blocks of data are identical.
  718.     **
  719.     **    INPUT:    v1            Pointer to first data block.
  720.     **            v2            Pointer to second data block.
  721.     **            size        Length of data blocks.
  722.     **    RESULT:    Boolean        Returns true if blocks are equal.
  723.     **
  724.     **    This function checks to see if two blocks of data are identical. */
  725.  
  726. void    SetMem(void *vptr, unsigned char c, unsigned long len);
  727.     /*
  728.     **    ¶ Sets a block of memory to a specified value.
  729.     **
  730.     **    INPUT:    vptr    Pointer to block of memory to set.
  731.     **            c        Byte value to store into memory.
  732.     **            len        Length of block to set to specified value.
  733.     **
  734.     **    Sets a block of memory to a specified value. */
  735.  
  736.  
  737.  
  738. #ifdef __cplusplus
  739. }
  740. #endif
  741.  
  742.  
  743.  
  744. #endif
  745.