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

📄 stdf.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/snmptalk/stdf.c,v 1.3 2003/01/15 14:04:56 josh Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1993-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: stdf.c,v $ * Revision 1.3  2003/01/15 14:04:56  josh * directory structure shifting * * Revision 1.2  2001/11/08 16:47:32  tneale * Updated for newset file layout * * Revision 1.1.1.1  2001/11/05 17:49:13  tneale * Tornado shuffle * * Revision 7.8  2001/01/19 22:24:51  paul * Update copyright. * * Revision 7.7  2000/03/17 00:14:36  meister * Update copyright message * * Revision 7.6  1998/02/25 04:58:08  sra * Update copyrights. * * Revision 7.5  1997/08/07 18:47:33  josh * fixed strnicmp() bug that was decrementing len past 0 * * Revision 7.4  1997/03/20 06:54:00  sra * DFARS-safe copyright text.  Zap! * * Revision 7.3  1997/02/25 10:58:16  sra * Update copyright notice, dust under the bed. * * Revision 7.2  1997/01/08 23:26:53  sar * Updated include files to use envoy/h as appropriate after * move from envoy/utils to snark/snmptalk * * Revision 7.1  1997/01/08  01:58:11  sar * Removed no_pp stuff and updated copyrights * * Revision 7.0  1996/03/18  20:19:20  sar * Updated rev to 7.0 and copyright to 96 * * Revision 6.1  1995/11/01  00:56:58  sar * added pp style argument lists * * Revision 6.0  1995/05/31  21:50:27  sra * Release 6.0. * * Revision 5.0  1994/05/16  15:57:40  sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0  1993/06/24  17:14:56  sar * Updated rev to 4.0 and copyright to 93 * * Revision 1.3  1993/06/13  02:48:16  sar * moved inclusion of stdf.h to be after asn1.h so that NO_PP will be defined * if desired. * * Revision 1.2  1993/05/17  20:36:13  sar * Added <install.h> and "stdf.h" to include string routiens that zortech * didn't have. * * Revision 1.1  1993/02/19  19:29:35  dab * Initial revision * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*/#include <wrn/wm/common/install.h>#include <wrn/wm/snmp/engine/asn1.h>#include <snmptalk.h>/*#include "stdf.h"*/#include <ctype.h>#include <errno.h>/* PORTABLE 'Standard' C FUNCTIONS - these are written in C because not * all systems provide them consistently. Sometimes they're even broken. */#ifdef NEEDS_STRDUPchar *  strdup(char *str){  char *ans;  ans = (char *)SNMP_memory_alloc(strlen(str) + 1);  if (ans)    strcpy(ans, str);  return ans;}#endif /* NEEDS_STRDUP */#ifdef NEEDS_STRTOL/* This doesn't accept 0x if the radix is 16.  The overflow code assumes * a 2's complement architecture */long  strtol(char  *string,         char **endptr,         int    radix){  char *s;  long value;  long new_value;  int sign;  int increment;  extern int errno;  value = 0;  sign = 1;  s = string;  if ((radix == 1) || (radix > 36) || (radix < 0)) {    errno = ERANGE;    goto done;  }    /* skip whitespace */  while ((*s == ' ') || (*s == '\t') || (*s == '\n') || (*s == '\r'))    s++;  if (*s == '-') {    sign = -1; s++;  }  else if (*s == '+')    s++;  if (radix == 0) {    if (*s == '0') {      s++;      if ((*s == 'x') || (*s == 'X')) {        s++;        radix = 16;      }      else        radix = 8;    }    else      radix = 10;  }  /* read number */  while (1) {    if ((*s >= '0') && (*s <= '9'))      increment = *s - '0';    else if ((*s >= 'a') && (*s <= 'z'))      increment = *s - 'a' + 10;    else if ((*s >= 'A') && (*s <= 'Z'))      increment = *s - 'A' + 10;    else      break;    if (increment >= radix)      break;    new_value = value * radix + increment;    /* detect overflow */    if ((new_value - increment)/radix != value) {      s = string;      value = -1 >> 1;      if (sign < 0)        value += 1;      errno = ERANGE;      goto done;    }    value = new_value;    s++;  } done:  if (endptr)    *endptr = s;  return value*sign;}#endif /* NEEDS_STRTOL */#ifdef NEEDS_STRTOUL/* This doesn't accept 0x if the radix is 16.  The overflow code assumes * a 2's complement architecture */unsigned long  strtoul(char  *string,          char **endptr,          int    radix){  char *s;  unsigned long value;  unsigned long new_value;  int sign;  int increment;  extern int errno;  value = 0;  sign = 1;  s = string;  if ((radix == 1) || (radix > 36) || (radix < 0)) {    errno = ERANGE;    goto done;  }    /* skip whitespace */  while ((*s == ' ') || (*s == '\t') || (*s == '\n') || (*s == '\r'))    s++;  if (*s == '-') {    sign = -1; s++;  }  else if (*s == '+')    s++;  if (radix == 0) {    if (*s == '0') {      s++;      if ((*s == 'x') || (*s == 'X')) {        s++;        radix = 16;      }      else        radix = 8;    }    else      radix = 10;  }  /* read number */  while (1) {    if ((*s >= '0') && (*s <= '9'))      increment = *s - '0';    else if ((*s >= 'a') && (*s <= 'z'))      increment = *s - 'a' + 10;    else if ((*s >= 'A') && (*s <= 'Z'))      increment = *s - 'A' + 10;    else      break;    if (increment >= radix)      break;    new_value = value * radix + increment;    /* detect overflow */    if ((new_value - increment)/radix != value) {      s = string;      value = -1 >> 1;      if (sign < 0)        value += 1;      errno = ERANGE;      goto done;    }    value = new_value;    s++;  } done:  if (endptr)    *endptr = s;  return value*sign;}#endif /* NEEDS_STRTOUL */#ifdef NEEDS_STRICMPint  stricmp(register char *s,          register char *t){  char a, b;    while (*s && *t) {    a = *s; b = *t;        /* we only call tolower() if we're sure we need to because     * on some systems, calling tolower() on something other     * than an uppercase character will break the character.     */    if (isupper(a))      a = tolower(a);    if (isupper(b))      b = tolower(b);    if (a != b)      return -1;        s++;    t++;  }    if (*s != *t)    return -1;  else    return 0;}#endif /* NEEDS_STRICMP */#ifdef  NEEDS_STRNICMPint  strnicmp(register char   *s,           register char   *t,                    size_t  len){  char a, b;    while (*s && *t && len) {    len--;    a = *s; b = *t;    if (isupper(a))      a = tolower(a);    if (isupper(b))      b = tolower(b);    if (a != b)      return -1;    s++;    t++;  }    /* if we're here because len is zero, don't do the final compare,   * which verifies that both strings are null terminated, cause   * chances are, they're not.   */  if (len == 0)    return 0;    if (*s != *t) {    return -1;  }  else {    return 0;  }}#endif  /* NEEDS_STRNICMP */

⌨️ 快捷键说明

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