本文整理汇总了C++中PORT_Strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ PORT_Strdup函数的具体用法?C++ PORT_Strdup怎么用?C++ PORT_Strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PORT_Strdup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}