home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / test / cintltst / cintltst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-14  |  3.9 KB  |  139 lines

  1. /*
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1996                                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1999                    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.                  *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure             *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                              *
  10. *                                                                                       *
  11. *****************************************************************************************
  12. ********************************************************************************
  13. *
  14. * File CINTLTST.C
  15. *
  16. * Modification History:
  17. *        Name                     Description            
  18. *     Madhu Katragadda               Creation
  19. *********************************************************************************
  20. */
  21.  
  22. /*The main root for C API tests*/
  23.  
  24. #include "cintltst.h"
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include "uchar.h"
  28. #include "ustring.h"
  29.  
  30. static char* _testDirectory=NULL;
  31. int main ( int argc, char **argv )
  32. {
  33.       
  34.   
  35.   TestNode *root = NULL;
  36.   addAllTests(&root);
  37.   processArgs(root, argc, argv);
  38.  
  39.  
  40.    return 0;
  41.  
  42.     
  43. }
  44.  
  45. void 
  46. ctest_pathnameInContext( char* fullname, int32_t maxsize, const char* relPath ) 
  47. {
  48.     char* mainDir;
  49.     char  sepChar;
  50.  
  51.     const char inpSepChar = '|';
  52.     char* tmp;
  53.     char sepString[2] ;
  54.     int32_t lenMainDir;
  55.     int32_t lenRelPath ;   
  56.  
  57. #if defined(_WIN32) || defined(WIN32) || defined(__OS2__) || defined(OS2)
  58.         char mainDirBuffer[200];
  59.         mainDir = getenv("ICU_DATA");
  60.         if(mainDir!=NULL) {
  61.             strcpy(mainDirBuffer, mainDir);
  62.             strcat(mainDirBuffer, "..\\..");
  63.         } else {
  64.             mainDirBuffer[0]='\0';
  65.         }
  66.         mainDir=mainDirBuffer;
  67.         sepChar = '\\';
  68. #elif defined(_AIX) || defined(SOLARIS) || defined(LINUX) || defined(HPUX)
  69.         mainDir = getenv("HOME");
  70.         sepChar = '/';
  71.     
  72. #elif defined(XP_MAC)
  73.         Str255 volName;
  74.         int16_t volNum;
  75.         OSErr err = GetVol( volName, &volNum );
  76.         if (err != noErr) volName[0] = 0;
  77.         mainDir = (char*) &(volName[1]);
  78.         mainDir[volName[0]] = 0;
  79.         sepChar = ':';
  80. #else
  81.         mainDir = "";
  82.         sepChar = '/';
  83. #endif
  84.     sepString[0] = sepChar;
  85.     sepString[1] = 0;
  86.     if (relPath[0] == '|') relPath++;
  87.  
  88.     lenMainDir = strlen( mainDir );
  89.     
  90.       lenRelPath = strlen( relPath );
  91.     if (maxsize < lenMainDir + lenRelPath + 2) { fullname[0] = 0; return; }
  92.     strcpy( fullname, mainDir );
  93.     strcat( fullname, sepString );
  94.     strcat( fullname, relPath );
  95.     strchr( fullname, inpSepChar );
  96.     tmp = strchr(fullname, inpSepChar);
  97.     while (tmp) {
  98.         *tmp = sepChar;
  99.         tmp = strchr( tmp+1, inpSepChar );
  100.     }
  101. }
  102. const char*
  103. ctest_getTestDirectory()
  104. {
  105.     if (_testDirectory == NULL) 
  106.     {
  107.       ctest_setTestDirectory("icu|source|test|testdata|");
  108.     }
  109.     return _testDirectory;
  110. }
  111.  
  112. void
  113. ctest_setTestDirectory(const char* newDir) 
  114. {
  115.     char newTestDir[256];
  116.     ctest_pathnameInContext(newTestDir, sizeof(newTestDir), newDir); 
  117.     if(_testDirectory != NULL)
  118.         free(_testDirectory);
  119.     _testDirectory = (char*) malloc(sizeof(char*) * (strlen(newTestDir) + 1));
  120.     strcpy(_testDirectory, newTestDir);
  121. }
  122.  
  123.  
  124. char *austrdup(const UChar* unichars)
  125. {
  126.     int   length;
  127.     char *newString;
  128.  
  129.     length    = u_strlen ( unichars );
  130.     newString = (char*)malloc  ( sizeof( char ) * ( length + 1 ) );
  131.  
  132.     if ( newString == NULL )
  133.         return NULL;
  134.  
  135.     u_austrcpy ( newString, unichars );
  136.  
  137.     return newString;
  138. }
  139.