home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWCommon / Sources / FWPriStr.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  2.5 KB  |  102 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPriStr.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFound.hpp"
  11.  
  12. #ifndef FWPRISTR_H
  13. #include "FWPriStr.h"
  14. #endif
  15.  
  16. #ifdef FW_BUILD_MAC
  17. #include <Memory.h>
  18. #endif
  19.  
  20. #ifdef FW_BUILD_MAC
  21. #pragma segment FWCommon
  22. #endif
  23.  
  24. #if FW_LIB_EXPORT_PRAGMAS
  25. #pragma lib_export on
  26. #endif
  27.  
  28. //----------------------------------------------------------------------------------------
  29. // FW_PrimitiveStringLength
  30. //----------------------------------------------------------------------------------------
  31.  
  32. size_t FW_FUNC_ATTR FW_PrimitiveStringLength(const char * p)
  33. {
  34.     size_t i = 0;
  35.     for (; *p; p++, i++) ;
  36.  
  37.     return i;
  38. }
  39.  
  40. //----------------------------------------------------------------------------------------
  41. // FW_PrimitiveStringEqual
  42. //----------------------------------------------------------------------------------------
  43.  
  44. int FW_FUNC_ATTR FW_PrimitiveStringEqual(const char *p1, const char *p2)
  45. {
  46.     while (1)
  47.     {
  48.         char c1 = *p1++;
  49.         char c2 = *p2++;
  50.         
  51.         if (c1 != c2) return 0;
  52.         
  53.         if (!c1) return 1;
  54.     }
  55. }
  56.  
  57. //----------------------------------------------------------------------------------------
  58. // FW_PrimitiveStringCopy
  59. //----------------------------------------------------------------------------------------
  60.  
  61. void FW_FUNC_ATTR FW_PrimitiveStringCopy(const char *source, char *destination)
  62. {
  63.     char c;
  64.     
  65.     while ((c = *source++) != '\0')
  66.         *destination++ = c;
  67.     
  68.     *destination = '\0';
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. // FW_PrimitiveStringCatenate
  73. //----------------------------------------------------------------------------------------
  74.  
  75. void FW_FUNC_ATTR FW_PrimitiveStringCatenate(const char *source, char *destination)
  76. {
  77.     size_t len = FW_PrimitiveStringLength(destination);
  78.     FW_PrimitiveStringCopy(source, destination+len);
  79. }
  80.  
  81. //----------------------------------------------------------------------------------------
  82. // FW_PrimitiveStringFindCharacter
  83. //----------------------------------------------------------------------------------------
  84.  
  85. FW_FUNC_ATTR char * FW_PrimitiveStringFindCharacter(const char *source, char c)
  86. {
  87.     while (1)
  88.     {
  89.         char cc;
  90.         if (c == (cc = *source))
  91.         {
  92.             return (char *) source;
  93.         }
  94.         else if (!cc)
  95.         {
  96.             return NULL;
  97.         }
  98.         else
  99.             source++;
  100.     }
  101. }
  102.