背景
我正在为ettercap重新编写插件,并希望在firefox源代码中找到有关处理HTTP-RESPONSE的有用信息。
问题
所以我找到了这个名为
的文件目录中的
nsprpub / LIB /的libc / SRC
来自mozilla-beta。 所以有一个名为PL_strncasecmp(...)的方法对我来说很有意思。
代码:
PR_IMPLEMENT(PRIntn)
PL_strncasecmp(const char *a, const char *b, PRUint32 max)
{
const unsigned char *ua = (const unsigned char *)a;
const unsigned char *ub = (const unsigned char *)b;
if( ((const char *)0 == a) || (const char *)0 == b )
return (PRIntn)(a-b);
while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) )
{
a++;
ua++;
ub++;
max--;
}
if( 0 == max ) return (PRIntn)0;
return (PRIntn)(uc[*ua] - uc[*ub]);
}
还有一行说:return (PRIntn)(a-b);
我很好奇PRIntn是什么类型的数据类型。
grep -rnw "typedef PRIntn"
的输出:
root@kali:~/Desktop/mozilla-beta# grep -rnw "typedef PRIntn"
security/nss/lib/base/baset.h:72:typedef PRIntn (* nssListSortFunc)(void *a, void *b);
services/crypto/modules/WeaveCrypto.js:152: // typedef PRIntn PRBool; --> int
nsprpub/lib/ds/plhash.h:21:typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
nsprpub/lib/ds/plhash.h:23:typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
nsprpub/pr/tests/dlltest.c:36:typedef PRIntn (PR_CALLBACK *GetFcnType)(void);
nsprpub/pr/src/pthreads/ptio.c:283:typedef PRIntn pt_SockLen;
nsprpub/pr/include/prinit.h:105:typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv);
nsprpub/pr/include/prprf.h:67:typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen);
nsprpub/pr/include/obsolete/protypes.h:18:typedef PRIntn intn;
nsprpub/pr/include/prtypes.h:467:typedef PRIntn PRBool;
nsprpub/pr/include/prio.h:50:typedef PRIntn PRDescIdentity; /* see: Layering file descriptors */
nsprpub/pr/include/prio.h:357:typedef PRIntn (PR_CALLBACK *PRReservedFN)(PRFileDesc *fd);
nsprpub/pr/include/md/_unixos.h:607:typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64 *buf);
nsprpub/pr/include/md/_unixos.h:608:typedef PRIntn (*_MD_Open64)(const char *path, int oflag, ...);
nsprpub/pr/include/md/_unixos.h:609:typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf);
根据我对代码的理解,我会说它是一种整数或布尔值。但我不能仅凭我的信念来争论。
提前致谢
找到答案
PRIntn实际上是一个整数类型
证明: prtypes.h:400
400 /************************************************************************
401 ** TYPES: PRUintn
402 ** PRIntn
403 ** DESCRIPTION:
404 ** The PRIntn types are most appropriate for automatic variables. They are
405 ** guaranteed to be at least 16 bits, though various architectures may
406 ** define them to be wider (e.g., 32 or even 64 bits). These types are
407 ** never valid for fields of a structure.
408 ************************************************************************/
409 #if PR_BYTES_PER_INT >= 2
410 typedef int PRIntn;
411 typedef unsigned int PRUintn;
412 #else
413 #error 'sizeof(int)' not sufficient for platform use
414 #endif
答案 0 :(得分:0)
找到答案
PRIntn实际上是一个整数类型。
声明PR_IMPLEMENT(PRIntn)
正在链接到文件
prtypes.h
所以看了这个文件,我找到了答案。
证明: prtypes.h:400
400 /************************************************************************
401 ** TYPES: PRUintn
402 ** PRIntn
403 ** DESCRIPTION:
404 ** The PRIntn types are most appropriate for automatic variables. They are
405 ** guaranteed to be at least 16 bits, though various architectures may
406 ** define them to be wider (e.g., 32 or even 64 bits). These types are
407 ** never valid for fields of a structure.
408 ************************************************************************/
409 #if PR_BYTES_PER_INT >= 2
410 typedef int PRIntn;
411 typedef unsigned int PRUintn;
412 #else
413 #error 'sizeof(int)' not sufficient for platform use
414 #endif