home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / PASCLSTR.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  4KB  |  154 lines

  1. //====START_GENERATED_PROLOG======================================
  2. //
  3. //
  4. //   COMPONENT_NAME: odutils
  5. //
  6. //   CLASSES: none
  7. //
  8. //   ORIGINS: 82,27
  9. //
  10. //
  11. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  12. //   All Rights Reserved
  13. //   Licensed Materials - Property of IBM
  14. //   US Government Users Restricted Rights - Use, duplication or
  15. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  16. //       
  17. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  21. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  22. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  23. //   OR PERFORMANCE OF THIS SOFTWARE.
  24. //
  25. //====END_GENERATED_PROLOG========================================
  26. //
  27. // @(#) 1.5 com/src/utils/include/PasclStr.h, odutils, od96os2, odos29646d 7/15/96 18:01:39 [ 11/15/96 15:29:34 ]
  28. /*
  29.     File:        PasclStr.h
  30.  
  31.     Contains:    Pascal string manipulation routines
  32.  
  33.     Owned by:    Nick Pilch
  34.  
  35.     Copyright:    ⌐ 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  36.  
  37.     
  38. */
  39.  
  40. #ifndef _PASCLSTR_
  41. #define _PASCLSTR_
  42.  
  43. #ifndef _ODTYPES_
  44. #include "ODTypes.h"
  45. #endif
  46.  
  47.  
  48. #ifdef _PLATFORM_MACINTOSH_
  49. #ifdef THINK_CPLUS
  50.     #ifndef __pascal__
  51.     #include <pascal.h>
  52.     #endif
  53. #else // THINK_CPLUS
  54.     #ifndef __STRINGS__
  55.     #include <strings.h>
  56.     #endif
  57. #endif // THINK_CPLUS
  58.  
  59. #ifndef __TYPES__
  60. #include <types.h>
  61. #endif
  62.  
  63. #else  // not Platform MacIntosh
  64.   #ifndef _ODTYPESP_
  65.   #include <ODTypesP.h>
  66.   #endif
  67. #endif
  68.  
  69. #ifndef _ITEXT_
  70. #include <IText.h>
  71. #endif
  72.  
  73.  
  74. #ifdef __cplusplus
  75.     // These routines convert the string in place.
  76.     
  77.     inline StringPtr CToPascalString(char* string)
  78.     {
  79.         return c2pstr(string);
  80.     }
  81.     
  82.     inline char* PascalToCString(StringPtr string)
  83.     {
  84.         return p2cstr(string);
  85.     }
  86.  
  87.     extern "C" {
  88.  
  89. #else
  90.     #define CToPascalString    c2pstr
  91.     #define PascalToCString p2cstr
  92. #endif
  93.  
  94.  
  95. #ifdef _OD_IMPL_SHARE_UTILS_
  96. #pragma import on
  97. #endif
  98.  
  99. void ConcatPascalStrings(Str255 destString, ConstStr255Param srcString);
  100.     // Error checking is done to ensure that the limit of 256 chars is not
  101.     //    exceeded.
  102.  
  103. void CopyPascalString(Str255 destString, ConstStr255Param srcString);
  104.  
  105. ODBoolean EqualPascalStrings(ConstStr255Param str1, ConstStr255Param str2);
  106.     // Returns kODTrue if strings are equal, kODFalse otherwise. Does a CASE-
  107.     //    INSENSITIVE compare!
  108.  
  109. void CopyISOStr2PStr(Str255 destString, const ODISOStr srcString);
  110.  
  111. StringPtr IntlToPStr(ODIText* intlText, StringPtr pstr);
  112.     // Caller must allocate storage for pstr. No error checking is done for
  113.     //    strings longer than 255 chars. Simply grabs the text from the theText
  114.     //    field of ODIText.
  115.     //    CAUTION: This function is only intended to convert the bytes of the
  116.     //    IText to a pascal string. These bytes are not valid without the
  117.     //    accompanying script code and language code as well.
  118.  
  119. ODIText* PStrToIntl(StringPtr pstr, ODIText** intlText);
  120.     // Caller must dispose storage for intlText when done with it. The ODIText
  121.     //    is created with theScriptCode = smScriptRoman and
  122.     //    theLangCode = langEnglish.  Storage for the ODIText is allocated only if
  123.     //  intlText == NULL; otherwise it's assumed that *intlText is a valid ptr to
  124.     //  an ODIText big enough to hold the string.
  125.     //    CAUTION: This function is only intended to convert the bytes of the
  126.     //    pascl string to the bytes in an ODIText. These bytes are not valid
  127.     //    without first setting the appropriate accompanying script code and
  128.     //    language code in the ODIText as well.
  129.  
  130. ODHandle PStrToText(ConstStr255Param pstr);
  131.     // Caller must dispose of the returned ODHandle.
  132.  
  133. void TextToPStr(ODHandle textHandle, Str255 destString);
  134.  
  135. ODSShort ClipStringToBytes( Str255 string, ODSShort numBytes,
  136.         ODScriptCode scriptCode );
  137.     // Truncate a pascal string so that it occupies the given number of bytes
  138.     // (plus the length byte) or one less.  The one less case occurs when
  139.     // simple truncation would clip off the second byte of a double-byte
  140.     // character.
  141.     // returns the number of bytes the truncated string is long, ie numBytes or
  142.     // numBytes - 1.
  143.  
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147.  
  148. #ifdef _OD_IMPL_SHARE_UTILS_
  149. #pragma import off
  150. #endif
  151.  
  152.  
  153. #endif // _PASCLSTR_
  154.