home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Miscellaneous / CopyPaste 3.3.4 / CopyPaste Tools Sourcecode / Selection Sort.c / Comp & Swap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-12  |  1.3 KB  |  61 lines  |  [TEXT/KAHL]

  1. #include "ToolSort.h"
  2.  
  3. /*=========================================================================
  4. Module:        Comp
  5.  
  6. Purpose:    Transforms e1 and e2 of type char * to the type Str255. 
  7.             Compares two strings: s1 and s2, returns -1 if
  8.             s1 < s2, 0 if s1 == s2, and 1 if s1 > s2. 
  9.  
  10. Uses:        
  11.  
  12. Returns:    eq
  13.  
  14. =========================================================================*/
  15. Comp(e1, e2)
  16.     Handle    *e1;
  17.     Handle    *e2;
  18.     {
  19.     int        eq = 0;
  20.     
  21.     long    size1;
  22.     long    size2;
  23.     Str255    s1;
  24.     Str255    s2;
  25.     
  26.     size1 = GetHandleSize(*e1);
  27.     size2 = GetHandleSize(*e2);
  28.     
  29.     if (size1<255 && size2<255)        /* convert s1 & s2 to Str255 */
  30.         {
  31.         s1[0] = size1;                            /* set size byte */
  32.         BlockMove( **e1, s1+1, (long)size1);    /* copy string */
  33.     
  34.         s2[0] = size2;                            /* set size byte */
  35.         BlockMove( **e2, s2+1, (long)size2);    /* copy string */
  36.  
  37.         eq = RelString(s1, s2, (Boolean)0, (Boolean)0);
  38.         }
  39.         return(eq);
  40.     }
  41.  
  42. /*=========================================================================
  43. Module:        Swap
  44.  
  45. Purpose:    Exchanges e1 with e2.
  46.  
  47. Returns:    
  48.  
  49. =========================================================================*/
  50. Swap(e1, e2)
  51.     Handle    *e1;        /* pointer to a Handle of a str of char */
  52.     Handle    *e2;        /* pointer to a Handle of a str of char */
  53.     {
  54.     Handle    temp;
  55.     
  56.     temp = *e1;
  57.     *e1 = *e2;
  58.     *e2 = temp;
  59.     }
  60.     
  61.