Statistics
| Revision:

root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / util / TargetFactory.java @ 15280

History | View | Annotate | Download (25.8 KB)

1
/*
2
 * $Id: TargetFactory.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
3
 * IzPack
4
 * Copyright (C) 2002 by Elmar Grom
5
 *
6
 * File :               TargetFactory.java
7
 * Description :        provides factory methods and related functionality for OS specific isntantiations
8
 * Author's email :     elmar@grom.net
9
 * Website :            http://www.izforge.com
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
 */
25

    
26
package   com.izforge.izpack.util;
27

    
28
import java.io.BufferedReader;
29
import java.io.File;
30
import java.io.InputStream;
31
import java.io.InputStreamReader;
32
import java.util.StringTokenizer;
33

    
34
/*---------------------------------------------------------------------------*/
35
/**
36
 * The <code>TargetFactory</code> serves as a central mechanism to instantiate
37
 * OS specific class flavors, provide OS specific file extension types,
38
 * default install directories and similar functionality. In addition it
39
 * provides services that are related to OS versions and flavors. For a
40
 * tutorial on using some of the features in this class see the
41
 * <A HREF=doc-files/TargetFactory.html>TargetFactory Tutorial</A>.
42
 *
43
 * @version  0.0.1 / 1/3/2002
44
 * @author   Elmar Grom
45
 */
46
/*---------------------------------------------------------------------------*/
47
/*$
48
 * @design
49
 *
50
 * Reports actually observed on some systems:
51
 *
52
 * OS                 OS Name         Version     Architecture  Native Report (ver)
53
 * ----------------------------------------------------------------------------------------------------------
54
 * Windows 95
55
 * Windows 98         Windows 98      4.10        x86           Windows 98 [Version 4.10.1998]
56
 * Windows-ME         Windows Me      4.90        x86           Windows Millennium [Version 4.90.3000]
57
 * Windows-NT 3.5
58
 * Windows-NT 4.0     Windows NT      4.0         x86           Windows NT Version 4.0
59
 * Windows 2000       Windows 2000    5.0         x86           Microsoft Windows 2000 [Version 5.00.2195]
60
 * Windows-XP         Windows 2000    5.1         x86           Microsoft Windows XP [Version 5.1.2600]
61
 * Windows-XP         Windows XP      5.1         x86
62
 * Mac
63
 * Mac OS-X
64
 * Linux              Linux           2.4.7-10    i386
65
 * Linux              Linux           2.4.18-4GB  i386
66
 * Solaris
67
 *
68
 *---------------------------------------------------------------------------*/
69
public class TargetFactory
70
{
71
  // ------------------------------------------------------------------------
72
  // Constant Definitions
73
  // ------------------------------------------------------------------------
74

    
75
  // Basic operating systems
76

    
77
  /** Identifies Microsoft Windows. */
78
  public static final int    WINDOWS                     = 0;
79
  /** Identifies generic UNIX operating systems */
80
  public static final int    UNIX                        = 2;
81
  /** Used to report a non specific operating system. */
82
  public static final int    GENERIC                     = 3;
83

    
84
  // operating system favors
85

    
86
  /** This is the basic flavor for every operating system. */
87
  public static final int    STANDARD                    = 0;
88
  /** Used to identify the Windows-NT class of operating
89
      systems in terms of an OS flavor. It is reported for
90
      Windows-NT, 2000 and XP. */
91
  public static final int    NT                          = 1;
92
  /** Used to identify the OS X flavor of the Mac OS */
93
  public static final int    X                           = 2;
94

    
95
  // system architecture
96

    
97
  /** Identifies Intel X86 based processor types. */
98
  public static final int    X86                         = 0;
99
  /** Nonspecific processor architecture, other than X86. */
100
  public static final int    OTHER                       = 1;
101

    
102
  /** The extensions used for native libraries on various operating
103
      systems. The string positions correspond to the basic operating
104
      system indexes. The following values are legal to use : <br><br>
105
      <ul>
106
      <li>WINDOWS
107
      <li>MAC
108
      <li>UNIX
109
      <li>GENERIC
110
      </ul> */
111
  static final String [] LIBRARY_EXTENSION =
112
  {
113
    "dll",
114
    "so",
115
    "",
116
    ""
117
  };
118

    
119
  /** The os specific class prefixes for classes that implement
120
      different versions for the various operating systems. The
121
      string positions correspond to the basic operating system
122
      indexes. The following values are legal to use : <br><br>
123
      <ul>
124
      <li>WINDOWS
125
      <li>MAC
126
      <li>UNIX
127
      <li>GENERIC
128
      </ul> */
129
  static final String [] CLASS_PREFIX =
130
  {
131
    "Win_",
132
    "Mac_",
133
    "Unix_",
134
    ""
135
  };
136

    
137
  /** The os favor specific class prefixes for classes the implement
138
      different versions for various os favors. The string positions
139
      correspond to the flavor indexes. The following values are
140
      legal to use :  <br><br>
141
      <ul>
142
      <li>STANDARD
143
      <li>NT
144
      <li>X
145
      </ul> */
146
  static final String [] CLASS_FLAVOR_PREFIX =
147
  {
148
    "",
149
    "NT_",
150
    "X_"
151
  };
152

    
153
  /** The list of processor architecture specific prefixes. The string
154
      positions correspond to the architecture indexes. The following
155
      values are leegal to use : <br><br>
156
      <ul>
157
      <li>X86
158
      <li>OTHER
159
      </ul> */
160
  static final String [] CLASS_ARCHITECTURE_PREFIX =
161
  {
162
    "X86_",  // Intel X86 architecture
163
    "U_"     // unknown
164
  };
165

    
166
  /** The list of default install path fragments. Depending on
167
      the operating system, a path fragment might represent
168
      either a part of the default install path or the entire
169
      path to use. For MS-Windows it is always only a part
170
      of the full install path. The string positions correspond
171
      to the basic operating system indexes. The following
172
      values are leegal to use : <br><br>
173
      <ul>
174
      <li>WINDOWS
175
      <li>MAC
176
      <li>UNIX
177
      <li>GENERIC
178
      </ul> */
179
  static final String [] INSTALL_PATH_FRAGMENT =
180
  {
181
    "Program Files" + File.separator,
182
    "/Applications" + File.separator,
183
    "/usr/local" + File.separator,
184
    File.separator + "apps" + File.separator
185
  };
186

    
187
  /** This is a list of keys to use when looking for resources
188
      that define the default install path to use. The list is
189
      organized as two dimensional array of <code>String</code>s.
190
      To access the array, denote the first dimension with the
191
      operating system index and the second dimension with the
192
      flavor index. For example to access the key for Windows-NT
193
      use <code>INSTALL_PATH_RESOURCE_KEY[WINDOWS][NT]</code>
194
      The array uses a sparse population, that is, not all array
195
      locations actually contain a key. Only locations for which
196
      a real operating system/flavor combination exists are
197
      populated. For example, there is no such thing as
198
      <code>INSTALL_PATH_RESOURCE_KEY[UNIX][X]</code> */
199
  static final String [][] INSTALL_PATH_RESOURCE_KEY = 
200
  {
201
    //      Standard                        NT                          X
202
    { "TargetPanel.dir.windows", "TargetPanel.dir.windows", "" },                         // Windows
203
    { "TargetPanel.dir.mac",     "",                        "TargetPanel.dir.macosx" },   // Mac
204
    { "TargetPanel.dir.unix",    "",                        "" },                         // UNIX
205
    { "TargetPanel.dir",         "",                        "" }                          // Generic
206
  };
207

    
208
  /** The delimiter characters used to tokenize version numbers */
209
  private static final String VERSION_DELIMITER           = ".-";
210

    
211
  // ------------------------------------------------------------------------
212
  // Variable Declarations
213
  // ------------------------------------------------------------------------
214
  /** The reference to the single instance of <code>TargetFactory</code>. Used
215
      in static methods in place of <code>this</code>. */
216
  private static TargetFactory    me              = null;
217
  /** identifies the operating system we are running on */
218
  private int                     os              = -1;
219
  /** identifies the operating system favor */
220
  private int                     osFlavor        = -1;
221
  /** identifies the hardware architecture we are running on */
222
  private int                     architecture    = -1;
223
  /** represents the version number of the target system */
224
  private String                  version         = "";
225

    
226
 /*--------------------------------------------------------------------------*/
227
 /**
228
  * Constructor
229
  */
230
 /*--------------------------------------------------------------------------*/
231
 /*$
232
  * @design
233
  *
234
  * Identify the following about the target system:
235
  *
236
  * - OS type
237
  * - architecture
238
  * - version
239
  *
240
  * and store this information for later use.
241
  *--------------------------------------------------------------------------*/
242
  private TargetFactory ()
243
  {
244
    version = System.getProperty ("os.version");
245

    
246
    // ----------------------------------------------------
247
    // test for Windows
248
    // ----------------------------------------------------
249
    if (OsVersion.IS_WINDOWS)
250
    {
251
      os            = WINDOWS;
252
      osFlavor      = STANDARD;
253
      architecture  = X86;
254
      String osName = OsVersion.OS_NAME.toLowerCase();
255

    
256
      if (osName.indexOf ("nt") > -1)
257
      {
258
        osFlavor = NT;
259
      }
260
      else if (osName.indexOf ("2000") > -1)
261
      {
262
        osFlavor = NT;
263
      }
264
      else if (osName.indexOf ("xp") > -1)
265
      {
266
        osFlavor = NT;
267
      }
268
    }
269
    // ----------------------------------------------------
270
    // test for Mac OS
271
    // ----------------------------------------------------
272
    else if (OsVersion.IS_OSX)
273
    {
274
      os            = X;
275
      osFlavor      = STANDARD;
276
      architecture  = OTHER;
277
    }
278
    // ----------------------------------------------------
279
    // what's left should be unix
280
    // ----------------------------------------------------
281
    else
282
    {
283
      os            = UNIX;
284
      osFlavor      = STANDARD;
285
      architecture  = OTHER;
286
      String osName = OsVersion.OS_NAME.toLowerCase();
287

    
288
      if (osName.indexOf ("x86") > -1)
289
      {
290
        architecture  = X86;
291
      }
292
    }
293
  }
294
 /*--------------------------------------------------------------------------*/
295
 /**
296
  * Returns an instance of <code>TargetFactory</code> to use.
297
  *
298
  * @return    an instance of <code>TargetFactory</code>.
299
  */
300
 /*--------------------------------------------------------------------------*/
301
  public static TargetFactory getInstance ()
302
  {
303
    if (me == null)
304
    {
305
      me = new TargetFactory ();
306
    }
307

    
308
    return me;
309
  }
310
 /*--------------------------------------------------------------------------*/
311
 /**
312
  * This method returns an OS and OS flavor specific instance of the requested
313
  * class.
314
  * <br><br>
315
  * <b>Class Naming Rules</b><br>
316
  * Class versions must be named with the OS and OS flavor as prefix. The
317
  * prefixes are simply concatenated, with the OS prefix first and the flavor
318
  * prefix second. Use the following OS specific prefixes:<br><br>
319
  * <TABLE BORDER=1>
320
  * <TR><TH>Operating System</TH><TH>Prefix</TH></TR>
321
  * <TR><TD>Microsoft Windows</TD><TD>Win_</TD></TR>
322
  * <TR><TD>Mac OS</TD><TD>Mac_</TD></TR>
323
  * <TR><TD>UNIX</TD><TD>UNIX_</TD></TR>
324
        * </TABLE><br>
325
  * For the different OS flavors, use these prefixes:<br><br>
326
  * <TABLE BORDER=1>
327
  * <TR><TH>OS Flavor</TH><TH>Prefix</TH></TR>
328
  * <TR><TD>NT</TD><TD>NT_</TD></TR>
329
  * <TR><TD>Mac OS X</TD><TD>X_</TD></TR>
330
        * </TABLE>
331
  * <br><br>
332
  * <b>Naming Example:</b>
333
  * <br><br>
334
  * For the class <code>MyClass</code>, the specific version for Windows NT
335
  * must be in the same package as <code>MyClass</code> and the name must be
336
  * <code>Win_NT_MyClass</code>. A version that should be instantiated for any
337
  * non-NT flavor would be called <code>Win_MyClass</code>. This would also
338
  * be the version instantiated on Windows NT if the version
339
  * <code>Win_NT_MyClass</code> does not exist.
340
  * <br><br>
341
  * <b>The Loading Process</b>
342
  * <br><br>
343
  * The process is completed after the first successful attempt to load
344
  * a class. <br>
345
  * <ol>
346
  * <li>load a version that is OS and OS-Flavor specific
347
  * <li>load a version that is OS specific
348
  * <li>load the base version (without OS or OS-Flavor prefix)
349
  * </ol><br>
350
  * See the <A HREF=doc-files/TargetFactory.html>TargetFactory Tutorial</A>
351
  * for more information.<br><br>
352
  *
353
  * @param     name  the fully qualified name of the class to load without
354
  *                  the extension.
355
  *
356
  * @return    An instance of the requested class. Note that specific
357
  *            initialization that can not be accomplished in the default
358
  *            constructor still needs to be performed before the object
359
  *            can be used.
360
  *
361
  * @exception Exception if all attempts to instantiate class fail
362
  */
363
 /*--------------------------------------------------------------------------*/
364
  public Object makeObject (String name) throws Exception
365
  {
366
    int    nameStart    = name.lastIndexOf ('.') + 1;
367
    String packageName  = name.substring (0, nameStart);
368
    String className    = name.substring (nameStart, name.length ());
369
    String actualName;
370

    
371
    try
372
    {
373
      actualName = packageName + CLASS_PREFIX [os] + CLASS_FLAVOR_PREFIX [osFlavor] + className;
374
      Class temp = Class.forName (actualName);
375
      return temp.newInstance();
376
    }
377
    catch (Throwable exception1)
378
    {
379
      try
380
      {
381
        Class   temp   = Class.forName (packageName + CLASS_PREFIX [os] + className);
382
        return temp.newInstance();
383
      }
384
      catch (Throwable exception2)
385
      {
386
        try
387
        {
388
          actualName = name;
389
          Class temp = Class.forName (actualName);
390
          return temp.newInstance();
391
        }
392
        catch (Throwable exception3)
393
        {
394
          throw new Exception("can not instantiate class " + name);
395
        }
396
      }
397
    }
398
  }
399
 /*--------------------------------------------------------------------------*/
400
 /**
401
  * Returns true if the version in the parameter string is higher than the
402
  * version of the target os.
403
  *
404
  * @param     version      the version number to compare to
405
  *
406
  * @return    <code>false</code> if the version of the target system is
407
  *            higher, otherwise <code>true</code>
408
  */
409
 /*--------------------------------------------------------------------------*/
410
 /*$
411
  * @design
412
  *
413
  * Version numbers are assumed to be constructed as follows:
414
  *
415
  * - a list of one or more numbers, separated by periods as in X.X.X. ...
416
  *   or periods and dashes as in X.X.X-Y. ...
417
  * - the numbers follow the decimal number system
418
  * - the left most number is of highest significance
419
  *
420
  * The process compares each set of numbers, beginning at the most
421
  * significant and working down the ranks (this is working left to right).
422
  * The process is stopped as soon as the pair of numbers compaired is not
423
  * equal. If the numer for the target system is higher, flase is returned,
424
  * otherwise true.
425
  *--------------------------------------------------------------------------*/
426
  public boolean versionIsHigher (String version) throws Exception
427
  {
428
    StringTokenizer targetVersion   = new StringTokenizer (this.version, VERSION_DELIMITER);
429
    StringTokenizer compareVersion  = new StringTokenizer (version, VERSION_DELIMITER);
430

    
431
    int target;
432
    int compare;
433

    
434
    while (targetVersion.hasMoreTokens () && compareVersion.hasMoreTokens ())
435
    {
436
      try
437
      {
438
        target  = Integer.parseInt (targetVersion.nextToken ());
439
        compare = Integer.parseInt (compareVersion.nextToken ());
440
      }
441
      catch (Throwable exception)
442
      {
443
        throw new Exception("error in version string");
444
      }
445

    
446
      if (compare > target)
447
      {
448
        return true;
449
      }
450
      else if (target > compare)
451
      {
452
        return false;
453
      }
454
    }
455

    
456
    return false;
457
  }
458
 /*--------------------------------------------------------------------------*/
459
 /**
460
  * Returns the index number for the target operating system that was detected.
461
  *
462
  * @return    an index number for the OS
463
  *
464
  * @see       #WINDOWS
465
  * @see       #UNIX
466
  * @see       #GENERIC
467
  */
468
 /*--------------------------------------------------------------------------*/
469
  public int getOS ()
470
  {
471
    return os;
472
  }
473
 /*--------------------------------------------------------------------------*/
474
 /**
475
  * Returns the index number for the operating system flavor that was
476
  * detected on the target system.
477
  *
478
  * @return    an index for the OS flavor
479
  *
480
  * @see       #STANDARD
481
  * @see       #NT
482
  * @see       #X
483
  */
484
 /*--------------------------------------------------------------------------*/
485
  public int getOSFlavor ()
486
  {
487
    return osFlavor;
488
  }
489
 /*--------------------------------------------------------------------------*/
490
 /**
491
  * Returns an index number that identified the processor architecture of
492
  * the target system.
493
  *
494
  * @return    an index for the processor architecture
495
  *
496
  * @see       #X86
497
  * @see       #OTHER
498
  */
499
 /*--------------------------------------------------------------------------*/
500
  public int getArchitecture ()
501
  {
502
    return architecture;
503
  }
504
 /*--------------------------------------------------------------------------*/
505
 /**
506
  * Returns the file extension customarily used on the target OS for
507
  * dynamically loadable libraries.
508
  *
509
  * @return    a <code>String</code> containing the customary library
510
  *            extension for the target OS. Note that the string might
511
  *            be empty if there no such specific extension for the target OS.
512
  */
513
 /*--------------------------------------------------------------------------*/
514
  public String getNativeLibraryExtension ()
515
  {
516
    return LIBRARY_EXTENSION[os];
517
  }
518
 /*--------------------------------------------------------------------------*/
519
 /**
520
  * Returns the system dependent default install path. This is typically
521
  * used to suggest an istall path to the end user, when performing an
522
  * installation. The default install path is assembled form the OS specific
523
  * path fragment specified in <code>INSTALL_PATH_FRAGMENT</code>, possibly
524
  * a drive letter and the application name. The user the option to  define
525
  * resources that define default paths which differ from the path fragments
526
  * defined here. The following resource names will be recognized by this
527
  * method:
528
  * <br><br><ul>
529
  * <li><code>TargetPanel.dir.windows</code>
530
  * <li><code>TargetPanel.dir.macosx</code>
531
  * <li><code>TargetPanel.dir.unix</code>
532
  * <li><code>TargetPanel.dir</code> plus the all lower case version of
533
  *     <code>System.getProperty ("os.name")</code>, with all spaces replaced
534
  *     by an underscore ('_').
535
  * <li><code>TargetPanel.dir</code>
536
  * </ul>
537
  *
538
  * @param     appName  the name of the application to install. If no
539
  *                     specific resource has been set, then this name will
540
  *                     be appended to the OS specific default path fragment.
541
  *
542
  * @return    the default install path for the target system
543
  */
544
 /*--------------------------------------------------------------------------*/
545
 /*$
546
  * @design
547
  *
548
  * First try to read a path string from a resource file. This approach allows
549
  * the user to customize the default install path that is suggested to the
550
  * end user by IzPack. There are a number of choices for the naming of this
551
  * resource, so we need to go through a few steps in order to exhaust the
552
  * different possibilities. If this was not successful we use the default
553
  * install path that is defined for the operating system we are running on.
554
  * This path should be expanded by the application name to form the full
555
  * path that to returne.
556
  *--------------------------------------------------------------------------*/
557
  public String getDefaultInstallPath (String appName)
558
  {
559
    String      path        = null;
560
    InputStream input;
561
    String      keyFragment = "/res/" + INSTALL_PATH_RESOURCE_KEY [GENERIC][STANDARD];
562

    
563
    // ----------------------------------------------------
564
    // attempt to get an input stream through a resource
565
    // based on a key which is specific to the target OS 
566
    // ----------------------------------------------------
567
    input = getClass ().getResourceAsStream ("/res/" + INSTALL_PATH_RESOURCE_KEY [os][osFlavor]);
568
    
569
    // ----------------------------------------------------
570
    // attempt to get an input stream through a resource
571
    // based on a key which is made specific to the target
572
    // OS by using the string returned by 
573
    // System.getProperty ("os.name").toLowerCase ()
574
    // ----------------------------------------------------
575
    if (input == null)
576
    {
577
                  String key  = OsVersion.OS_NAME.toLowerCase().replace (' ', '_');         // avoid spaces in file names
578
      key         = keyFragment + key.toLowerCase ();  // for consistency among TargetPanel res files
579
                  input       = TargetFactory.class.getResourceAsStream (key);
580
    }
581

    
582
    // ----------------------------------------------------
583
    // attempt to get an input stream through a resource
584
    // based on a key which is not specific to any target OS 
585
    // ----------------------------------------------------
586
    if (input == null)
587
    {
588
      input = TargetFactory.class.getResourceAsStream (keyFragment);
589
    }
590

    
591
    // ----------------------------------------------------
592
    // If we got an input stream try to read the path
593
    // from the file
594
    // ----------------------------------------------------
595
    if (input != null)
596
    {
597
            InputStreamReader streamReader;
598
      BufferedReader    reader        = null;
599
      String            line;
600

    
601
      try
602
      {
603
              streamReader  = new InputStreamReader (input);
604
        reader        = new BufferedReader (streamReader);
605
        line          = reader.readLine ();
606

    
607
        while (line != null)
608
        {
609
                      line = line.trim ();
610
                      if (!line.equals ("")) 
611
          {
612
            break;
613
                      }
614
          line = reader.readLine ();
615
        }
616
        path = line;
617
      }
618
      catch (Throwable exception)
619
      {
620
      }
621
      finally
622
      {
623
        try
624
        {
625
          if(reader != null)
626
            reader.close ();
627
        }
628
        catch (Throwable exception)
629
        {
630
        }
631
      }
632
    }
633

    
634
    // ----------------------------------------------------
635
    // if we were unable to obtain a path from a resource,
636
    // use the default for the traget operating system.
637
    // ----------------------------------------------------
638
    if (path == null || path.equals(""))
639
    {
640
      path = "";
641
      
642
      // --------------------------------------------------
643
      // if we run on windows, we need a valid drive letter
644
      // to put in front of the path. The drive that
645
      // contains the user's home directory is usually the
646
      // drive that also contains the install directory,
647
      // so this seems the best choice here.
648
      // --------------------------------------------------
649
      if (os == WINDOWS)
650
      {
651
        String home = System.getProperty ("user.home");
652
        // take everything up to and including the first '\'
653
        path        = home.substring (0, home.indexOf(File.separatorChar) + 1);
654
      }
655

    
656
      path = path + INSTALL_PATH_FRAGMENT [os] + appName;
657
    }
658

    
659
    return path;
660
  }
661
  
662
  /**
663
   * Gets an Prefix Alias for the current Platform.
664
   * "Win_" on Windows Systems
665
   * "Win_NT_" on WinNT4, 2000, XP
666
   * Mac on Mac Mac_X on macosx and
667
   * Unix_
668
   * @return
669
   */
670

    
671
  public static String getCurrentOSPrefix()
672
  {
673
    String OSName      = System.getProperty ("os.name").toLowerCase (); 
674
    String OSArch      = System.getProperty ("os.arch").toLowerCase ();     
675
    int OS             = 0; 
676
    int OSFlavor       = 0;
677
    int OSarchitecture = 0;
678
    // ----------------------------------------------------
679
    // test for Windows
680
    // ----------------------------------------------------
681
    if (OSName.indexOf ("windows") > -1)
682
    {
683
      OS            = WINDOWS;
684
      OSFlavor      = STANDARD;
685
      OSarchitecture  = X86;
686

    
687
      if (OSName.indexOf ("nt") > -1)
688
      {
689
        OSFlavor = NT;
690
      }
691
      else if (OSName.indexOf ("2000") > -1)
692
      {
693
        OSFlavor = NT;
694
      }
695
      else if (OSName.indexOf ("xp") > -1)
696
      {
697
        OSFlavor = NT;
698
      }
699
    }
700
    // ----------------------------------------------------
701
    // test for Mac OS
702
    // ----------------------------------------------------
703
    else if (OSName.indexOf ("mac") > -1)
704
    {
705
      OS            = GENERIC;
706
      OSFlavor      = STANDARD;
707
      OSarchitecture  = OTHER;
708

    
709
      if (OSName.indexOf ("macosx") > -1)
710
      {
711
        OSFlavor = X;
712
      }
713
    }
714
    // ----------------------------------------------------
715
    // what's left should be unix
716
    // ----------------------------------------------------
717
    else
718
    {
719
      OS            = UNIX;
720
      OSFlavor      = STANDARD;
721
      OSarchitecture  = OTHER;
722

    
723
      if( OSArch.indexOf( "86" ) > -1 )
724
      {
725
        OSarchitecture  = X86;
726
      }
727
    }
728
    
729
    return( CLASS_PREFIX [OS] + CLASS_FLAVOR_PREFIX [OSFlavor] );
730
  }
731

    
732
}
733
/*---------------------------------------------------------------------------*/