当前位置: 首页>>代码示例>>C++>>正文


C++ seprintf函数代码示例

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


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

示例1: SunOSStackWalker

    /**
     * Callback used while walking up the stack.
     * @param pc program counter
     * @param sig 'active' signal (unused)
     * @param params parameters
     * @return always 0, continue walking up the stack
     */
    static int SunOSStackWalker(uintptr_t pc, int sig, void *params)
    {
        StackWalkerParams *wp = (StackWalkerParams *)params;

        /* Resolve program counter to file and nearest symbol (if possible) */
        Dl_info dli;
        if (dladdr((void *)pc, &dli) != 0) {
            *wp->bufptr += seprintf(*wp->bufptr, wp->last, " [%02i] %s(%s+0x%x) [0x%x]\n",
                                    wp->counter, dli.dli_fname, dli.dli_sname, (int)((byte *)pc - (byte *)dli.dli_saddr), (uint)pc);
        } else {
            *wp->bufptr += seprintf(*wp->bufptr, wp->last, " [%02i] [0x%x]\n", wp->counter, (uint)pc);
        }
        wp->counter++;

        return 0;
    }
开发者ID:Voxar,项目名称:OpenTTD,代码行数:23,代码来源:crashlog_unix.cpp

示例2: CmdRenamePresident

/**
 * Change the name of the president.
 * @param tile unused
 * @param flags operation to perform
 * @param p1 unused
 * @param p2 unused
 * @param text the new name or an empty string when resetting to the default
 * @return the cost of this operation or an error
 */
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
	bool reset = StrEmpty(text);

	if (!reset) {
		if (Utf8StringLength(text) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) return CMD_ERROR;
		if (!IsUniquePresidentName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
	}

	if (flags & DC_EXEC) {
		Company *c = Company::Get(_current_company);
		free(c->president_name);

		if (reset) {
			c->president_name = NULL;
		} else {
			c->president_name = stredup(text);

			if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) {
				char buf[80];

				seprintf(buf, lastof(buf), "%s Transport", text);
				DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, buf);
			}
		}

		MarkWholeScreenDirty();
		CompanyAdminUpdate(c);
	}

	return CommandCost();
}
开发者ID:TeddyDesTodes,项目名称:openttd,代码行数:41,代码来源:company_cmd.cpp

示例3: strecpy

/**
 * Get the address as a string, e.g. 127.0.0.1:12345.
 * @param buffer the buffer to write to
 * @param last the last element in the buffer
 * @param with_family whether to add the family (e.g. IPvX).
 */
void NetworkAddress::GetAddressAsString(char *buffer, const char *last, bool with_family)
{
	if (this->GetAddress()->ss_family == AF_INET6) buffer = strecpy(buffer, "[", last);
	buffer = strecpy(buffer, this->GetHostname(), last);
	if (this->GetAddress()->ss_family == AF_INET6) buffer = strecpy(buffer, "]", last);
	buffer += seprintf(buffer, last, ":%d", this->GetPort());

	if (with_family) {
		char family;
		switch (this->address.ss_family) {
			case AF_INET:  family = '4'; break;
			case AF_INET6: family = '6'; break;
			default:       family = '?'; break;
		}
		seprintf(buffer, last, " (IPv%c)", family);
	}
}
开发者ID:ShaunOfTheLive,项目名称:OpenCoasterTycoon,代码行数:23,代码来源:address.cpp

示例4: seprintf

	/* virtual */ char *LogOSVersion(char *buffer, const char *last) const
	{
		struct utsname name;
		if (uname(&name) < 0) {
			return buffer + seprintf(buffer, last, "Could not get OS version: %s\n", strerror(errno));
		}

		return buffer + seprintf(buffer, last,
				"Operating system:\n"
				" Name:     %s\n"
				" Release:  %s\n"
				" Version:  %s\n"
				" Machine:  %s\n",
				name.sysname,
				name.release,
				name.version,
				name.machine
		);
	}
开发者ID:andrew889,项目名称:openttd-android,代码行数:19,代码来源:crashlog_unix.cpp

示例5: Utf8Encode

char *ScriptText::_GetEncodedText(char *p, char *lastofp)
{
	p += Utf8Encode(p, SCC_ENCODED);
	p += seprintf(p, lastofp, "%X", this->string);
	for (int i = 0; i < this->paramc; i++) {
		if (this->params[i] != NULL) {
			p += seprintf(p, lastofp, ":\"%s\"", this->params[i]);
			continue;
		}
		if (this->paramt[i] != NULL) {
			p += seprintf(p, lastofp, ":");
			p = this->paramt[i]->_GetEncodedText(p, lastofp);
			continue;
		}
		p += seprintf(p, lastofp,":%X", this->parami[i]);
	}

	return p;
}
开发者ID:benjeffery,项目名称:openttd,代码行数:19,代码来源:script_text.cpp

示例6: cputyperead

static long cputyperead(struct chan *unused, void *a, long n, int64_t off)
{
	char buf[512], *s, *e;
	int i, k;

	error(ENOSYS, NULL);
#if 0
	e = buf + sizeof buf;
	s = seprintf(buf, e, "%s %d\n", "AMD64", 0);
	k = m->ncpuinfoe - m->ncpuinfos;
	if (k > 4)
		k = 4;
	for (i = 0; i < k; i++)
		s = seprintf(s, e, "%#8.8ux %#8.8ux %#8.8ux %#8.8ux\n",
					 m->cpuinfo[i][0], m->cpuinfo[i][1],
					 m->cpuinfo[i][2], m->cpuinfo[i][3]);
	return readstr(off, a, n, buf);
#endif
}
开发者ID:anonymous31173,项目名称:akaros,代码行数:19,代码来源:devarch.c

示例7: seprintf

/**
 * Convert the md5sum to a hexadecimal string representation
 * @param buf buffer to put the md5sum into
 * @param last last character of buffer (usually lastof(buf))
 * @param md5sum the md5sum itself
 * @return a pointer to the next character after the md5sum
 */
char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
{
	char *p = buf;

	for (uint i = 0; i < 16; i++) {
		p += seprintf(p, last, "%02X", md5sum[i]);
	}

	return p;
}
开发者ID:CliffsDover,项目名称:openttd-android,代码行数:17,代码来源:string.cpp

示例8: SetFallbackFont

bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, SetFallbackFontCallback *callback)
{
	if (!FcInit()) return false;

	bool ret = false;

	/* Fontconfig doesn't handle full language isocodes, only the part
	 * before the _ of e.g. en_GB is used, so "remove" everything after
	 * the _. */
	char lang[16];
	seprintf(lang, lastof(lang), ":lang=%s", language_isocode);
	char *split = strchr(lang, '_');
	if (split != NULL) *split = '\0';

	/* First create a pattern to match the wanted language. */
	FcPattern *pat = FcNameParse((FcChar8*)lang);
	/* We only want to know the filename. */
	FcObjectSet *os = FcObjectSetBuild(FC_FILE, NULL);
	/* Get the list of filenames matching the wanted language. */
	FcFontSet *fs = FcFontList(NULL, pat, os);

	/* We don't need these anymore. */
	FcObjectSetDestroy(os);
	FcPatternDestroy(pat);

	if (fs != NULL) {
		for (int i = 0; i < fs->nfont; i++) {
			FcPattern *font = fs->fonts[i];

			FcChar8 *file = NULL;
			FcResult res = FcPatternGetString(font, FC_FILE, 0, &file);
			if (res != FcResultMatch || file == NULL) {
				continue;
			}

			strecpy(settings->small_font,  (const char*)file, lastof(settings->small_font));
			strecpy(settings->medium_font, (const char*)file, lastof(settings->medium_font));
			strecpy(settings->large_font,  (const char*)file, lastof(settings->large_font));

			bool missing = callback(NULL);
			DEBUG(freetype, 1, "Font \"%s\" misses%s glyphs", file, missing ? "" : " no");

			if (!missing) {
				ret = true;
				break;
			}
		}

		/* Clean up the list of filenames. */
		FcFontSetDestroy(fs);
	}

	FcFini();
	return ret;
}
开发者ID:ShaunOfTheLive,项目名称:OpenCoasterTycoon,代码行数:55,代码来源:fontcache.cpp

示例9: seprintf

/**
 * Build a human readable list of available drivers, grouped by type.
 */
char *DriverFactoryBase::GetDriversInfo(char *p, const char *last)
{
	for (Driver::Type type = Driver::DT_BEGIN; type != Driver::DT_END; type++) {
		p += seprintf(p, last, "List of %s drivers:\n", GetDriverTypeName(type));

		for (int priority = 10; priority >= 0; priority--) {
			Drivers::iterator it = GetDrivers().begin();
			for (; it != GetDrivers().end(); it++) {
				DriverFactoryBase *d = (*it).second;
				if (d->type != type) continue;
				if (d->priority != priority) continue;
				p += seprintf(p, last, "%18s: %s\n", d->name, d->GetDescription());
			}
		}

		p += seprintf(p, last, "\n");
	}

	return p;
}
开发者ID:ShaunOfTheLive,项目名称:OpenCoasterTycoon,代码行数:23,代码来源:driver.cpp

示例10: FiosIsValidFile

bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
{
	char filename[MAX_PATH];
	int res;
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
	/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
	if (FiosIsRoot(path)) {
		res = seprintf(filename, lastof(filename), "%s:%s", path, ent->d_name);
	} else // XXX - only next line!
#else
	assert(path[strlen(path) - 1] == PATHSEPCHAR);
	if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
#endif
	res = seprintf(filename, lastof(filename), "%s%s", path, ent->d_name);

	/* Could we fully concatenate the path and filename? */
	if (res >= (int)lengthof(filename) || res < 0) return false;

	return stat(filename, sb) == 0;
}
开发者ID:CliffsDover,项目名称:openttd-android,代码行数:20,代码来源:unix.cpp

示例11: CheckExternalFiles

/**
 * Checks whether the MD5 checksums of the files are correct.
 *
 * @note Also checks sample.cat and other required non-NewGRF GRFs for corruption.
 */
void CheckExternalFiles()
{
	if (BaseGraphics::GetUsedSet() == NULL || BaseSounds::GetUsedSet() == NULL) return;

	const GraphicsSet *used_set = BaseGraphics::GetUsedSet();

	DEBUG(grf, 1, "Using the %s base graphics set", used_set->name);

	static const size_t ERROR_MESSAGE_LENGTH = 256;
	static const size_t MISSING_FILE_MESSAGE_LENGTH = 128;

	/* Allocate for a message for each missing file and for one error
	 * message per set.
	 */
	char error_msg[MISSING_FILE_MESSAGE_LENGTH * (GraphicsSet::NUM_FILES + SoundsSet::NUM_FILES) + 2 * ERROR_MESSAGE_LENGTH];
	error_msg[0] = '\0';
	char *add_pos = error_msg;
	const char *last = lastof(error_msg);

	if (used_set->GetNumInvalid() != 0) {
		/* Not all files were loaded successfully, see which ones */
		add_pos += seprintf(add_pos, last, "Trying to load graphics set '%s', but it is incomplete. The game will probably not run correctly until you properly install this set or select another one. See section 4.1 of readme.txt.\n\nThe following files are corrupted or missing:\n", used_set->name);
		for (uint i = 0; i < GraphicsSet::NUM_FILES; i++) {
			MD5File::ChecksumResult res = used_set->files[i].CheckMD5(BASESET_DIR);
			if (res != MD5File::CR_MATCH) add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", used_set->files[i].filename, res == MD5File::CR_MISMATCH ? "corrupt" : "missing", used_set->files[i].missing_warning);
		}
		add_pos += seprintf(add_pos, last, "\n");
	}

	const SoundsSet *sounds_set = BaseSounds::GetUsedSet();
	if (sounds_set->GetNumInvalid() != 0) {
		add_pos += seprintf(add_pos, last, "Trying to load sound set '%s', but it is incomplete. The game will probably not run correctly until you properly install this set or select another one. See section 4.1 of readme.txt.\n\nThe following files are corrupted or missing:\n", sounds_set->name);

		assert_compile(SoundsSet::NUM_FILES == 1);
		/* No need to loop each file, as long as there is only a single
		 * sound file. */
		add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", sounds_set->files->filename, sounds_set->files->CheckMD5(BASESET_DIR) == MD5File::CR_MISMATCH ? "corrupt" : "missing", sounds_set->files->missing_warning);
	}

	if (add_pos != error_msg) ShowInfoF("%s", error_msg);
}
开发者ID:davidwlewis,项目名称:openttd-cargodist,代码行数:46,代码来源:gfxinit.cpp

示例12: seprintf

AILibrary *AIScannerLibrary::FindLibrary(const char *library, int version)
{
	/* Internally we store libraries as 'library.version' */
	char library_name[1024];
	seprintf(library_name, lastof(library_name), "%s.%d", library, version);
	strtolower(library_name);

	/* Check if the library + version exists */
	ScriptInfoList::iterator iter = this->info_list.find(library_name);
	if (iter == this->info_list.end()) return NULL;

	return static_cast<AILibrary *>((*iter).second);
}
开发者ID:Johnnei,项目名称:OpenTTD,代码行数:13,代码来源:ai_scanner.cpp

示例13: seprintf

/** Build a string containing space separated parameter values, and terminate */
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
{
	uint i;

	/* Return an empty string if there are no parameters */
	if (c->num_params == 0) return strecpy(dst, "", last);

	for (i = 0; i < c->num_params; i++) {
		if (i > 0) dst = strecpy(dst, " ", last);
		dst += seprintf(dst, last, "%d", c->param[i]);
	}
	return dst;
}
开发者ID:tony,项目名称:openttd,代码行数:14,代码来源:newgrf_config.cpp

示例14: sq_gettop

/* static */ bool Squirrel::CreateClassInstanceVM(HSQUIRRELVM vm, const char *class_name, void *real_instance, HSQOBJECT *instance, SQRELEASEHOOK release_hook, bool prepend_API_name)
{
	Squirrel *engine = (Squirrel *)sq_getforeignptr(vm);

	int oldtop = sq_gettop(vm);

	/* First, find the class */
	sq_pushroottable(vm);

	if (prepend_API_name) {
		size_t len = strlen(class_name) + strlen(engine->GetAPIName()) + 1;
		char *class_name2 = (char *)alloca(len);
		seprintf(class_name2, class_name2 + len - 1, "%s%s", engine->GetAPIName(), class_name);

		sq_pushstring(vm, class_name2, -1);
	} else {
		sq_pushstring(vm, class_name, -1);
	}

	if (SQ_FAILED(sq_get(vm, -2))) {
		DEBUG(misc, 0, "[squirrel] Failed to find class by the name '%s%s'", prepend_API_name ? engine->GetAPIName() : "", class_name);
		sq_settop(vm, oldtop);
		return false;
	}

	/* Create the instance */
	if (SQ_FAILED(sq_createinstance(vm, -1))) {
		DEBUG(misc, 0, "[squirrel] Failed to create instance for class '%s%s'", prepend_API_name ? engine->GetAPIName() : "", class_name);
		sq_settop(vm, oldtop);
		return false;
	}

	if (instance != NULL) {
		/* Find our instance */
		sq_getstackobj(vm, -1, instance);
		/* Add a reference to it, so it survives for ever */
		sq_addref(vm, instance);
	}
	sq_remove(vm, -2); // Class-name
	sq_remove(vm, -2); // Root-table

	/* Store it in the class */
	sq_setinstanceup(vm, -1, real_instance);
	if (release_hook != NULL) sq_setreleasehook(vm, -1, release_hook);

	if (instance != NULL) sq_settop(vm, oldtop);

	return true;
}
开发者ID:IchiroWang,项目名称:OpenTTD,代码行数:49,代码来源:squirrel.cpp

示例15: FiosGetDrives

void FiosGetDrives(FileList &file_list)
{
	TCHAR drives[256];
	const TCHAR *s;

	GetLogicalDriveStrings(lengthof(drives), drives);
	for (s = drives; *s != '\0';) {
		FiosItem *fios = file_list.Append();
		fios->type = FIOS_TYPE_DRIVE;
		fios->mtime = 0;
		seprintf(fios->name, lastof(fios->name),  "%c:", s[0] & 0xFF);
		strecpy(fios->title, fios->name, lastof(fios->title));
		while (*s++ != '\0') { /* Nothing */ }
	}
}
开发者ID:J0anJosep,项目名称:OpenTTD,代码行数:15,代码来源:win32.cpp


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