• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PR_snprintf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PR_snprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_snprintf函数的具体用法?C++ PR_snprintf怎么用?C++ PR_snprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PR_snprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetUniqueMaiAtkTypeName

static const char *
GetUniqueMaiAtkTypeName(PRUint16 interfacesBits)
{
#define MAI_ATK_TYPE_NAME_LEN (30)     /* 10+sizeof(PRUint16)*8/4+1 < 30 */

    static gchar namePrefix[] = "MaiAtkType";   /* size = 10 */
    static gchar name[MAI_ATK_TYPE_NAME_LEN + 1];

    PR_snprintf(name, MAI_ATK_TYPE_NAME_LEN, "%s%x", namePrefix,
                interfacesBits);
    name[MAI_ATK_TYPE_NAME_LEN] = '\0';

    MAI_LOG_DEBUG(("MaiWidget::LastedTypeName=%s\n", name));

    return name;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:16,代码来源:nsAccessibleWrap.cpp


示例2: ResourceAt

void
ResourceQueue::Dump(const char* aPath)
{
  for (uint32_t i = 0; i < uint32_t(GetSize()); ++i) {
    ResourceItem* item = ResourceAt(i);

    char buf[255];
    PR_snprintf(buf, sizeof(buf), "%s/%08u.bin", aPath, i);
    FILE* fp = fopen(buf, "wb");
    if (!fp) {
      return;
    }
    fwrite(item->mData->Elements(), item->mData->Length(), 1, fp);
    fclose(fp);
  }
}
开发者ID:Danielzac,项目名称:gecko-dev,代码行数:16,代码来源:ResourceQueue.cpp


示例3: PR_Now

void aptCoreTrace::LogBytes(eLogLevel eLevel, const char* data, size_t len)
{
    // Extra spaces for Date, PID, EOL etc
#ifdef _WIN32
    static const int nEXTRA = 34;
#else
    static const int nEXTRA = 33;
#endif
    if (!mCanLog) return;

    if (eLevel < mCoreLogLevel) return;
    
	PRTime curTime = PR_Now();
	PRExplodedTime localTime;
	PR_ExplodeTime(curTime, PR_LocalTimeParameters, &localTime);
    int nTotal = len + nEXTRA + strlen(gsLogLevel[eLevel]);

    char *buf = new char[nTotal];
    if (!buf) return;

    PRUint32 nWritten = PR_snprintf(buf, nTotal,
			"%02d:%02d:%02d %02d/%02d/%04d [%6d] [%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]);


    memcpy(buf+nWritten, data, len);

    nWritten += len;

#ifdef _WIN32
    buf[nWritten++] = '\r';
#endif
    buf[nWritten++] = '\n';
    
#ifdef _DEBUG
    if (nWritten != nTotal)
    {
        char tmp[50];
        sprintf(tmp, "nW=%d nT=%d\n", nWritten, nTotal);
        mLC->WriteLog(tmp, strlen(tmp));
    }
#endif

    mLC->WriteNewedLog(buf, nWritten);
}
开发者ID:aptana,项目名称:Jaxer,代码行数:47,代码来源:aptCoreTrace.cpp


示例4: 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


示例5: printf

void nsToolkit::GetInterface()
{
#ifdef DEBUG
  printf("TK-GI\n");
#endif
  if(! cached)
  {
    char portname[64];

    PR_snprintf(portname, sizeof(portname), "event%lx", 
                (long unsigned) mGuiThread);

    eventport = find_port(portname);

    cached = true;
  }
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:17,代码来源:nsToolkit.cpp


示例6: LOG

static void LOG(const char *fmt, ... )
{
  va_list ap;
  va_start(ap, fmt);
  PRUint32 nb = 0;
  char buf[512];

  nb = PR_snprintf(buf, sizeof(buf), "[%u:%p] ", GetPID(), PR_GetCurrentThread());

  PR_vsnprintf(buf + nb, sizeof(buf) - nb, fmt, ap);
  buf[sizeof(buf) - 1] = '\0';

  fwrite(buf, strlen(buf), 1, stdout);
  fflush(stdout);

  va_end(ap);
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:17,代码来源:TestIPCLocks.cpp


示例7: ensureTimezone

NS_IMETHODIMP
calDateTime::ToString(nsACString & aResult)
{
    nsAutoCString tzid;
    char buffer[256];

    ensureTimezone();
    mTimezone->GetTzid(tzid);

    uint32_t const length = PR_snprintf(
        buffer, sizeof(buffer), "%04hd/%02hd/%02hd %02hd:%02hd:%02hd %s isDate=%01hd nativeTime=%lld",
        mYear, mMonth + 1, mDay, mHour, mMinute, mSecond,
        tzid.get(), static_cast<int16_t>(mIsDate), mNativeTime);
    if (length != static_cast<uint32_t>(-1))
        aResult.Assign(buffer, length);
    return NS_OK;
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:17,代码来源:calDateTime.cpp


示例8: LoadEnvirFromIni

	SKERR LoadEnvirFromIni(const char * key = NULL)
	{
		static char ENV_INI[] = "sk.ini";
		static char ENV_SECTION[] = "envir";

		SKERR err        = noErr;
		char * homeDir = NULL;
		err = GetValue(SK_HOME_ENVIR_VAR, &homeDir);
		if(err != noErr || !homeDir || 0 == PL_strlen(homeDir))
		{
			return err_notfound;
		}

		char envirFilename[1024];
		PR_snprintf(envirFilename, sizeof envirFilename - 1, "%s/sk.ini", homeDir);
		SKTextFile iniFile;
		err = iniFile.SetFileName(envirFilename);
		if(err != noErr)
		{
			SKError(err_failure, "[SKTextFile::LoadEnvirFromIni] "
				"Failed to set filename, error = %d, envirFilename = %s", err, envirFilename);
		}

		IniParser parser(&iniFile);

		char* pszSection = NULL;
		char* pszName    = NULL;
		char* pszValue   = NULL;
		PRUint32 line = 0;
		while (    (err == noErr)
			&& parser.readIniLine(&pszSection, &pszName, &pszValue, &line))
		{
			if(NULL != pszValue && 0 == strcmp(pszSection, ENV_SECTION) && 
				(NULL == key || 0 == strcmp(key, pszName)) )
			{
				err = SetValue(pszName, pszValue);
				if(err != noErr)
					SKError(err_failure, "[SKTextFile::LoadEnvirFromIni] "
					"Stops parsing. Error %d on line %d of %s : %s/%s=%s",
					err, line, ENV_INI, pszSection, pszName, pszValue);
			}
		}
		return noErr;
	}
开发者ID:developercyrus,项目名称:skmobile,代码行数:44,代码来源:envir.cpp


示例9: PL_strncpy

const char *ConfigStore::GetConfig(const char *name)
{ 
	char buf[256];
        char *ret;
	if (m_root->getSet() ==NULL) {
		return NULL;
	}
	if (PL_strlen(m_substore_name) == 0) {
		PL_strncpy(buf,name,256);
	} else {
		PR_snprintf(buf,256,"%s.%s",m_substore_name,name);
	}

        PR_Lock(m_lock);
        ret = (char *)PL_HashTableLookupConst(m_root->getSet(), buf);
        PR_Unlock(m_lock);

	return ret;
}
开发者ID:encukou,项目名称:pki,代码行数:19,代码来源:ConfigStore.cpp


示例10: Java_org_mozilla_jss_ssl_SSLSocket_setCipherPreferenceDefault

JNIEXPORT void JNICALL
Java_org_mozilla_jss_ssl_SSLSocket_setCipherPreferenceDefault(
    JNIEnv *env, jclass clazz, jint cipher, jboolean enable)
{
    SECStatus status;

    /* set the preference */
    status = SSL_CipherPrefSetDefault(cipher, enable);
    if(status != SECSuccess) {
        char buf[128];
        PR_snprintf(buf, 128, "Failed to %s cipher 0x%lx\n",
            (enable ? "enable" : "disable"), cipher);
        JSSL_throwSSLSocketException(env, buf);
        goto finish;
    }

finish:
    return;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:19,代码来源:SSLSocket.c


示例11: InitLog

NS_IMETHODIMP 
nsDebugImpl::Warning(const char* aMessage,
                     const char* aFile, PRIntn aLine)
{
  InitLog();

  char buf[1000];
  PR_snprintf(buf, sizeof(buf),
              "WARNING: %s, file %s, line %d",
              aMessage, aFile, aLine);

  // Write out the warning message to the debug log
  PR_LOG(gDebugLog, PR_LOG_ERROR, ("%s", buf));

  // And write it out to the stdout
  fprintf(stderr, "%s\n", buf);
  fflush(stderr);
  return NS_OK;
}
开发者ID:bringhurst,项目名称:vbox,代码行数:19,代码来源:nsDebugImpl.cpp


示例12: PR_snprintf

void CMapiApi::GetPropTagName( ULONG tag, nsCString& s)
{
  char numStr[256];
  PR_snprintf( numStr, 256, "0x%lx, %ld", tag, tag);
  s = numStr;
  switch( tag) {
#include "mapitagstrs.cpp"
  }
  s += ", data: ";
  switch( PROP_TYPE( tag)) {
    case PT_UNSPECIFIED: s += "PT_UNSPECIFIED"; break;
    case PT_NULL: s += "PT_NULL"; break;
    case PT_I2: s += "PT_I2"; break;
    case PT_LONG: s += "PT_LONG"; break;
    case PT_R4: s += "PT_R4"; break;
    case PT_DOUBLE: s += "PT_DOUBLE"; break;
    case PT_CURRENCY: s += "PT_CURRENCY"; break;
    case PT_APPTIME: s += "PT_APPTIME"; break;
    case PT_ERROR: s += "PT_ERROR"; break;
    case PT_BOOLEAN: s += "PT_BOOLEAN"; break;
    case PT_OBJECT: s += "PT_OBJECT"; break;
    case PT_I8: s += "PT_I8"; break;
    case PT_STRING8: s += "PT_STRING8"; break;
    case PT_UNICODE: s += "PT_UNICODE"; break;
    case PT_SYSTIME: s += "PT_SYSTIME"; break;
    case PT_CLSID: s += "PT_CLSID"; break;
    case PT_BINARY: s += "PT_BINARY"; break;
    case PT_MV_I2: s += "PT_MV_I2"; break;
    case PT_MV_LONG: s += "PT_MV_LONG"; break;
    case PT_MV_R4: s += "PT_MV_R4"; break;
    case PT_MV_DOUBLE: s += "PT_MV_DOUBLE"; break;
    case PT_MV_CURRENCY: s += "PT_MV_CURRENCY"; break;
    case PT_MV_APPTIME: s += "PT_MV_APPTIME"; break;
    case PT_MV_SYSTIME: s += "PT_MV_SYSTIME"; break;
    case PT_MV_STRING8: s += "PT_MV_STRING8"; break;
    case PT_MV_BINARY: s += "PT_MV_BINARY"; break;
    case PT_MV_UNICODE: s += "PT_MV_UNICODE"; break;
    case PT_MV_CLSID: s += "PT_MV_CLSID"; break;
    case PT_MV_I8: s += "PT_MV_I8"; break;
    default:
      s += "Unknown";
  }
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:43,代码来源:MapiApi.cpp


示例13: _PR_MD_OPEN_DIR

PRStatus
_PR_MD_OPEN_DIR(_MDDir *d, const char *name)
{
    char filename[ CCHMAXPATH ];
    PRUword numEntries, rc;

    numEntries = 1;

    PR_snprintf(filename, CCHMAXPATH, "%s%s%s",
                name, PR_DIRECTORY_SEPARATOR_STR, "*.*");
    FlipSlashes( filename, strlen(filename) );

    d->d_hdl = HDIR_CREATE;

    if (isWSEB)
    {
        rc = DosFindFirst( filename,
                           &d->d_hdl,
                           FILE_DIRECTORY | FILE_HIDDEN,
                           &(d->d_entry.large),
                           sizeof(d->d_entry.large),
                           &numEntries,
                           FIL_STANDARDL);
    }
    else
    {
        rc = DosFindFirst( filename,
                           &d->d_hdl,
                           FILE_DIRECTORY | FILE_HIDDEN,
                           &(d->d_entry.small),
                           sizeof(d->d_entry.small),
                           &numEntries,
                           FIL_STANDARD);
    }
    if ( rc != NO_ERROR ) {
		_PR_MD_MAP_OPENDIR_ERROR(rc);
        return PR_FAILURE;
    }
    d->firstEntry = PR_TRUE;
    d->magic = _MD_MAGIC_DIR;
    return PR_SUCCESS;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:42,代码来源:os2io.c


示例14: _PR_MD_STAT

PRInt32
_PR_MD_STAT(const char *fn, struct stat *info)
{
    PRInt32 rv;
    char filename[CCHMAXPATH];

    PR_snprintf(filename, CCHMAXPATH, "%s", fn);
    FlipSlashes(filename, strlen(filename));

    rv = _stat((char*)filename, info);
    if (-1 == rv) {
        /*
         * Check for MSVC runtime library _stat() bug.
         * (It's really a bug in FindFirstFile().)
         * If a pathname ends in a backslash or slash,
         * e.g., c:\temp\ or c:/temp/, _stat() will fail.
         * Note: a pathname ending in a slash (e.g., c:/temp/)
         * can be handled by _stat() on NT but not on Win95.
         *
         * We remove the backslash or slash at the end and
         * try again.  
         *
         * Not sure if this happens on OS/2 or not,
         * but it doesn't hurt to be careful.
         */

        int len = strlen(fn);
        if (len > 0 && len <= _MAX_PATH
                && (fn[len - 1] == '\\' || fn[len - 1] == '/')) {
            char newfn[_MAX_PATH + 1];

            strcpy(newfn, fn);
            newfn[len - 1] = '\0';
            rv = _stat(newfn, info);
        }
    }

    if (-1 == rv) {
        _PR_MD_MAP_STAT_ERROR(errno);
    }
    return rv;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:42,代码来源:os2io.c


示例15: DLLErrorInternal

static void DLLErrorInternal(PRIntn oserr)
/*
** This whole function, and most of the code in this file, are run
** with a big hairy lock wrapped around it. Not the best of situations,
** but will eventually come up with the right answer.
*/
{
    const char *error = NULL;
#ifdef USE_DLFCN
    error = dlerror();  /* $$$ That'll be wrong some of the time - AOF */
#elif defined(HAVE_STRERROR)
    error = strerror(oserr);  /* this should be okay */
#else
    char errStrBuf[ERR_STR_BUF_LENGTH];
    PR_snprintf(errStrBuf, sizeof(errStrBuf), "error %d", oserr);
    error = errStrBuf;
#endif
    if (NULL != error)
        PR_SetErrorText(strlen(error), error);
}  /* DLLErrorInternal */
开发者ID:sahlberg,项目名称:timberwolf,代码行数:20,代码来源:prlink.c


示例16: ldbm_instance_config_instance_dir_get

static void *
ldbm_instance_config_instance_dir_get(void *arg)
{
    ldbm_instance *inst = (ldbm_instance *)arg;

    if (inst->inst_dir_name == NULL)
        return slapi_ch_strdup("");
    else if (inst->inst_parent_dir_name)
    {
        int len = strlen(inst->inst_parent_dir_name) +
                  strlen(inst->inst_dir_name) + 2;
        char *full_inst_dir = (char *)slapi_ch_malloc(len);
        PR_snprintf(full_inst_dir, len, "%s%c%s",
            inst->inst_parent_dir_name, get_sep(inst->inst_parent_dir_name),
            inst->inst_dir_name);
        return full_inst_dir;
    }
    else 
        return slapi_ch_strdup(inst->inst_dir_name);
}
开发者ID:ohamada,项目名称:389ds,代码行数:20,代码来源:ldbm_instance_config.c


示例17: PR_snprintf

void
nsMathMLmactionFrame::MouseClick()
{
  if (NS_MATHML_ACTION_TYPE_TOGGLE == mActionType) {
    if (mChildCount > 1) {
      int32_t selection = (mSelection == mChildCount)? 1 : mSelection + 1;
      nsAutoString value;
      char cbuf[10];
      PR_snprintf(cbuf, sizeof(cbuf), "%d", selection);
      value.AssignASCII(cbuf);
      bool notify = false; // don't yet notify the document
      mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::selection_, value, notify);

      // Now trigger a content-changed reflow...
      PresContext()->PresShell()->
        FrameNeedsReflow(mSelectedFrame, nsIPresShell::eTreeChange,
                         NS_FRAME_IS_DIRTY);
    }
  }
}
开发者ID:at13,项目名称:mozilla-central,代码行数:20,代码来源:nsMathMLmactionFrame.cpp


示例18: Java_org_mozilla_jss_ssl_SSLSocket_getCipherPreferenceDefault

JNIEXPORT jboolean JNICALL
Java_org_mozilla_jss_ssl_SSLSocket_getCipherPreferenceDefault(
    JNIEnv *env, jclass clazz, jint cipher)
{
    SECStatus status;
    PRBool enabled;

    /* get the preference */
    status = SSL_CipherPrefGetDefault(cipher, &enabled);
    if(status != SECSuccess) {
        char buf[128];
        PR_snprintf(buf, 128, "Failed to get default preference for "
            "cipher 0x%lx\n", cipher);
        JSSL_throwSSLSocketException(env, buf);
        goto finish;
    }

finish:
    return enabled;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:20,代码来源:SSLSocket.c


示例19: 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


示例20: ldbm_instance_add_instance_entry_callback

int
ldbm_instance_add_instance_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg) 
{
    char *instance_name;
    struct ldbm_instance *inst= NULL;
    struct ldbminfo *li= (struct ldbminfo *) arg;
    int rc = 0;

    parse_ldbm_instance_entry(entryBefore, &instance_name);

    /* Make sure we don't create two instances with the same name. */
    inst = ldbm_instance_find_by_name(li, instance_name);
    if (inst != NULL) {
        LDAPDebug(LDAP_DEBUG_ANY, "WARNING: ldbm instance %s already exists\n",
                  instance_name, 0, 0);
        if (returntext != NULL)
            PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "An ldbm instance with the name %s already exists\n",
                    instance_name);
        if (returncode != NULL)
            *returncode = LDAP_UNWILLING_TO_PERFORM;
        slapi_ch_free((void **)&instance_name);
        return SLAPI_DSE_CALLBACK_ERROR;
    }

    if (pb == NULL) {
        /* called during startup -- do the rest now */
        rc = ldbm_instance_generate(li, instance_name, NULL);
        if (!rc) {
            inst = ldbm_instance_find_by_name(li, instance_name);
            rc = ldbm_instance_create_default_user_indexes(inst);
        }
    }
    /* if called during a normal ADD operation, the postadd callback
     * will do the rest.
     */

    slapi_ch_free((void **)&instance_name);
    return (rc == 0) ? SLAPI_DSE_CALLBACK_OK : SLAPI_DSE_CALLBACK_ERROR;
}
开发者ID:ohamada,项目名称:389ds,代码行数:39,代码来源:ldbm_instance_config.c



注:本文中的PR_snprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PR_sscanf函数代码示例发布时间:2022-05-30
下一篇:
C++ PR_smprintf_free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap