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

📄 handy.h

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 H
📖 第 1 页 / 共 2 页
字号:
/*    handy.h * *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, *    2000, 2001, 2002, 2004, 2005, 2006, 2007, by Larry Wall and others * *    You may distribute under the terms of either the GNU General Public *    License or the Artistic License, as specified in the README file. * */#if !defined(__STDC__)#ifdef NULL#undef NULL#endif#ifndef I286#  define NULL 0#else#  define NULL 0L#endif#endif#define Null(type) ((type)NULL)/*=head1 Handy Values=for apidoc AmU||NullchNull character pointer.=for apidoc AmU||NullsvNull SV pointer.=cut*/#define Nullch Null(char*)#define Nullfp Null(PerlIO*)#define Nullsv Null(SV*)#ifdef TRUE#undef TRUE#endif#ifdef FALSE#undef FALSE#endif#define TRUE (1)#define FALSE (0)/* XXX Configure ought to have a test for a boolean type, if I can   just figure out all the headers such a test needs.   Andy Dougherty	August 1996*//* bool is built-in for g++-2.6.3 and later, which might be used   for extensions.  <_G_config.h> defines _G_HAVE_BOOL, but we can't   be sure _G_config.h will be included before this file.  _G_config.h   also defines _G_HAVE_BOOL for both gcc and g++, but only g++   actually has bool.  Hence, _G_HAVE_BOOL is pretty useless for us.   g++ can be identified by __GNUG__.   Andy Dougherty	February 2000*/#ifdef __GNUG__		/* GNU g++ has bool built-in */#  ifndef HAS_BOOL#    define HAS_BOOL 1#  endif#endif/* The NeXT dynamic loader headers will not build with the bool macro   So declare them now to clear confusion.*/#if defined(NeXT) || defined(__NeXT__)# undef FALSE# undef TRUE  typedef enum bool { FALSE = 0, TRUE = 1 } bool;# define ENUM_BOOL 1# ifndef HAS_BOOL#  define HAS_BOOL 1# endif /* !HAS_BOOL */#endif /* NeXT || __NeXT__ */#ifndef HAS_BOOL# if defined(UTS) || defined(VMS)#  define bool int# else#  define bool char# endif# define HAS_BOOL 1#endif/* Try to figure out __func__ or __FUNCTION__ equivalent, if any. * XXX Should really be a Configure probe, with HAS__FUNCTION__ *     and FUNCTION__ as results. * XXX Similarly, a Configure probe for __FILE__ and __LINE__ is needed. */#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__SUNPRO_C)) /* C99 or close enough. */#  define FUNCTION__ __func__#else#  if (defined(_MSC_VER) && _MSC_VER < 1300) || /* Pre-MSVC 7.0 has neither __func__ nor __FUNCTION and no good workarounds, either. */ \      (defined(__DECC_VER)) /* Tru64 or VMS, and strict C89 being used, but not modern enough cc (in Tur64, -c99 not known, only -std1). */#    define FUNCTION__ ""#  else#    define FUNCTION__ __FUNCTION__ /* Common extension. */#  endif#endif/* XXX A note on the perl source internal type system.  The   original intent was that I32 be *exactly* 32 bits.   Currently, we only guarantee that I32 is *at least* 32 bits.   Specifically, if int is 64 bits, then so is I32.  (This is the case   for the Cray.)  This has the advantage of meshing nicely with   standard library calls (where we pass an I32 and the library is   expecting an int), but the disadvantage that an I32 is not 32 bits.   Andy Dougherty	August 1996   There is no guarantee that there is *any* integral type with   exactly 32 bits.  It is perfectly legal for a system to have   sizeof(short) == sizeof(int) == sizeof(long) == 8.   Similarly, there is no guarantee that I16 and U16 have exactly 16   bits.   For dealing with issues that may arise from various 32/64-bit   systems, we will ask Configure to check out	SHORTSIZE == sizeof(short)	INTSIZE == sizeof(int)	LONGSIZE == sizeof(long)	LONGLONGSIZE == sizeof(long long) (if HAS_LONG_LONG)	PTRSIZE == sizeof(void *)	DOUBLESIZE == sizeof(double)	LONG_DOUBLESIZE == sizeof(long double) (if HAS_LONG_DOUBLE).*/#ifdef I_INTTYPES /* e.g. Linux has int64_t without <inttypes.h> */#   include <inttypes.h>#   ifdef INT32_MIN_BROKEN#       undef  INT32_MIN#       define INT32_MIN (-2147483647-1)#   endif#   ifdef INT64_MIN_BROKEN#       undef  INT64_MIN#       define INT64_MIN (-9223372036854775807LL-1)#   endif#endiftypedef I8TYPE I8;typedef U8TYPE U8;typedef I16TYPE I16;typedef U16TYPE U16;typedef I32TYPE I32;typedef U32TYPE U32;#ifdef PERL_CORE#   ifdef HAS_QUADtypedef I64TYPE I64;typedef U64TYPE U64;#   endif#endif /* PERL_CORE */#if defined(HAS_QUAD) && defined(USE_64_BIT_INT)#   ifndef UINT64_C /* usually from <inttypes.h> */#       if defined(HAS_LONG_LONG) && QUADKIND == QUAD_IS_LONG_LONG#           define INT64_C(c)	CAT2(c,LL)#           define UINT64_C(c)	CAT2(c,ULL)#       else#           if LONGSIZE == 8 && QUADKIND == QUAD_IS_LONG#               define INT64_C(c)	CAT2(c,L)#               define UINT64_C(c)	CAT2(c,UL)#           else#               define INT64_C(c)	((I64TYPE)(c))#               define UINT64_C(c)	((U64TYPE)(c))#           endif#       endif#   endif#endif/* HMB H.Merijn Brand - a placeholder for preparing Configure patches */#if defined(HAS_MALLOC_SIZE) && defined(LOCALTIME_R_NEEDS_TZSET) && defined(HAS_PSEUDOFORK)/* Not (yet) used at top level, but mention them for metaconfig */#endif/* Mention I8SIZE, U8SIZE, I16SIZE, U16SIZE, I32SIZE, U32SIZE,   I64SIZE, and U64SIZE here so that metaconfig pulls them in. */#if defined(UINT8_MAX) && defined(INT16_MAX) && defined(INT32_MAX)/* I8_MAX and I8_MIN constants are not defined, as I8 is an ambiguous type.   Please search CHAR_MAX in perl.h for further details. */#define U8_MAX UINT8_MAX#define U8_MIN UINT8_MIN#define I16_MAX INT16_MAX#define I16_MIN INT16_MIN#define U16_MAX UINT16_MAX#define U16_MIN UINT16_MIN#define I32_MAX INT32_MAX#define I32_MIN INT32_MIN#ifndef UINT32_MAX_BROKEN /* e.g. HP-UX with gcc messes this up */#  define U32_MAX UINT32_MAX#else#  define U32_MAX 4294967295U#endif#define U32_MIN UINT32_MIN#else/* I8_MAX and I8_MIN constants are not defined, as I8 is an ambiguous type.   Please search CHAR_MAX in perl.h for further details. */#define U8_MAX PERL_UCHAR_MAX#define U8_MIN PERL_UCHAR_MIN#define I16_MAX PERL_SHORT_MAX#define I16_MIN PERL_SHORT_MIN#define U16_MAX PERL_USHORT_MAX#define U16_MIN PERL_USHORT_MIN#if LONGSIZE > 4# define I32_MAX PERL_INT_MAX# define I32_MIN PERL_INT_MIN# define U32_MAX PERL_UINT_MAX# define U32_MIN PERL_UINT_MIN#else# define I32_MAX PERL_LONG_MAX# define I32_MIN PERL_LONG_MIN# define U32_MAX PERL_ULONG_MAX# define U32_MIN PERL_ULONG_MIN#endif#endif/* log(2) is pretty close to  0.30103, just in case anyone is grepping for it */#define BIT_DIGITS(N)   (((N)*146)/485 + 1)  /* log2(10) =~ 146/485 */#define TYPE_DIGITS(T)  BIT_DIGITS(sizeof(T) * 8)#define TYPE_CHARS(T)   (TYPE_DIGITS(T) + 2) /* sign, NUL */#define Ctl(ch) ((ch) & 037)/*=head1 SV-Body Allocation=for apidoc Ama|SV*|newSVpvs|const char* sLike C<newSVpvn>, but takes a literal string instead of a string/length pair.=for apidoc Ama|SV*|newSVpvs_share|const char* sLike C<newSVpvn_share>, but takes a literal string instead of a string/lengthpair and omits the hash parameter.=for apidoc Am|void|sv_catpvs|SV* sv|const char* sLike C<sv_catpvn>, but takes a literal string instead of a string/length pair.=for apidoc Am|void|sv_setpvs|SV* sv|const char* sLike C<sv_setpvn>, but takes a literal string instead of a string/length pair.=head1 Memory Management=for apidoc Ama|char*|savepvs|const char* sLike C<savepvn>, but takes a literal string instead of a string/length pair.=head1 GV Functions=for apidoc Am|HV*|gv_stashpvs|const char* name|I32 createLike C<gv_stashpvn>, but takes a literal string instead of a string/length pair.=head1 Hash Manipulation Functions=for apidoc Am|SV**|hv_fetchs|HV* tb|const char* key|I32 lvalLike C<hv_fetch>, but takes a literal string instead of a string/length pair.=for apidoc Am|SV**|hv_stores|HV* tb|const char* key|NULLOK SV* valLike C<hv_store>, but takes a literal string instead of a string/length pairand omits the hash parameter.=cut*//* concatenating with "" ensures that only literal strings are accepted as argument */#define STR_WITH_LEN(s)  (s ""), (sizeof(s)-1)/* note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros, which means that it requires the full * Perl_xxx(aTHX_ ...) form for any API calls where it's used. *//* STR_WITH_LEN() shortcuts */#define newSVpvs(str) Perl_newSVpvn(aTHX_ STR_WITH_LEN(str))#define newSVpvs_share(str) Perl_newSVpvn_share(aTHX_ STR_WITH_LEN(str), 0)#define sv_catpvs(sv, str) Perl_sv_catpvn_flags(aTHX_ sv, STR_WITH_LEN(str), SV_GMAGIC)#define sv_setpvs(sv, str) Perl_sv_setpvn(aTHX_ sv, STR_WITH_LEN(str))#define savepvs(str) Perl_savepvn(aTHX_ STR_WITH_LEN(str))#define gv_stashpvs(str, create) Perl_gv_stashpvn(aTHX_ STR_WITH_LEN(str), create)#define gv_fetchpvs(namebeg, add, sv_type) Perl_gv_fetchpvn_flags(aTHX_ STR_WITH_LEN(namebeg), add, sv_type)#define hv_fetchs(hv,key,lval)						\  ((SV **)Perl_hv_common(aTHX_ (hv), NULL, STR_WITH_LEN(key), 0,	\			 (lval) ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)	\			 : HV_FETCH_JUST_SV, NULL, 0))#define hv_stores(hv,key,val)						\  ((SV **)Perl_hv_common(aTHX_ (hv), NULL, STR_WITH_LEN(key), 0,	\			 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), (val), 0))/*=head1 Miscellaneous Functions=for apidoc Am|bool|strNE|char* s1|char* s2Test two strings to see if they are different.  Returns true orfalse.=for apidoc Am|bool|strEQ|char* s1|char* s2Test two strings to see if they are equal.  Returns true or false.=for apidoc Am|bool|strLT|char* s1|char* s2Test two strings to see if the first, C<s1>, is less than the second,C<s2>.  Returns true or false.=for apidoc Am|bool|strLE|char* s1|char* s2Test two strings to see if the first, C<s1>, is less than or equal to thesecond, C<s2>.  Returns true or false.=for apidoc Am|bool|strGT|char* s1|char* s2Test two strings to see if the first, C<s1>, is greater than the second,C<s2>.  Returns true or false.=for apidoc Am|bool|strGE|char* s1|char* s2Test two strings to see if the first, C<s1>, is greater than or equal tothe second, C<s2>.  Returns true or false.=for apidoc Am|bool|strnNE|char* s1|char* s2|STRLEN lenTest two strings to see if they are different.  The C<len> parameterindicates the number of bytes to compare.  Returns true or false. (Awrapper for C<strncmp>).=for apidoc Am|bool|strnEQ|char* s1|char* s2|STRLEN lenTest two strings to see if they are equal.  The C<len> parameter indicatesthe number of bytes to compare.  Returns true or false. (A wrapper forC<strncmp>).=cut*/#define strNE(s1,s2) (strcmp(s1,s2))#define strEQ(s1,s2) (!strcmp(s1,s2))#define strLT(s1,s2) (strcmp(s1,s2) < 0)#define strLE(s1,s2) (strcmp(s1,s2) <= 0)#define strGT(s1,s2) (strcmp(s1,s2) > 0)#define strGE(s1,s2) (strcmp(s1,s2) >= 0)#define strnNE(s1,s2,l) (strncmp(s1,s2,l))#define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))#ifdef HAS_MEMCMP#  define memNE(s1,s2,l) (memcmp(s1,s2,l))#  define memEQ(s1,s2,l) (!memcmp(s1,s2,l))#else#  define memNE(s1,s2,l) (bcmp(s1,s2,l))#  define memEQ(s1,s2,l) (!bcmp(s1,s2,l))#endif#define memEQs(s1, l, s2) \	(sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1)))#define memNEs(s1, l, s2) !memEQs(s1, l, s2)/* * Character classes. * * Unfortunately, the introduction of locales means that we * can't trust isupper(), etc. to tell the truth.  And when * it comes to /\w+/ with tainting enabled, we *must* be able * to trust our character classes. * * Therefore, the default tests in the text of Perl will be * independent of locale.  Any code that wants to depend on * the current locale will use the tests that begin with "lc". */#ifdef HAS_SETLOCALE  /* XXX Is there a better test for this? */#  ifndef CTYPE256#    define CTYPE256#  endif#endif/*=head1 Character classes=for apidoc Am|bool|isALNUM|char chReturns a boolean indicating whether the C C<char> is an ASCII alphanumericcharacter (including underscore) or digit.=for apidoc Am|bool|isALPHA|char chReturns a boolean indicating whether the C C<char> is an ASCII alphabeticcharacter.=for apidoc Am|bool|isSPACE|char chReturns a boolean indicating whether the C C<char> is whitespace.=for apidoc Am|bool|isDIGIT|char chReturns a boolean indicating whether the C C<char> is an ASCIIdigit.=for apidoc Am|bool|isUPPER|char chReturns a boolean indicating whether the C C<char> is an uppercasecharacter.=for apidoc Am|bool|isLOWER|char chReturns a boolean indicating whether the C C<char> is a lowercasecharacter.=for apidoc Am|char|toUPPER|char chConverts the specified character to uppercase.=for apidoc Am|char|toLOWER|char chConverts the specified character to lowercase.=cut*/#define isALNUM(c)	(isALPHA(c) || isDIGIT(c) || (c) == '_')#define isIDFIRST(c)	(isALPHA(c) || (c) == '_')#define isALPHA(c)	(isUPPER(c) || isLOWER(c))#define isSPACE(c) \	((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) =='\r' || (c) == '\f')#define isPSXSPC(c)	(isSPACE(c) || (c) == '\v')#define isBLANK(c)	((c) == ' ' || (c) == '\t')#define isDIGIT(c)	((c) >= '0' && (c) <= '9')#ifdef EBCDIC

⌨️ 快捷键说明

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