Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ll.cxx
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 
00037 #ifdef COMPILER_LICENSING
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040 #include <lmsgi.h>
00041 
00042 #include <invent.h>
00043 #include <sys/sysmp.h>
00044 
00045 LM_CODE(code, ENCRYPTION_CODE_1, ENCRYPTION_CODE_2, VENDOR_KEY1,
00046                      VENDOR_KEY2, VENDOR_KEY3, VENDOR_KEY4, VENDOR_KEY5);
00047 
00048 
00049 #define TRUE 1
00050 #define FALSE 0
00051 #define LINGER_PERIOD  10
00052 #define ALL (-1)
00053 #define ALL_8BIT (ALL & 0xFF)
00054 
00055 /* ====================================================================
00056  *
00057  * get_license
00058  *
00059  * Get a license for automatic parallelization
00060  *
00061  * ====================================================================
00062  */
00063 
00064 void
00065 get_license( char * feature_name, int soft, int tiers )
00066 
00067 {
00068 
00069  int err = FALSE;
00070  char * no_licensing;
00071  char * hard_licensing;
00072  char * tier_licensing;
00073  int numCPU;
00074  int archCPU;
00075  char *p;
00076  inventory_t *inv;
00077  int systemNumCPU = 0;
00078  int systemArchCPU;
00079 
00080  no_licensing = getenv("COMPILER_LICENSING");
00081  if (no_licensing != NULL) {
00082      return;
00083  }
00084 
00085  hard_licensing = getenv("HARD_LICENSING");
00086  if (hard_licensing != NULL) {
00087      soft = FALSE;
00088  }
00089 
00090  tier_licensing = getenv("TIER_LICENSING");
00091  if (tier_licensing != NULL) {
00092      tiers = FALSE;
00093  }
00094 
00095  if (license_init(&code,"sgifd",B_TRUE) < 0) {
00096     err = TRUE;
00097  }
00098 
00099  /* Set Up Soft Licensing */
00100  license_set_attr(LMSGI_NO_SUCH_FEATURE, NULL);
00101 
00102  /* Set the linger period to 10 seconds */
00103  license_set_attr(LM_A_LINGER, (LM_A_VAL_TYPE) LINGER_PERIOD);
00104 
00105 
00106  /*
00107     Attempt to check out a license
00108     leave the first argument as is.  you only need to fill in
00109     the feature name (program name) and version number.
00110  */
00111 
00112  if (license_chk_out(&code,     /* leave as is */
00113      feature_name,              /* replace with your feature name */
00114      "7.000"                    /* replace with your version number */
00115  )) {
00116       err = TRUE;
00117       fprintf(stderr,"%s\n", license_errstr());
00118       fprintf(stderr,"\n");
00119  }
00120 
00121  if ((tiers) && (err == FALSE)) {
00122      CONFIG *conf = lc_auth_data(get_job(), feature_name);
00123      if (conf == NULL) {
00124          err = TRUE;
00125          fprintf(stderr,"%s\n", license_errstr());
00126          fprintf(stderr,"\n");
00127      } else {
00128          if ((conf->users == 0) && (conf->lc_vendor_def != NULL) &&
00129              (strcmp(conf->lc_vendor_def, "") != 0)) {
00130 
00131            /* Nodelocked license with non empty vendor string */
00132            /* sscanf(conf->lc_vendor_def, "%d:%d", &numCPU, &archCPU); */
00133 
00134            p = conf->lc_vendor_def;
00135            while ( ((*p) != '\0')  && (((*p) < '0') || ((*p) > '9')) )
00136               p++;
00137            numCPU = atoi(p);
00138 
00139            while ((inv = getinvent()) != NULL) {
00140                if ((inv->inv_class == INV_PROCESSOR) &&
00141                    (inv->inv_type == INV_CPUBOARD)) {
00142                    if ((inv->inv_unit & ALL_8BIT) == ALL_8BIT) {
00143                        systemNumCPU = sysmp(MP_NPROCS);
00144                        systemArchCPU = inv->inv_state;
00145                    } else {
00146                        systemNumCPU = inv->inv_unit;
00147                        systemArchCPU = inv->inv_state;
00148                    }
00149                }
00150            }
00151 
00152            if ((numCPU >= systemNumCPU)) {
00153                err = FALSE;
00154            } else if ( numCPU == 0 ) {  /* A zero in the vendor string implies         */
00155                err = FALSE;             /* the largest system configuration tier       */
00156            } else {                     /* In other words, it will work on any system. */
00157                err = TRUE;
00158                fprintf(stderr, " This product's license is for %d CPU's; Your system has %d CPU's\n", numCPU, systemNumCPU );
00159                fprintf(stderr,"\n");
00160            }
00161         }
00162      }
00163  }
00164 
00165  if (err) {
00166    fprintf(stderr," This product (%s) requires a license password. \n", feature_name);
00167    fprintf(stderr," For license installation and trouble shooting \n");
00168    fprintf(stderr," information visit the web page: \n");
00169    fprintf(stderr,"\n");
00170    fprintf(stderr,"         http://www.sgi.com/Support/Licensing/install_docs.html \n");
00171    fprintf(stderr,"\n");
00172    fprintf(stderr," To obtain a Permanent license (proof of purchase\n");
00173    fprintf(stderr," required) or an Evaluation license please\n");
00174    fprintf(stderr," visit our license request web page: \n");
00175    fprintf(stderr,"\n");
00176 #if 0
00177    fprintf(stderr,"    Internal SGI Users refer to:\n");
00178    fprintf(stderr,"         http://wwclass.csd.sgi.com/swl-internal/beta_lice.html\n");
00179    fprintf(stderr,"    Otherwise:\n");
00180 #endif
00181    fprintf(stderr,"         http://www.sgi.com/Products/license.html \n");
00182    fprintf(stderr,"\n");
00183    fprintf(stderr,"         or send a blank email message to: \n");
00184    fprintf(stderr,"\n");
00185    fprintf(stderr,"         [email protected] \n");
00186    fprintf(stderr,"\n");
00187    fprintf(stderr," In North America, Silicon Graphics' customers may request \n");
00188    fprintf(stderr," Permanent licenses by sending a facsimile to: \n");
00189    fprintf(stderr,"\n");
00190    fprintf(stderr,"         (415) 390-0537 \n");
00191    fprintf(stderr,"\n");
00192    fprintf(stderr,"         or by calling our technical support hotline \n");
00193    fprintf(stderr,"\n");
00194    fprintf(stderr,"         1-800-800-4SGI \n");
00195    fprintf(stderr,"\n");
00196    fprintf(stderr," If you are Outside of North America or you are not a Silicon \n");
00197    fprintf(stderr," Graphics support customer then contact your local support provider. \n");
00198    fprintf(stderr,"\n");
00199 #if 0
00200    fprintf(stderr," Note: Permanent Licenses require verification of entitlement \n");
00201    fprintf(stderr," (i.e., Proof-of-Purchase). \n");
00202    fprintf(stderr,"  \n");
00203 #endif
00204 
00205   
00206    if (!soft)
00207       exit(-1);
00208  }
00209 }
00210 
00211 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines