Exemplo n.º 1
0
void StringList_Add (
	StringListPtr self,
	char *str
	)
{
	ESIF_ASSERT(str);
	self->list = (char**)esif_ccb_realloc(self->list, (self->items + 2) * sizeof(self->list[0]));
	if (self->list) {
		self->list[self->items++] = String_Clone(str);
		self->list[self->items]   = 0;
	}
}
Exemplo n.º 2
0
/* Adds all locales from the program's external libraries. */
static sdef(int, onLibrary, struct dl_phdr_info *info, __unused size_t size, void *data) {
	DynInstName(self) $this = (DynInstName(self)) (self *) data;

	RdString path = String_FromNul((char *) info->dlpi_name);
	path.len != 0 || ret(0);

	RdString ext      = Path_getFileExtension(path);
	RdString fileName = Path_getFileName(path);

	Logger_Debug(&this->logger, $("Found external library %."), fileName);

	if (!String_Equals(ext, $("dll"))) {
		Logger_Debug(&this->logger, $("Incompatible library extension."));
		return 0;
	}

	String realPath;
	if (Path_isLink(path)) {
		realPath = Path_followLink(path);
	} else {
		realPath = String_Clone(path);
	}

	RdString folderPath = Path_getFolderPath(realPath.rd);
	RdString context    = String_Slice(fileName, 0, -4);

	String lngpath = String_Format($("%Locale/"), folderPath);

	if (!Path_exists(lngpath.rd)) {
		Logger_Debug(&this->logger, $("External library % has no locales."),
			context);
		String_Destroy(&lngpath);
	} else {
		if (Locale_hasContext(Locale_GetInstance(), context)) {
			Logger_Error(&this->logger, $(
				"The locale context % was already registered. Possibly "
				"the program maintains a local copy of its external locales."),
				context);
		} else {
			Logger_Debug(&this->logger,
				$("Adding locale directory % (for external library %)."),
				lngpath.rd, context);

			Locale_addContext(Locale_GetInstance(), context, lngpath);
		}
	}

	String_Destroy(&realPath);

	return 0;
}
Exemplo n.º 3
0
static sdef(String, Sanitize, String name) {
	String out = String_Clone(name);

	String_ReplaceAll(&out, $("?"),  $(" "));
	String_ReplaceAll(&out, $(":"),  $(" "));
	String_ReplaceAll(&out, $("/"),  $("-"));
	String_ReplaceAll(&out, $("  "), $(" "));

	String_Copy(&out, String_Trim(out));

	if (String_EndsWith(out, $("."))) {
		out.len--;
	}

	return out;
}
Exemplo n.º 4
0
#import "Builder.h"

#define self Builder

rsdef(self, new, Terminal *term, Logger *logger, Deps *deps) {
	return (self) {
		.term      = term,
		.deps      = deps,
		.logger    = logger,
		.output    = String_New(0),
		.cc        = String_Clone($("/usr/bin/clang")),
		.inclhdr   = String_New(0),
		.runtime   = String_New(0),
		.manifest  = false,
		.library   = false,
		.dbgsym    = false,
		.std       = String_Clone($("gnu99")),
		.blocks    = true,
		.optmlevel = 0,
		.verbose   = false,
		.link      = StringArray_New(0),
		.mappings  = MappingArray_New(0),
		.linkpaths = StringArray_New(0),
		.workers   = CPU_getCores()
	};
}

def(void, destroy) {
	String_Destroy(&this->output);
	String_Destroy(&this->cc);
	String_Destroy(&this->inclhdr);
Exemplo n.º 5
0
def(void, Init, StorageInstance storage, String providerId) {
	this->logger     = Debugger_GetLogger(Debugger_GetInstance());
	this->storage    = storage;
	this->providerId = String_Clone(providerId);
	this->location   = $("");
}
Exemplo n.º 6
0
def(void, Init, String base) {
	this->base = String_Clone(base);
}