本文整理汇总了C++中PORT_Strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ PORT_Strdup函数的具体用法?C++ PORT_Strdup怎么用?C++ PORT_Strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PORT_Strdup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parseGroupList
SECStatus
parseGroupList(const char *arg, SSLNamedGroup **enabledGroups,
unsigned int *enabledGroupsCount)
{
SSLNamedGroup *groups;
char *str;
char *p;
unsigned int numValues = 0;
unsigned int count = 0;
/* Count the number of groups. */
str = PORT_Strdup(arg);
if (!str) {
return SECFailure;
}
p = strtok(str, ",");
while (p) {
++numValues;
p = strtok(NULL, ",");
}
PORT_Free(str);
str = NULL;
groups = PORT_ZNewArray(SSLNamedGroup, numValues);
if (!groups) {
goto done;
}
/* Get group names. */
str = PORT_Strdup(arg);
if (!str) {
goto done;
}
p = strtok(str, ",");
while (p) {
SSLNamedGroup group = groupNameToNamedGroup(p);
if (group == ssl_grp_none) {
count = 0;
goto done;
}
groups[count++] = group;
p = strtok(NULL, ",");
}
done:
if (str) {
PORT_Free(str);
}
if (!count) {
PORT_Free(groups);
return SECFailure;
}
*enabledGroupsCount = count;
*enabledGroups = groups;
return SECSuccess;
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:56,代码来源:basicutil.c
示例2: PORT_Strdup
/*
** Convert a der-encoded integer to a hex printable string form
*/
char *CERT_Hexify (SECItem *i, int do_colon)
{
unsigned char *cp, *end;
char *rv, *o;
if (!i->len) {
return PORT_Strdup("00");
}
rv = o = (char*) PORT_Alloc(i->len * 3);
if (!rv) return rv;
cp = i->data;
end = cp + i->len;
while (cp < end) {
unsigned char ch = *cp++;
*o++ = hex[(ch >> 4) & 0xf];
*o++ = hex[ch & 0xf];
if (cp != end) {
if (do_colon) {
*o++ = ':';
}
}
}
*o = 0; /* Null terminate the string */
return rv;
}
开发者ID:AOSC-Dev,项目名称:nss-purified,代码行数:30,代码来源:certhtml.c
示例3: lg_keydb_name_cb
static char *
lg_keydb_name_cb(void *arg, int dbVersion)
{
const char *configdir = (const char *)arg;
const char *dbver;
char *smpname = NULL;
char *dbname = NULL;
switch (dbVersion) {
case 4:
dbver = "4";
break;
case 3:
dbver = "3";
break;
case 1:
dbver = "1";
break;
case 2:
default:
dbver = "";
break;
}
smpname = PR_smprintf(KEY_DB_FMT, configdir, dbver);
if (smpname) {
dbname = PORT_Strdup(smpname);
PR_smprintf_free(smpname);
}
return dbname;
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:31,代码来源:lginit.c
示例4: SSL_SetURL
/*
* Allow the application to pass the url or hostname into the SSL library
* so that we can do some checking on it. It will be used for the value in
* SNI extension of client hello message.
*/
SECStatus
SSL_SetURL(PRFileDesc *fd, const char *url)
{
sslSocket * ss = ssl_FindSocket(fd);
SECStatus rv = SECSuccess;
if (!ss) {
SSL_DBG(("%d: SSL[%d]: bad socket in SSLSetURL",
SSL_GETPID(), fd));
return SECFailure;
}
ssl_Get1stHandshakeLock(ss);
ssl_GetSSL3HandshakeLock(ss);
if ( ss->url ) {
PORT_Free((void *)ss->url); /* CONST */
}
ss->url = (const char *)PORT_Strdup(url);
if ( ss->url == NULL ) {
rv = SECFailure;
}
ssl_ReleaseSSL3HandshakeLock(ss);
ssl_Release1stHandshakeLock(ss);
return rv;
}
开发者ID:Metrological,项目名称:chromium,代码行数:33,代码来源:sslsecur.c
示例5: JAR_find
/*
* J A R _ f i n d
*
* Establish the search pattern for use
* by JAR_find_next, to traverse the filenames
* or certificates in the JAR structure.
*
* See jar.h for a description on how to use.
*
*/
JAR_Context *
JAR_find(JAR *jar, char *pattern, jarType type)
{
JAR_Context *ctx;
PORT_Assert(jar != NULL);
if (!jar)
return NULL;
ctx = (JAR_Context *)PORT_ZAlloc(sizeof(JAR_Context));
if (ctx == NULL)
return NULL;
ctx->jar = jar;
if (pattern) {
if ((ctx->pattern = PORT_Strdup(pattern)) == NULL) {
PORT_Free(ctx);
return NULL;
}
}
ctx->finding = type;
switch (type) {
case jarTypeMF:
ctx->next = ZZ_ListHead(jar->hashes);
break;
case jarTypeSF:
case jarTypeSign:
ctx->next = NULL;
ctx->nextsign = ZZ_ListHead(jar->signers);
break;
case jarTypeSect:
ctx->next = ZZ_ListHead(jar->manifest);
break;
case jarTypePhy:
ctx->next = ZZ_ListHead(jar->phy);
break;
case jarTypeOwner:
if (jar->signers)
ctx->next = ZZ_ListHead(jar->signers);
else
ctx->next = NULL;
break;
case jarTypeMeta:
ctx->next = ZZ_ListHead(jar->metainfo);
break;
default:
PORT_Assert(1 != 2);
break;
}
return ctx;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:69,代码来源:jar.c
示例6: nss_get_password
static char * nss_get_password(PK11SlotInfo * slot, PRBool retry, void *arg)
{
(void)slot; /* unused */
if(retry || NULL == arg)
return NULL;
else
return (char *)PORT_Strdup((char *)arg);
}
开发者ID:3s3s,项目名称:simple_server,代码行数:8,代码来源:nss.c
示例7: exitErr
/* Unrecoverable error */
exitErr("Unable to connect to server", errCode);
}
#if 0 /* No client authorization */
static char *
myPasswd(PK11SlotInfo *info, PRBool retry, void *arg)
{
char * passwd = NULL;
if ( (!retry) && arg )
passwd = PORT_Strdup((char *)arg);
return passwd;
}
开发者ID:tsh185,项目名称:t80_platform_external,代码行数:15,代码来源:stap-client-connect.c
示例8: getPassword
static char *
getPassword(PK11SlotInfo *slot, PRBool retry, void *arg)
{
int *success = (int *)arg;
if (retry) {
*success = 0;
return NULL;
}
*success = 1;
return PORT_Strdup(userPassword);
}
开发者ID:emilio,项目名称:gecko-dev,代码行数:13,代码来源:dbtest.c
示例9: NSS_CMSSignerInfo_GetSignerEmailAddress
/*
* NSS_CMSSignerInfo_GetSignerEmailAddress - return the common name of the signer
*
* sinfo - signerInfo data for this signer
*
* Returns a pointer to allocated memory, which must be freed.
* A return value of NULL is an error.
*/
char *
NSS_CMSSignerInfo_GetSignerEmailAddress(NSSCMSSignerInfo *sinfo)
{
CERTCertificate *signercert;
if ((signercert = NSS_CMSSignerInfo_GetSigningCertificate(sinfo, NULL)) == NULL)
return NULL;
if (!signercert->emailAddr || !signercert->emailAddr[0])
return NULL;
return (PORT_Strdup(signercert->emailAddr));
}
开发者ID:MekliCZ,项目名称:positron,代码行数:21,代码来源:cmssiginfo.c
示例10: nss_get_password
static char * nss_get_password(PK11SlotInfo * slot, PRBool retry, void *arg)
{
pphrase_arg_t *parg;
parg = (pphrase_arg_t *) arg;
(void)slot; /* unused */
if(retry > 2)
return NULL;
if(parg->data->set.str[STRING_KEY_PASSWD])
return (char *)PORT_Strdup((char *)parg->data->set.str[STRING_KEY_PASSWD]);
else
return NULL;
}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:13,代码来源:nss.c
示例11: vcard_emul_get_password
/*
* NSS needs the app to supply a password prompt. In our case the only time
* the password is supplied is as part of the Login APDU. The actual password
* is passed in the pw_arg in that case. In all other cases pw_arg should be
* NULL.
*/
static char *
vcard_emul_get_password(PK11SlotInfo *slot, PRBool retries, void *pw_arg)
{
/* if it didn't work the first time, don't keep trying */
if (retries) {
return NULL;
}
/* we are looking up a password when we don't have one in hand */
if (pw_arg == NULL) {
return NULL;
}
/* TODO: we really should verify that were are using the right slot */
return PORT_Strdup(pw_arg);
}
开发者ID:AjayMashi,项目名称:x-tier,代码行数:20,代码来源:vcard_emul_nss.c
示例12: nss_get_password_from_console
char* nss_get_password_from_console(PK11SlotInfo* slot, PRBool retry, void *arg) {
char prompt[255];
char* pw = NULL;
if(arg != NULL) pw = (char *)PORT_Strdup((char *)arg);
if(pw != NULL) return pw;
sprintf(prompt, "Enter Password or Pin for \"%s\":",
PK11_GetTokenName(slot));
return getPasswordString(NULL, prompt);
std::cerr<<"Password check failed: No password found."<<std::endl;
return NULL;
}
开发者ID:ic-hep,项目名称:emi3,代码行数:15,代码来源:nssgetpassword.cpp
示例13: PRBool
char *SEC_GetPassword(FILE *input, FILE *output, char *prompt,
PRBool (*ok)(char *))
{
#if defined(_WINDOWS)
int isTTY = (input == stdin);
#define echoOn(x)
#define echoOff(x)
#else
int infd = fileno(input);
int isTTY = isatty(infd);
#endif
char phrase[200] = {'\0'}; /* ensure EOF doesn't return junk */
for (;;) {
/* Prompt for password */
if (isTTY) {
fprintf(output, "%s", prompt);
fflush (output);
echoOff(infd);
}
QUIET_FGETS ( phrase, sizeof(phrase), input);
if (isTTY) {
fprintf(output, "\n");
echoOn(infd);
}
/* stomp on newline */
phrase[PORT_Strlen(phrase)-1] = 0;
/* Validate password */
if (!(*ok)(phrase)) {
/* Not weird enough */
if (!isTTY) return 0;
fprintf(output, "Password must be at least 8 characters long with one or more\n");
fprintf(output, "non-alphabetic characters\n");
continue;
}
return (char*) PORT_Strdup(phrase);
}
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:42,代码来源:secpwd.c
示例14: nss_doubleEscape
static char *
nss_doubleEscape(const char *string)
{
char *round1 = NULL;
char *retValue = NULL;
if (string == NULL) {
goto done;
}
round1 = nss_addEscape(string,'\'');
if (round1) {
retValue = nss_addEscape(round1,'"');
PORT_Free(round1);
}
done:
if (retValue == NULL) {
retValue = PORT_Strdup("");
}
return retValue;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:20,代码来源:nssinit.c
示例15: NSSUTIL_DoubleEscape
char *
NSSUTIL_DoubleEscape(const char *string, char quote1, char quote2)
{
char *round1 = NULL;
char *retValue = NULL;
if (string == NULL) {
goto done;
}
round1 = nssutil_escapeQuotes(string, quote1, PR_FALSE);
if (round1) {
retValue = nssutil_escapeQuotes(round1, quote2, PR_FALSE);
PORT_Free(round1);
}
done:
if (retValue == NULL) {
retValue = PORT_Strdup("");
}
return retValue;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:20,代码来源:utilpars.c
示例16: PORT_Strdup
static
char *_NSSUTIL_GetOldSecmodName(const char *dbname,const char *filename)
{
char *file = NULL;
char *dirPath = PORT_Strdup(dbname);
char *sep;
sep = PORT_Strrchr(dirPath,*NSSUTIL_PATH_SEPARATOR);
#ifdef WINDOWS
if (!sep) {
sep = PORT_Strrchr(dirPath,'\\');
}
#endif
if (sep) {
*(sep)=0;
}
file= PR_smprintf("%s"NSSUTIL_PATH_SEPARATOR"%s", dirPath, filename);
PORT_Free(dirPath);
return file;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:20,代码来源:utilmod.c
示例17: lg_GenerateSecretCKA_ID
/*
* Secret keys must have a CKA_ID value to be stored in the database. This code
* will generate one if there wasn't one already.
*/
static CK_RV
lg_GenerateSecretCKA_ID(NSSLOWKEYDBHandle *handle, SECItem *id, char *label)
{
unsigned int retries;
SECStatus rv = SECSuccess;
CK_RV crv = CKR_OK;
id->data = NULL;
if (label) {
id->data = (unsigned char *)PORT_Strdup(label);
if (id->data == NULL) {
return CKR_HOST_MEMORY;
}
id->len = PORT_Strlen(label) + 1;
if (!nsslowkey_KeyForIDExists(handle, id)) {
return CKR_OK;
}
PORT_Free(id->data);
id->data = NULL;
id->len = 0;
}
id->data = (unsigned char *)PORT_Alloc(LG_KEY_ID_SIZE);
if (id->data == NULL) {
return CKR_HOST_MEMORY;
}
id->len = LG_KEY_ID_SIZE;
retries = 0;
do {
rv = RNG_GenerateGlobalRandomBytes(id->data, id->len);
} while (rv == SECSuccess && nsslowkey_KeyForIDExists(handle, id) &&
(++retries <= LG_KEY_MAX_RETRIES));
if ((rv != SECSuccess) || (retries > LG_KEY_MAX_RETRIES)) {
crv = CKR_DEVICE_ERROR; /* random number generator is bad */
PORT_Free(id->data);
id->data = NULL;
id->len = 0;
}
return crv;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:45,代码来源:lgcreate.c
示例18: GetPasswordString
char *
GetPasswordString(void *arg, char *prompt)
{
FILE *input = stdin;
char phrase[200] = {'\0'};
int isInputTerminal = isatty(fileno(stdin));
#ifndef _WINDOWS
if (isInputTerminal) {
input = fopen(consoleName, "r");
if (input == NULL) {
fprintf(stderr, "Error opening input terminal for read\n");
return NULL;
}
}
#endif
if (isInputTerminal) {
fprintf(stdout, "Please enter your password:\n");
fflush(stdout);
}
QUIET_FGETS (phrase, sizeof(phrase), input);
if (isInputTerminal) {
fprintf(stdout, "\n");
}
#ifndef _WINDOWS
if (isInputTerminal) {
fclose(input);
}
#endif
/* Strip off the newlines if present */
if (phrase[PORT_Strlen(phrase)-1] == '\n' ||
phrase[PORT_Strlen(phrase)-1] == '\r') {
phrase[PORT_Strlen(phrase)-1] = 0;
}
return (char*) PORT_Strdup(phrase);
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:41,代码来源:nss_secutil.c
示例19: JAR_get_metainfo
int
JAR_get_metainfo(JAR *jar, char *name, char *header, void **info,
unsigned long *length)
{
JAR_Item *it;
ZZLink *link;
ZZList *list;
PORT_Assert(jar != NULL && header != NULL);
if (jar == NULL || header == NULL)
return JAR_ERR_PNF;
list = jar->metainfo;
if (ZZ_ListEmpty(list))
return JAR_ERR_PNF;
for (link = ZZ_ListHead(list);
!ZZ_ListIterDone(list, link);
link = link->next) {
it = link->thing;
if (it->type == jarTypeMeta) {
JAR_Metainfo *met;
if ((name && !it->pathname) || (!name && it->pathname))
continue;
if (name && it->pathname && strcmp(it->pathname, name))
continue;
met = (JAR_Metainfo *)it->data;
if (!PORT_Strcasecmp(met->header, header)) {
*info = PORT_Strdup(met->info);
*length = PORT_Strlen(met->info);
return 0;
}
}
}
return JAR_ERR_PNF;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:39,代码来源:jar.c
示例20: lg_EvaluateConfigDir
const char *
lg_EvaluateConfigDir(const char *configdir,char **appName)
{
if (PORT_Strncmp(configdir, MULTIACCESS, sizeof(MULTIACCESS)-1) == 0) {
char *cdir;
*appName = PORT_Strdup(configdir+sizeof(MULTIACCESS)-1);
if (*appName == NULL) {
return configdir;
}
cdir = *appName;
while (*cdir && *cdir != ':') {
cdir++;
}
if (*cdir == ':') {
*cdir = 0;
cdir++;
}
configdir = cdir;
}
return configdir;
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:22,代码来源:lginit.c
注:本文中的PORT_Strdup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论