⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atlconf_misc.c

📁 基于Blas CLapck的.用过的人知道是干啥的
💻 C
📖 第 1 页 / 共 2 页
字号:
         }         if (GoOn) GetEnter(stdout);         else break;      }      while(GoOn);   }   else while (fgets(ln, 256, fp)) fprintf(fpout, "%s", ln);   i = ferror(fp);   fclose(fp);   return(i);}int DisplayFile0(char *fnam, FILE *fpout){   FILE *fp;   char ln[256];   int i;   fp = fopen(fnam, "r");   if (fp == NULL)   {      fprintf(stderr, "Unable to open file '%s', continuing without display.\n",              fnam);      return(-1);   }   while (fgets(ln, 256, fp)) fprintf(fpout, "%s", ln);   i = ferror(fp);   fclose(fp);   return(i);}int FoundInFile(char *fnam, char *str){   FILE *fp;   int found=0;   char ln[256];   fp = fopen(fnam, "r");   assert(fp);   while (fgets(ln, 256, fp))   {      if (strstr(ln, str))      {         found=1;         break;      }   }   fclose(fp);   return(found);}char *FindUname(char *targ){   static int FirstTime=1;   static char unam[64];   static char unamT[6];   if (FirstTime)   {      if (FileIsThere("/bin/uname")) strcpy(unam, "/bin/uname");      else if (FileIsThere("/usr/bin/uname")) strcpy(unam, "/usr/bin/uname");      else strcpy(unam, "uname");      strcpy(unamT, "uname");      FirstTime = 0;   }   if (targ && targ[0] != '\0')      return(unamT);   return(unam);}enum ARCHFAM ProbeArchFam(char *targ)/* * Tries to guess broad architectural family using uname */{   enum ARCHFAM fam=AFOther;   char cmnd[256], res[256];   char *uname;   uname = FindUname(targ);   sprintf(cmnd, "%s -m", uname);   if ( !CmndOneLine(targ, cmnd, res) )   {      if (strstr(res, "ppc") || strstr(res, "Power Macintosh") ||          strstr(res, "powerpc")) fam = AFPPC;      else if (strstr(res, "sparc")) fam = AFSPARC;      else if (strstr(res, "alpha")) fam = AFALPHA;      else if (strstr(res, "ia64")) fam = AFIA64;      else if (strstr(res, "mips")) fam = AFMIPS;      else if ( strstr(res, "i686") || strstr(res, "i586") ||                strstr(res, "i486") || strstr(res, "i386") ||                strstr(res, "x86_64") ) fam = AFX86;   }/* * Try uname -p if uname -m didn't work */   if (fam == AFOther)   {      sprintf(cmnd, "%s -p", uname);      if ( !CmndOneLine(targ, cmnd, res) )      {         if (strstr(res, "ppc") || strstr(res, "Power Macintosh") ||             strstr(res, "powerpc")) fam = AFPPC;         else if (strstr(res, "sparc")) fam = AFSPARC;         else if (strstr(res, "alpha")) fam = AFALPHA;         else if (strstr(res, "ia64")) fam = AFIA64;         else if ( strstr(res, "i686") || strstr(res, "i586") ||                   strstr(res, "i486") || strstr(res, "i386") ||                   strstr(res, "x86_64") ) fam = AFX86;         else if (strstr(res, "mips")) fam = AFMIPS;      }   }   return(fam);}/* * =========================================================================== * These files handle setting/checking bits in (possibly) multi-word bitfields * =========================================================================== */int IsBitSetInField(int *field, int bit)/* * RETURNS: 1 if bit bit is 1, else 0 */{   int word;/* * Find which word the bit is in (assume 32-bit ints for safety), and what * bit in that word it is */   word = bit >> 5;   bit -= (word<<5);   return(field[word] & (1<<bit));}void SetBitInField(int *field, int bit)/* * Sets bit bit in multiword bitfield field */{   int word;   word = bit >> 5;   bit -= (word<<5);   field[word] |= (1<<bit);}/* * =================================================================== * These files do some string processing for some crude pseudo-parsing * =================================================================== */void KillUselessSpace(char *str)/* * This routine removes all whitespace from beginning & end of str, and * collapses multiple intra-word whitespace to one space * NOTE: killing whitespace means '\n' are transformed to ' ' or '\0'! * NOTE: This implementation ignores ' and ", so will collapse substrings */{   int i;  /* index to uncopied portion */   int j;  /* index to place to copy next character */   if (str)   {      for (i=0; str[i] && isspace(str[i]); i++);      if (str[i])      {         j = 0;         while (str[i])         {            while (str[i] && !isspace(str[i]))               str[j++] = str[i++];            if (str[i])            {               str[j++] = ' ';            }            while (isspace(str[i])) i++;         }         if (isspace(str[j-1]))            str[j-1] = '\0';         else str[j] = '\0';      }      else str[0] = '\0';   }}char *GetPathWithoutName(char *file)/* *RETURNS: string containing path without last file/dir */{   char *sp;   int i, lastslash;   char ch;   char *NewStringCopy(char *old);   for (lastslash=i=0; file[i]; i++)      if (file[i] == '/')         lastslash = i;   ch = file[i];   file[i] = '\0';   sp = NewStringCopy(file);   file[i] = ch;   return(sp);}char *NameWithoutPath(char *file)/* * Strips off path from file, assuming unix / for path * RETURNS: string containing file w/o path */{   int i, lastslash;   char *cp;   for (lastslash=i=0; file[i]; i++)      if (file[i] == '/')         lastslash = i;   cp = malloc(sizeof(char)*(i-lastslash+1));   assert(cp);   strcpy(cp, file+((file[lastslash] == '/') ? lastslash+1 : 0));   KillUselessSpace(cp);   return(cp);}int GetIntVers(char *str, int *nskip){   char ln[64];   int i, j;   *nskip = 0;   for (i=0; str[i] && !isdigit(str[i]); i++);  /* skip non-digits */   if (str[i])   {      for (j=0; j < 64 && str[j+i] && isdigit(str[j+i]); j++) ln[j] = str[j+i];      ln[j] = '\0';      if (j)      {         *nskip = i+j;         return(atoi(ln));      }   }   return(-1);}void GetGccVers(char *gcc, int *comp, int *major, int *minor, int *patch)/* * comp: 0: gcc;  1: egcs;  2: pgcc, 3: apple's gcc */{   char ln[512], ln2[512];   int i, j;   *comp = *major = *minor = *patch = -1;   sprintf(ln, "%s --version", gcc);   if (CmndOneLine(NULL, ln, ln2) == 0)   {      if (strstr(ln2, "Apple Computer"))         *comp = 3;/* *    Skip compiler name, which may have digits in it */      for (i=0; ln2[i] && !isspace(ln2[i]); i++);      *major = GetIntVers(ln2+i, &j); j += i;      if (*major != -1)      {         *minor = GetIntVers(ln2+j, &i); j += i;         if (*minor != -1)         {            *patch = GetIntVers(ln2+j, &i); j += i;            if (strstr(ln2, "egcs")) *comp = 1;            else if (strstr(ln2, "pgcc")) *comp = 2;            else *comp = 0;         }      }   }}int CompIsGcc(char *comp)/* * Tries to detect if compiler is gcc w/o scoping name of compiler */{   char cmnd[1024], res[1024];   sprintf(cmnd, "%s --version", comp);   if (CmndOneLine(NULL, cmnd, res) == 0)   {      if (strstr(res, "(GCC)") || strstr(res, " GCC ") ||          strstr(res, "GNU Fortran") || strstr(res, "(GCC "))         return(1);   }   return(0);}int CompIsAppleGcc(char *comp)/* * Tries to detect if compiler is Apple's funked-up gcc */{   char cmnd[1024], res[1024];   if (CompIsGcc(comp))   {      res[0] = '\0';      sprintf(cmnd, "%s -v 2>&1 | fgrep Apple", comp);      CmndOneLine(NULL, cmnd, res);      if (strstr(res, "Apple"))         return(1);   }   return(0);}int CompIsMIPSpro(char *comp)/* * RETURNS: 1 if compiler is MIPSpro compiler, 0 otherwise */{   char cmnd[1024], res[1024];   sprintf(cmnd, "%s -v", comp);   if (CmndOneLine(NULL, cmnd, res) == 0)   {      if (strstr(res, "MIPSpro Compiler"))         return(1);   }   return(0);}int CompIsSunWorkshop(char *comp)/* * RETURNS: 1 if compiler is Sun WorkShop compiler, 0 otherwise */{   char cmnd[1024], res[1024];   sprintf(cmnd, "%s -V", comp);   if (CmndOneLine(NULL, cmnd, res) == 0)   {      if (strstr(res, "Sun WorkShop"))         return(1);   }   return(0);}int CompIsIBMXL(char *comp)/* * RETURNS: 1 if compiler is an IBM XL compiler, 0 otherwise */{   char cmnd[1024], res[1024];   sprintf(cmnd, "%s -qversion", comp);   if (CmndOneLine(NULL, cmnd, res) == 0)   {      if (strstr(res, "IBM XL"))         return(1);   }   return(0);}char *NewStringCopy(char *old)/* * RETURNS: newly allocates string containing copy of string old */{   char *new;   new = malloc(sizeof(char)*(strlen(old)+1));   strcpy(new, old);   return(new);}char *NewAppendedString(char *old, char *app)/* * RETURNS: string holding : old + " " + app * NOTE: frees old string after copy */{   char *new;   if (!old)   {      new = malloc(sizeof(char)*(strlen(app)+1));      assert(new);      strcpy(new, app);   }   else   {      new = malloc(sizeof(char)*(strlen(old) + strlen(app)+2));      assert(new);      strcpy(new, old);      strcat(new, " ");      strcat(new, app);      free(old);   }   return(new);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -