本文整理汇总了C++中PR_sscanf函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_sscanf函数的具体用法?C++ PR_sscanf怎么用?C++ PR_sscanf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_sscanf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char* argv[])
{
if (test_common_init(&argc, &argv) != 0)
return -1;
nsresult rv;
if (argc < 4) {
printf("usage: %s <file-to-read> <start-offset> <read-length>\n", argv[0]);
return -1;
}
char* fileName = argv[1];
int64_t offset, length;
int err = PR_sscanf(argv[2], "%lld", &offset);
if (err == -1) {
printf("Start offset must be an integer!\n");
return 1;
}
err = PR_sscanf(argv[3], "%lld", &length);
if (err == -1) {
printf("Length must be an integer!\n");
return 1;
}
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
if (registrar)
registrar->AutoRegister(nullptr);
#if defined(PR_LOGGING)
gTestLog = PR_NewLogModule("Test");
#endif
nsCOMPtr<nsIFile> file;
rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
rv = RunTest(file, offset, length);
NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
// give background threads a chance to finish whatever work they may
// be doing.
PR_Sleep(PR_SecondsToInterval(1));
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nullptr);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return NS_OK;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:53,代码来源:TestStreamPump.cpp
示例2: narrow
NS_IMETHODIMP sbDatetimePropertyInfo::MakeSearchable(const nsAString & aValue, nsAString & _retval)
{
nsresult rv;
PRInt64 value = 0;
NS_ConvertUTF16toUTF8 narrow(aValue);
_retval = aValue;
_retval.StripWhitespace();
sbSimpleAutoLock lock(mMinMaxDateTimeLock);
if(PR_sscanf(narrow.get(), gsFmtRadix10, &value) != 1) {
_retval = EmptyString();
return NS_ERROR_INVALID_ARG;
}
char out[32] = {0};
if(PR_snprintf(out, 32, gsSortFmtRadix10, value) == (PRUint32)-1) {
rv = NS_ERROR_FAILURE;
_retval = EmptyString();
}
else {
NS_ConvertUTF8toUTF16 wide(out);
rv = NS_OK;
_retval = wide;
}
return rv;
}
开发者ID:Brijen,项目名称:nightingale-hacking,代码行数:29,代码来源:sbDatetimePropertyInfo.cpp
示例3: narrow
int32_t
nsAString::ToInteger(nsresult *aErrorCode, uint32_t aRadix) const
{
NS_ConvertUTF16toUTF8 narrow(*this);
const char *fmt;
switch (aRadix) {
case 10:
fmt = "%i";
break;
case 16:
fmt = "%x";
break;
default:
NS_ERROR("Unrecognized radix!");
*aErrorCode = NS_ERROR_INVALID_ARG;
return 0;
}
int32_t result = 0;
if (PR_sscanf(narrow.get(), fmt, &result) == 1)
*aErrorCode = NS_OK;
else
*aErrorCode = NS_ERROR_FAILURE;
return result;
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:29,代码来源:nsStringAPI.cpp
示例4: switch
int64_t
nsACString::ToInteger64(nsresult *aErrorCode, uint32_t aRadix) const
{
const char *fmt;
switch (aRadix) {
case 10:
fmt = "%lli";
break;
case 16:
fmt = "%llx";
break;
default:
NS_ERROR("Unrecognized radix!");
*aErrorCode = NS_ERROR_INVALID_ARG;
return 0;
}
int64_t result = 0;
if (PR_sscanf(nsCString(*this).get(), fmt, &result) == 1)
*aErrorCode = NS_OK;
else
*aErrorCode = NS_ERROR_FAILURE;
return result;
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:27,代码来源:nsStringAPI.cpp
示例5: NS_WARNING
/**
* Reads one table of results from the response. Leaves begin pointing at the
* next table.
*/
nsresult
nsUrlClassifierHashCompleterRequest::HandleTable(nsACString::const_iterator& begin,
const nsACString::const_iterator& end)
{
nsACString::const_iterator iter;
iter = begin;
if (!FindCharInReadable(':', iter, end)) {
// No table line.
NS_WARNING("Received badly-formatted gethash response.");
return NS_ERROR_FAILURE;
}
const nsCSubstring& tableName = Substring(begin, iter);
iter++;
begin = iter;
if (!FindCharInReadable('\n', iter, end)) {
// Unterminated header line.
NS_WARNING("Received badly-formatted gethash response.");
return NS_ERROR_FAILURE;
}
const nsCSubstring& remaining = Substring(begin, iter);
iter++;
begin = iter;
PRUint32 chunkId;
PRInt32 size;
if (PR_sscanf(PromiseFlatCString(remaining).get(),
"%u:%d", &chunkId, &size) != 2) {
NS_WARNING("Received badly-formatted gethash response.");
return NS_ERROR_FAILURE;
}
if (size % COMPLETE_LENGTH != 0) {
NS_WARNING("Unexpected gethash response length");
return NS_ERROR_FAILURE;
}
// begin now refers to the hash data.
if (begin.size_forward() < size) {
NS_WARNING("Response does not match the expected response length.");
return NS_ERROR_FAILURE;
}
for (PRInt32 i = 0; i < (size / COMPLETE_LENGTH); i++) {
// Read the complete hash.
iter.advance(COMPLETE_LENGTH);
nsresult rv = HandleItem(Substring(begin, iter), tableName, chunkId);
NS_ENSURE_SUCCESS(rv, rv);
begin = iter;
}
// begin now points at the end of the hash data.
return NS_OK;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:64,代码来源:nsUrlClassifierHashCompleter.cpp
示例6: ParseVersion
static PRUint32 ParseVersion(const char *versionStr)
{
PRUint16 major, minor;
if (PR_sscanf(versionStr, "%hu.%hu", &major, &minor) != 2) {
NS_WARNING("invalid version string");
return 0;
}
return PRUint32(major) << 16 | PRUint32(minor);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:10,代码来源:nsXULRunnerApp.cpp
示例7: while
nsresult
mozSqlResultODBC::BuildRows()
{
while (SQL_SUCCEEDED(SQLFetch(mResult))) {
nsCOMPtr<nsIRDFResource> resource;
nsresult rv = gRDFService->GetAnonymousResource(getter_AddRefs(resource));
if (NS_FAILED(rv)) return rv;
Row* row = Row::Create(mAllocator, resource, mColumnInfo);
for (PRInt32 j = 0; j < mColumnInfo.Count(); j++) {
SQLINTEGER indicator;
SQLCHAR buf[512];
if(SQL_SUCCEEDED(SQLGetData(mResult, j+1, SQL_C_TCHAR, buf, sizeof(buf), &indicator)) && indicator != SQL_NULL_DATA) {
char* value = (char*)buf;
Cell* cell = row->mCells[j];
cell->SetNull(PR_FALSE);
PRInt32 type = cell->GetType();
if (type == mozISqlResult::TYPE_STRING)
cell->SetString(ToNewUnicode(nsDependentCString(value)));
else if (type == mozISqlResult::TYPE_INT)
PR_sscanf(value, "%d", &cell->mInt);
else if (type == mozISqlResult::TYPE_FLOAT)
PR_sscanf(value, "%f", &cell->mFloat);
else if (type == mozISqlResult::TYPE_DECIMAL)
PR_sscanf(value, "%f", &cell->mFloat);
else if (type == mozISqlResult::TYPE_DATE ||
type == mozISqlResult::TYPE_TIME ||
type == mozISqlResult::TYPE_DATETIME)
PR_ParseTimeString(value, PR_FALSE, &cell->mDate);
else if (type == mozISqlResult::TYPE_BOOL)
cell->mBool = !strcmp(value, "t");
}
}
mRows.AppendElement(row);
nsVoidKey key(resource);
mSources.Put(&key, row);
}
return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:43,代码来源:mozSqlResultODBC.cpp
示例8:
NS_IMETHODIMP
nsInstallVersion::Init(const nsString& version)
{
mMajor = mMinor = mRelease = mBuild = 0;
// nsString is a flat string
if (PR_sscanf(NS_ConvertUTF16toUTF8(version).get(),"%d.%d.%d.%d",&mMajor,&mMinor,&mRelease,&mBuild) < 1)
return NS_ERROR_UNEXPECTED;
return NS_OK;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:11,代码来源:nsInstallVersion.cpp
示例9: if
void
nsUrlClassifierUtils::CanonicalNum(const nsACString& num,
uint32_t bytes,
bool allowOctal,
nsACString& _retval)
{
_retval.Truncate();
if (num.Length() < 1) {
return;
}
uint32_t val;
if (allowOctal && IsOctal(num)) {
if (PR_sscanf(PromiseFlatCString(num).get(), "%o", &val) != 1) {
return;
}
} else if (IsDecimal(num)) {
if (PR_sscanf(PromiseFlatCString(num).get(), "%u", &val) != 1) {
return;
}
} else if (IsHex(num)) {
if (PR_sscanf(PromiseFlatCString(num).get(), num[1] == 'X' ? "0X%x" : "0x%x",
&val) != 1) {
return;
}
} else {
return;
}
while (bytes--) {
char buf[20];
PR_snprintf(buf, sizeof(buf), "%u", val & 0xff);
if (_retval.IsEmpty()) {
_retval.Assign(buf);
} else {
_retval = nsDependentCString(buf) + NS_LITERAL_CSTRING(".") + _retval;
}
val >>= 8;
}
}
开发者ID:MekliCZ,项目名称:positron,代码行数:41,代码来源:nsUrlClassifierUtils.cpp
示例10: while
nsresult
mozSqlResultMysql::BuildRows()
{
MYSQL_ROW resultrow;
while ((resultrow = mysql_fetch_row(mResult))){
nsCOMPtr<nsIRDFResource> resource;
nsresult rv = gRDFService->GetAnonymousResource(getter_AddRefs(resource));
if (NS_FAILED(rv)) return rv;
Row* row = Row::Create(mAllocator, resource, mColumnInfo);
for (PRInt32 j = 0; j < mColumnInfo.Count(); j++) {
char* value = resultrow[j];
if (value){
Cell* cell = row->mCells[j];
cell->SetNull(PR_FALSE);
PRInt32 type = cell->GetType();
if (type == mozISqlResult::TYPE_STRING)
cell->SetString(UTF8ToNewUnicode(nsDependentCString(value)));
else if (type == mozISqlResult::TYPE_INT)
PR_sscanf(value, "%d", &cell->mInt);
else if (type == mozISqlResult::TYPE_FLOAT)
PR_sscanf(value, "%f", &cell->mFloat);
else if (type == mozISqlResult::TYPE_DECIMAL)
PR_sscanf(value, "%f", &cell->mFloat);
else if (type == mozISqlResult::TYPE_DATE ||
type == mozISqlResult::TYPE_TIME ||
type == mozISqlResult::TYPE_DATETIME)
PR_ParseTimeString(value, PR_FALSE, &cell->mDate);
else if (type == mozISqlResult::TYPE_BOOL)
cell->mBool = !strcmp(value, "t");
}
}
mRows.AppendElement(row);
nsVoidKey key(resource);
mSources.Put(&key, row);
}
return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:41,代码来源:mozSqlResultMysql.cpp
示例11: PR_sscanf
nsresult
SdpHelper::GetComponent(const std::string& candidate, size_t* component)
{
unsigned int temp;
int32_t result = PR_sscanf(candidate.c_str(), "%*s %u", &temp);
if (result == 1) {
*component = temp;
return NS_OK;
}
SDP_SET_ERROR("Malformed ICE candidate: " << candidate);
return NS_ERROR_INVALID_ARG;
}
开发者ID:rthyberg,项目名称:gecko-dev,代码行数:12,代码来源:SdpHelper.cpp
示例12: return
/* static */ bool
LookupCache::IsCanonicalizedIP(const nsACString& aHost)
{
// The canonicalization process will have left IP addresses in dotted
// decimal with no surprises.
uint32_t i1, i2, i3, i4;
char c;
if (PR_sscanf(PromiseFlatCString(aHost).get(), "%u.%u.%u.%u%c",
&i1, &i2, &i3, &i4, &c) == 4) {
return (i1 <= 0xFF && i2 <= 0xFF && i3 <= 0xFF && i4 <= 0xFF);
}
return false;
}
开发者ID:afabbro,项目名称:gecko-dev,代码行数:14,代码来源:LookupCache.cpp
示例13: get_post_assertion_data
char * get_post_assertion_data(Session *sn, Request *rq, char *url)
{
int i = 0;
char *body = NULL;
int cl = 0;
char *cl_str = NULL;
/**
* content length and body
*
* note: memory allocated in here should be released by
* other function such as: "policy_unregister_post"
*/
request_header("content-length", &cl_str, sn, rq);
if(cl_str == NULL)
cl_str = pblock_findval("content-length", rq->headers);
if(cl_str == NULL)
return body;
if(PR_sscanf(cl_str, "%ld", &cl) == 1) {
body = (char *)malloc(cl + 1);
if(body != NULL){
for (i = 0; i < cl; i++) {
int ch = netbuf_getc(sn->inbuf);
if (ch==IO_ERROR || ch == IO_EOF) {
break;
}
body[i] = ch;
}
body[i] = '\0';
}
} else {
am_web_log_error("Error reading POST content body");
}
am_web_log_max_debug("Read POST content body : %s", body);
/**
* need to reset content length before redirect,
* otherwise, web server will wait for serveral minutes
* for non existant data
*/
param_free(pblock_remove("content-length", rq->headers));
pblock_nvinsert("content-length", "0", rq->headers);
return body;
}
开发者ID:dromero91,项目名称:openam,代码行数:49,代码来源:web_agent.c
示例14: TimelineInit
PRStatus TimelineInit(void)
{
char *timeStr;
char *fileName;
PRInt32 secs, msecs;
PRFileDesc *fd;
PRInt64 tmp1, tmp2;
PRStatus status = PR_NewThreadPrivateIndex( &gTLSIndex, ThreadDestruct );
NS_WARN_IF_FALSE(status==0, "TimelineService could not allocate TLS storage.");
timeStr = PR_GetEnv("NS_TIMELINE_INIT_TIME");
#ifdef XP_MAC
initInterval = PR_IntervalNow();
#endif
// NS_TIMELINE_INIT_TIME only makes sense for the main thread, so if it
// exists, set it there. If not, let normal thread management code take
// care of setting the init time.
if (timeStr != NULL && 2 == PR_sscanf(timeStr, "%d.%d", &secs, &msecs)) {
PRTime &initTime = GetThisThreadData()->initTime;
LL_MUL(tmp1, (PRInt64)secs, 1000000);
LL_MUL(tmp2, (PRInt64)msecs, 1000);
LL_ADD(initTime, tmp1, tmp2);
#ifdef XP_MAC
initInterval -= PR_MicrosecondsToInterval(
(PRUint32)(PR_Now() - initTime));
#endif
}
// Get the log file.
#ifdef XP_MAC
fileName = "timeline.txt";
#else
fileName = PR_GetEnv("NS_TIMELINE_LOG_FILE");
#endif
if (fileName != NULL
&& (fd = PR_Open(fileName, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
0666)) != NULL) {
timelineFD = fd;
PR_fprintf(fd,
"NOTE: due to asynchrony, the indentation that you see does"
" not necessarily correspond to nesting in the code.\n\n");
}
// Runtime disable of timeline
if (PR_GetEnv("NS_TIMELINE_ENABLE"))
gTimelineDisabled = PR_FALSE;
return PR_SUCCESS;
}
开发者ID:jeppeter,项目名称:vbox,代码行数:48,代码来源:nsTimelineService.cpp
示例15: nssUTF8_Size
NSS_IMPLEMENT CK_VERSION
nss_dbm_db_get_format_version
(
nss_dbm_db_t *db
)
{
CK_VERSION rv;
DBT k, v;
int dbrv;
char buffer[64];
rv.major = rv.minor = 0;
k.data = PREFIX_METADATA "FormatVersion";
k.size = nssUTF8_Size((NSSUTF8 *)k.data, (PRStatus *)NULL);
(void)memset(&v, 0, sizeof(v));
/* Locked region */
{
if( CKR_OK != NSSCKFWMutex_Lock(db->crustylock) ) {
return rv;
}
dbrv = db->db->get(db->db, &k, &v, 0);
if( dbrv == 0 ) {
CK_ULONG major = 0, minor = 0;
(void)PR_sscanf(v.data, "%ld.%ld", &major, &minor);
rv.major = major;
rv.minor = minor;
} else if( dbrv > 0 ) {
(void)PR_snprintf(buffer, sizeof(buffer), "%ld.%ld", nss_dbm_db_format_version.major,
nss_dbm_db_format_version.minor);
v.data = buffer;
v.size = nssUTF8_Size((NSSUTF8 *)v.data, (PRStatus *)NULL);
dbrv = db->db->put(db->db, &k, &v, 0);
(void)db->db->sync(db->db, 0);
rv = nss_dbm_db_format_version;
} else {
/* No error return.. */
;
}
(void)NSSCKFWMutex_Unlock(db->crustylock);
}
return rv;
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:47,代码来源:db.c
示例16: sizeof
// Decode Q encoding (RFC 2047).
// static
char *DecodeQ(const char *in, PRUint32 length)
{
char *out, *dest = 0;
out = dest = (char *)PR_Calloc(length + 1, sizeof(char));
if (dest == nsnull)
return nsnull;
while (length > 0) {
PRUintn c = 0;
switch (*in) {
case '=':
// check if |in| in the form of '=hh' where h is [0-9a-fA-F].
if (length < 3 || !ISHEXCHAR(in[1]) || !ISHEXCHAR(in[2]))
goto badsyntax;
PR_sscanf(in + 1, "%2X", &c);
*out++ = (char) c;
in += 3;
length -= 3;
break;
case '_':
*out++ = ' ';
in++;
length--;
break;
default:
if (*in & 0x80) goto badsyntax;
*out++ = *in++;
length--;
}
}
*out++ = '\0';
for (out = dest; *out ; ++out) {
if (*out == '\t')
*out = ' ';
}
return dest;
badsyntax:
PR_Free(dest);
return nsnull;
}
开发者ID:mmmulani,项目名称:v8monkey,代码行数:47,代码来源:nsMIMEHeaderParamImpl.cpp
示例17: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP sbDatetimePropertyInfo::Validate(const nsAString & aValue, bool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
PRInt64 value = 0;
NS_ConvertUTF16toUTF8 narrow(aValue);
*_retval = PR_TRUE;
if(PR_sscanf(narrow.get(), gsFmtRadix10, &value) != 1) {
*_retval = PR_FALSE;
return NS_OK;
}
sbSimpleAutoLock lock(mMinMaxDateTimeLock);
if(value < mMinDateTime ||
value > mMaxDateTime) {
*_retval = PR_FALSE;
}
return NS_OK;
}
开发者ID:Brijen,项目名称:nightingale-hacking,代码行数:21,代码来源:sbDatetimePropertyInfo.cpp
示例18: getter_Copies
void
nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, bool remove)
{
nsXPIDLCString portList;
// Get a pref string and chop it up into a list of ports.
prefBranch->GetCharPref(pref, getter_Copies(portList));
if (portList) {
nsTArray<nsCString> portListArray;
ParseString(portList, ',', portListArray);
uint32_t index;
for (index=0; index < portListArray.Length(); index++) {
portListArray[index].StripWhitespace();
int32_t portBegin, portEnd;
if (PR_sscanf(portListArray[index].get(), "%d-%d", &portBegin, &portEnd) == 2) {
if ((portBegin < 65536) && (portEnd < 65536)) {
int32_t curPort;
if (remove) {
for (curPort=portBegin; curPort <= portEnd; curPort++)
mRestrictedPortList.RemoveElement(curPort);
} else {
for (curPort=portBegin; curPort <= portEnd; curPort++)
mRestrictedPortList.AppendElement(curPort);
}
}
} else {
nsresult aErrorCode;
int32_t port = portListArray[index].ToInteger(&aErrorCode);
if (NS_SUCCEEDED(aErrorCode) && port < 65536) {
if (remove)
mRestrictedPortList.RemoveElement(port);
else
mRestrictedPortList.AppendElement(port);
}
}
}
}
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:40,代码来源:nsIOService.cpp
示例19: _md_ImportFileMapFromString
extern PRFileMap * _md_ImportFileMapFromString(
const char *fmstring
)
{
PRStatus rc;
PRInt32 osfd;
PRIntn prot; /* really: a PRFileMapProtect */
PRFileDesc *fd;
PRFileMap *fm = NULL; /* default return value */
PRFileInfo64 info;
PR_sscanf( fmstring, "%ld:%d", &osfd, &prot );
/* import the os file descriptor */
fd = PR_ImportFile( osfd );
if ( NULL == fd ) {
PR_LOG( _pr_shma_lm, PR_LOG_DEBUG,
("_md_ImportFileMapFromString(): PR_ImportFile() failed"));
goto Finished;
}
rc = PR_GetOpenFileInfo64( fd, &info );
if ( PR_FAILURE == rc ) {
PR_LOG( _pr_shma_lm, PR_LOG_DEBUG,
("_md_ImportFileMapFromString(): PR_GetOpenFileInfo64() failed"));
goto Finished;
}
fm = PR_CreateFileMap( fd, info.size, (PRFileMapProtect)prot );
if ( NULL == fm ) {
PR_LOG( _pr_shma_lm, PR_LOG_DEBUG,
("_md_ImportFileMapFromString(): PR_CreateFileMap() failed"));
}
Finished:
return(fm);
} /* end _md_ImportFileMapFromString() */
开发者ID:edrikL,项目名称:gears,代码行数:37,代码来源:uxshm.c
示例20: NS_ENSURE_ARG_POINTER
nsresult
sbDeviceStatistics::UpdateForItem(sbIMediaItem* aMediaItem,
PRBool aItemAdded)
{
// Validate arguments.
NS_ENSURE_ARG_POINTER(aMediaItem);
// Function variables.
nsresult rv;
// Ignore media lists.
nsCOMPtr<sbIMediaList> mediaList = do_QueryInterface(aMediaItem, &rv);
if (NS_SUCCEEDED(rv))
return NS_OK;
// Get the item content type.
PRUint32 contentType;
rv = mBaseDevice->GetItemContentType(aMediaItem, &contentType);
if (NS_FAILED(rv)) {
contentType = sbIDeviceCapabilities::CONTENT_UNKNOWN;
}
// Get the item count update value.
PRInt32 itemCountUpdate;
if (aItemAdded)
itemCountUpdate = 1;
else
itemCountUpdate = -1;
// Get the item used update value.
PRInt64 itemUsedUpdate;
rv = aMediaItem->GetContentLength(&itemUsedUpdate);
NS_ENSURE_SUCCESS(rv, rv);
if (!aItemAdded)
itemUsedUpdate = -itemUsedUpdate;
// Get the item play time update value.
PRInt64 itemPlayTimeUpdate = 0;
nsAutoString duration;
rv = aMediaItem->GetProperty(NS_LITERAL_STRING(SB_PROPERTY_DURATION),
duration);
if (NS_SUCCEEDED(rv)) {
if (PR_sscanf(NS_ConvertUTF16toUTF8(duration).get(),
"%lld",
&itemPlayTimeUpdate) == 0) {
itemPlayTimeUpdate = 0;
}
}
if (!aItemAdded)
itemPlayTimeUpdate = -itemPlayTimeUpdate;
// Update appropriate statistics depending upon the content type.
// Statistics for other content types will be collected together elsewhere
// in the total other statistics.
if (contentType == sbIDeviceCapabilities::CONTENT_AUDIO) {
AddAudioCount(itemCountUpdate);
AddAudioUsed(itemUsedUpdate);
AddAudioPlayTime(itemPlayTimeUpdate);
} else if (contentType == sbIDeviceCapabilities::CONTENT_VIDEO) {
AddVideoCount(itemCountUpdate);
AddVideoUsed(itemUsedUpdate);
AddVideoPlayTime(itemPlayTimeUpdate);
}
return NS_OK;
}
开发者ID:AntoineTurmel,项目名称:nightingale-hacking,代码行数:66,代码来源:sbDeviceStatistics.cpp
注:本文中的PR_sscanf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论