文件的 PRIntn 是哪种数据类型 strcase.c

What sort of datatype is PRIntn for the file strcase.c

背景

我正在为 ettercap 重新设计一个插件,希望能在 firefox 源代码中找到有关处理 HTTP-RESPONSE 的有用信息。

问题

所以我找到了这个名为

的文件

strcase.c

在目录

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]) && ('[=11=]' != *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

找到答案

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