本文整理汇总了C++中PR_ExplodeTime函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_ExplodeTime函数的具体用法?C++ PR_ExplodeTime怎么用?C++ PR_ExplodeTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_ExplodeTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display_cert_info
static void display_cert_info(struct SessionHandle *data,
CERTCertificate *cert)
{
char *subject, *issuer, *common_name;
PRExplodedTime printableTime;
char timeString[256];
PRTime notBefore, notAfter;
subject = CERT_NameToAscii(&cert->subject);
issuer = CERT_NameToAscii(&cert->issuer);
common_name = CERT_GetCommonName(&cert->subject);
infof(data, "\tsubject: %s\n", subject);
CERT_GetCertTimes(cert, ¬Before, ¬After);
PR_ExplodeTime(notBefore, PR_GMTParameters, &printableTime);
PR_FormatTime(timeString, 256, "%b %d %H:%M:%S %Y GMT", &printableTime);
infof(data, "\tstart date: %s\n", timeString);
PR_ExplodeTime(notAfter, PR_GMTParameters, &printableTime);
PR_FormatTime(timeString, 256, "%b %d %H:%M:%S %Y GMT", &printableTime);
infof(data, "\texpire date: %s\n", timeString);
infof(data, "\tcommon name: %s\n", common_name);
infof(data, "\tissuer: %s\n", issuer);
PR_Free(subject);
PR_Free(issuer);
PR_Free(common_name);
}
示例2: main
int main(int argc, char **argv)
#endif
{
PRTime ct;
PRExplodedTime et;
PRStatus rv;
char *sp1 = "Sat, 1 Jan 3001 00:00:00"; /* no time zone */
char *sp2 = "Fri, 31 Dec 3000 23:59:60"; /* no time zone, not normalized */
#if _MSC_VER >= 1400 && !defined(WINCE)
/* Run this test in the US Pacific Time timezone. */
_putenv_s("TZ", "PST8PDT");
_tzset();
#endif
rv = PR_ParseTimeString(sp1, PR_FALSE, &ct);
printf("rv = %d\n", rv);
PR_ExplodeTime(ct, PR_GMTParameters, &et);
PrintExplodedTime(&et);
printf("\n");
rv = PR_ParseTimeString(sp2, PR_FALSE, &ct);
printf("rv = %d\n", rv);
PR_ExplodeTime(ct, PR_GMTParameters, &et);
PrintExplodedTime(&et);
printf("\n");
return 0;
}
示例3: PR_ExplodeTime
/** Returns a string containing a 11-digit random cookie based upon the
* current local time and the elapsed execution of the program.
* @param aCookie returned cookie string
* @return NS_OK on success
*/
NS_IMETHODIMP mozXMLTermUtils::RandomCookie(nsString& aCookie)
{
// Current local time
PRExplodedTime localTime;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &localTime);
PRInt32 randomNumberA = localTime.tm_sec*1000000+localTime.tm_usec;
PRIntervalTime randomNumberB = PR_IntervalNow();
XMLT_LOG(mozXMLTermUtils::RandomCookie,30,("ranA=0x%x, ranB=0x%x\n",
randomNumberA, randomNumberB));
PR_ASSERT(randomNumberA >= 0);
PR_ASSERT(randomNumberB >= 0);
static const char cookieDigits[17] = "0123456789abcdef";
char cookie[12];
int j;
for (j=0; j<6; j++) {
cookie[j] = cookieDigits[randomNumberA%16];
randomNumberA = randomNumberA/16;
}
for (j=6; j<11; j++) {
cookie[j] = cookieDigits[randomNumberB%16];
randomNumberB = randomNumberB/16;
}
cookie[11] = '\0';
aCookie.AssignASCII(cookie);
return NS_OK;
}
示例4: sv_PrintTime
int
sv_PrintTime(FILE *out, SECItem *t, char *m)
{
PRExplodedTime printableTime;
PRTime time;
char *timeString;
int rv;
rv = DER_DecodeTimeChoice(&time, t);
if (rv)
return rv;
/* Convert to local time */
PR_ExplodeTime(time, PR_LocalTimeParameters, &printableTime);
timeString = (char *)PORT_Alloc(256);
if (timeString) {
if (PR_FormatTime(timeString, 256, "%a %b %d %H:%M:%S %Y", &printableTime)) {
fprintf(out, "%s%s\n", m, timeString);
}
PORT_Free(timeString);
return 0;
}
return SECFailure;
}
示例5: __pmCertificateTimestamp
static int
__pmCertificateTimestamp(SECItem *vtime, char *buffer, size_t size)
{
PRExplodedTime exploded;
SECStatus secsts;
int64 itime;
switch (vtime->type) {
case siUTCTime:
secsts = DER_UTCTimeToTime(&itime, vtime);
break;
case siGeneralizedTime:
secsts = DER_GeneralizedTimeToTime(&itime, vtime);
break;
default:
return -EINVAL;
}
if (secsts != SECSuccess)
return __pmSecureSocketsError(PR_GetError());
/* Convert to local time */
PR_ExplodeTime(itime, PR_GMTParameters, &exploded);
if (!PR_FormatTime(buffer, size, "%a %b %d %H:%M:%S %Y", &exploded))
return __pmSecureSocketsError(PR_GetError());
return 0;
}
示例6: PR_ExplodeTime
void calDateTime::PRTimeToIcaltime(PRTime time, bool isdate,
icaltimezone const* tz,
icaltimetype * icalt)
{
PRExplodedTime et;
PR_ExplodeTime(time, PR_GMTParameters, &et);
icalt->year = et.tm_year;
icalt->month = et.tm_month + 1;
icalt->day = et.tm_mday;
if (isdate) {
icalt->hour = 0;
icalt->minute = 0;
icalt->second = 0;
icalt->is_date = 1;
} else {
icalt->hour = et.tm_hour;
icalt->minute = et.tm_min;
icalt->second = et.tm_sec;
icalt->is_date = 0;
}
icalt->zone = tz;
icalt->is_utc = ((tz && tz == icaltimezone_get_utc_timezone()) ? 1 : 0);
icalt->is_daylight = 0;
// xxx todo: discuss/investigate is_daylight
// if (tz) {
// icaltimezone_get_utc_offset(tz, icalt, &icalt->is_daylight);
// }
}
示例7: PrintTimeString
static void PrintTimeString(char *buf, PRUint32 bufsize, PRUint32 t_sec)
{
PRExplodedTime et;
PRTime t_usec = SecondsToPRTime(t_sec);
PR_ExplodeTime(t_usec, PR_LocalTimeParameters, &et);
PR_FormatTime(buf, bufsize, "%Y-%m-%d %H:%M:%S", &et);
}
示例8: Print
void Print(const char* aName, LogLevel aLevel, const char* aFmt, va_list aArgs)
{
const size_t kBuffSize = 1024;
char buff[kBuffSize];
char* buffToWrite = buff;
// For backwards compat we need to use the NSPR format string versions
// of sprintf and friends and then hand off to printf.
va_list argsCopy;
va_copy(argsCopy, aArgs);
size_t charsWritten = PR_vsnprintf(buff, kBuffSize, aFmt, argsCopy);
va_end(argsCopy);
if (charsWritten == kBuffSize - 1) {
// We may have maxed out, allocate a buffer instead.
buffToWrite = PR_vsmprintf(aFmt, aArgs);
charsWritten = strlen(buffToWrite);
}
// Determine if a newline needs to be appended to the message.
const char* newline = "";
if (charsWritten == 0 || buffToWrite[charsWritten - 1] != '\n') {
newline = "\n";
}
FILE* out = mOutFile ? mOutFile : stderr;
// This differs from the NSPR format in that we do not output the
// opaque system specific thread pointer (ie pthread_t) cast
// to a long. The address of the current PR_Thread continues to be
// prefixed.
//
// Additionally we prefix the output with the abbreviated log level
// and the module name.
if (!mAddTimestamp) {
fprintf_stderr(out,
"[%p]: %s/%s %s%s",
PR_GetCurrentThread(), ToLogStr(aLevel),
aName, buffToWrite, newline);
} else {
PRExplodedTime now;
PR_ExplodeTime(PR_Now(), PR_GMTParameters, &now);
fprintf_stderr(
out,
"%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - [%p]: %s/%s %s%s",
now.tm_year, now.tm_month + 1, now.tm_mday,
now.tm_hour, now.tm_min, now.tm_sec, now.tm_usec,
PR_GetCurrentThread(), ToLogStr(aLevel),
aName, buffToWrite, newline);
}
if (mIsSync) {
fflush(out);
}
if (buffToWrite != buff) {
PR_smprintf_free(buffToWrite);
}
}
示例9: strlen
//Framework logging - always log
void aptCoreTrace::LogF(eLogLevel eLevel, const char* str, const char* from)
{
if (!mCanLog) return;
size_t nlen = strlen(str) + 100;
char *msg = new char[nlen];
if (!msg)
{
// no memory
return;
}
PRTime curTime = PR_Now();
PRExplodedTime localTime;
PR_ExplodeTime(curTime, PR_LocalTimeParameters, &localTime);
PRUint32 nWritten = PR_snprintf(msg, nlen,
"%02d:%02d:%02d %02d/%02d/%04d [%6d] [%s] [%s] %s%s", // XXX i18n!
localTime.tm_hour, localTime.tm_min, localTime.tm_sec,
localTime.tm_month+1, localTime.tm_mday, localTime.tm_year,
mPid, gsLogLevel[eLevel], from, str,
#ifdef _WIN32
"\r\n"
#else
"\n"
#endif
);
mLC->WriteNewedLog(msg, nWritten);
}
示例10: PR_ExplodeTime
void xptiAutoLog::WriteTimestamp(PRFileDesc* fd, const char* msg)
{
PRExplodedTime expTime;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &expTime);
char time[128];
PR_FormatTimeUSEnglish(time, 128, "%Y-%m-%d-%H:%M:%S", &expTime);
PR_fprintf(fd, "\n%s %s\n\n", msg, time);
}
示例11: g_new0
NS_IMETHODIMP nsDiskinfo::AddCleanupItem(PRUint32 key, PRTime date) {
msg_hdr_t *hdr = g_new0(msg_hdr_t, 1);
hdr->key = key;
PR_ExplodeTime(date, PR_GMTParameters, &(hdr->date));
this->m_MsgList = g_slist_append(this->m_MsgList, hdr);
return NS_OK;
}
示例12: JzipOpen
/****************************************************************
*
* J z i p O p e n
*
* Opens a new ZIP file and creates a new ZIPfile structure to
* control the process of installing files into a zip.
*/
ZIPfile *
JzipOpen(char *filename, char *comment)
{
ZIPfile *zipfile;
PRExplodedTime prtime;
zipfile = PORT_ZAlloc(sizeof(ZIPfile));
if (!zipfile)
out_of_memory();
/* Construct time and date */
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prtime);
zipfile->date = ((prtime.tm_year - 1980) << 9) |
((prtime.tm_month + 1) << 5) |
prtime.tm_mday;
zipfile->time = (prtime.tm_hour << 11) |
(prtime.tm_min << 5) |
(prtime.tm_sec & 0x3f);
zipfile->fp = NULL;
if (filename &&
(zipfile->fp = PR_Open(filename,
PR_WRONLY |
PR_CREATE_FILE |
PR_TRUNCATE,
0777)) == NULL) {
char *nsprErr;
if (PR_GetErrorTextLength()) {
nsprErr = PR_Malloc(PR_GetErrorTextLength() + 1);
PR_GetErrorText(nsprErr);
} else {
nsprErr = NULL;
}
PR_fprintf(errorFD, "%s: can't open output jar, %s.%s\n",
PROGRAM_NAME,
filename, nsprErr ? nsprErr : "");
if (nsprErr)
PR_Free(nsprErr);
errorCount++;
exit(ERRX);
}
zipfile->list = NULL;
if (filename) {
zipfile->filename = PORT_ZAlloc(strlen(filename) + 1);
if (!zipfile->filename)
out_of_memory();
PORT_Strcpy(zipfile->filename, filename);
}
if (comment) {
zipfile->comment = PORT_ZAlloc(strlen(comment) + 1);
if (!zipfile->comment)
out_of_memory();
PORT_Strcpy(zipfile->comment, comment);
}
return zipfile;
}
示例13: display_conn_info
static void display_conn_info(struct connectdata *conn, PRFileDesc *sock)
{
SSLChannelInfo channel;
SSLCipherSuiteInfo suite;
CERTCertificate *cert;
char *subject, *issuer, *common_name;
PRExplodedTime printableTime;
char timeString[256];
PRTime notBefore, notAfter;
if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
SECSuccess && channel.length == sizeof channel &&
channel.cipherSuite) {
if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
&suite, sizeof suite) == SECSuccess) {
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
}
}
infof(conn->data, "Server certificate:\n");
cert = SSL_PeerCertificate(sock);
subject = CERT_NameToAscii(&cert->subject);
issuer = CERT_NameToAscii(&cert->issuer);
common_name = CERT_GetCommonName(&cert->subject);
infof(conn->data, "\tsubject: %s\n", subject);
CERT_GetCertTimes(cert, ¬Before, ¬After);
PR_ExplodeTime(notBefore, PR_GMTParameters, &printableTime);
PR_FormatTime(timeString, 256, "%b %d %H:%M:%S %Y GMT", &printableTime);
infof(conn->data, "\tstart date: %s\n", timeString);
PR_ExplodeTime(notAfter, PR_GMTParameters, &printableTime);
PR_FormatTime(timeString, 256, "%b %d %H:%M:%S %Y GMT", &printableTime);
infof(conn->data, "\texpire date: %s\n", timeString);
infof(conn->data, "\tcommon name: %s\n", common_name);
infof(conn->data, "\tissuer: %s\n", issuer);
PR_Free(subject);
PR_Free(issuer);
PR_Free(common_name);
CERT_DestroyCertificate(cert);
return;
}
示例14: SET_ERROR_RETURN
NS_IMETHODIMP
jxMySQL50Statement::BindDatetimeParameter(PRUint32 aParamIndex, PRUint32 aSecond)
{
if (mConnection == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED);
}
if (mSTMT == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL);
}
if (aParamIndex < 0 || aParamIndex >= mIn.mCount)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE);
}
if (mIn.mBindArrayBufferTYPE_DATE[aParamIndex] == nsnull)
mIn.mBindArrayBufferTYPE_DATE[aParamIndex] = static_cast<MYSQL_TIME*>(nsMemory::Alloc(sizeof(MYSQL_TIME)));
if (mIn.mBindArrayBufferTYPE_DATE[aParamIndex] == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_OUT_OF_MEMORY);
}
time_t t = (time_t) aSecond;
struct tm *tmptm = gmtime(&t);
// struct tm *tmpltm = localtime(&t);
#if 0
PRTime t = aSecond * 1000;
PRExplodedTime prtime;
PR_ExplodeTime(t, PR_LocalTimeParameters, &prtime);
#endif
MYSQL_TIME* mysqlTime = mIn.mBindArrayBufferTYPE_DATE[aParamIndex];
mysqlTime->year = tmptm->tm_year + 1900;
mysqlTime->month = tmptm->tm_mon + 1;
mysqlTime->day = tmptm->tm_mday;
mysqlTime->hour = tmptm->tm_hour;
mysqlTime->minute = tmptm->tm_min;
mysqlTime->second = tmptm->tm_sec;
mysqlTime->second_part = 0; /* mic's not supported in MySQL yet */
mysqlTime->neg = 0;
mysqlTime->time_type = MYSQL_TIMESTAMP_DATETIME;
mIn.mBIND[aParamIndex].buffer_type = MYSQL_TYPE_DATETIME;
mIn.mBIND[aParamIndex].buffer = mIn.mBindArrayBufferTYPE_DATE[aParamIndex];
mIn.mBIND[aParamIndex].length = 0;
mIn.mBIND[aParamIndex].length_value = lenOfMySQL_TIME;
mIn.mBIND[aParamIndex].buffer_length = lenOfMySQL_TIME;
return NS_OK;
}
示例15: PR_ExplodeTime
// performs a locale sensitive date formatting operation on the PRTime parameter
/*static*/ nsresult
DateTimeFormat::FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
const nsTimeFormatSelector aTimeFormatSelector,
const PRTime aPrTime,
nsAString& aStringOut)
{
PRExplodedTime explodedTime;
PR_ExplodeTime(aPrTime, PR_LocalTimeParameters, &explodedTime);
return FormatPRExplodedTime(aDateFormatSelector, aTimeFormatSelector, &explodedTime, aStringOut);
}