Пример #1
0
void quote_add_files_to_db(void)
{
	xdb_pair_t *pair;
	dlist_t *dl, *dptr, *dptr_tmp;
	char *dir;
	char *suffix, *str, *str_tmp;

	debug(NULL, "quote_add_files_to_db: Entered\n");

	dir = str_unite_static("%s/mods/mod_quote_files/", gi->confdir);

	dl = files_get_listing(NULL, dir,
			       FILES_NORMAL | FILES_RECURSE | FILES_NODOT);
	if (!dl)
		goto cleanup;

	dlist_fornext_retarded(dl, dptr, dptr_tmp) {
		if (!dptr)
			break;

		str = (char *)dlist_data(dptr);
		if (!str)
			continue;

		suffix = _strrchr(str, '.');

		if (suffix) {
			if (!strcasecmp(suffix, ".quot")) {
				dlist_remove_and_free(&dl, &dptr, free);
				continue;
			}
		}

		suffix = _strrchr(str, '/');
		if (!suffix)
			continue;
		suffix++;

		pair =
		    xdb_pair_create(suffix, strlen(suffix), str, strlen(str));

		if (!pair)
			continue;

		capsup(pair->key);
		str_tmp = pair->value;
		pair->value = str_unite("%s.quot", pair->value);
		free(str_tmp);
		dlist_Dinsert_after(&dl_quote_pairs, pair);
	}

	dlist_fornext(dl, dptr) {
		debug(NULL, "quote_add_files_to_db: file=%s\n",
		      (char *)dlist_data(dptr));
		quote_add_files_to_db_file((char *)dlist_data(dptr));
	}
Пример #2
0
void
___start(int argc, char **argv, char **envp, void *ps_strings,
	const void *obj, void (*cleanup)(void))
{
	char *s;

 	environ = envp;

	if ((__progname = argv[0]) != NULL) {   /* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
		for (s = __progname_storage; *__progname &&
		    s < &__progname_storage[sizeof __progname_storage - 1]; )
			*s++ = *__progname++;
		*s = '\0';
		__progname = __progname_storage;
	}

#if 0
	atexit(cleanup);
#endif
#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif	/* MCRT0 */

#ifndef SCRT0
        __init();
#endif

__asm("__callmain:");		/* Defined for the benefit of debuggers */
	exit(main(argc, argv, envp));
}
Пример #3
0
void
___start(int argc, char **argv, char **envp, void *aux, void (*cleanup)(void))
{
	char *s;

	environ = envp;

	if ((__progname = argv[0]) != NULL) {   /* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
		for (s = __progname_storage; *__progname &&
		   s < &__progname_storage[sizeof __progname_storage - 1]; )
			*s++ = *__progname++;
		*s = '\0';
		__progname = __progname_storage;
	}

	if (cleanup)
		atexit(cleanup);

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

#ifndef SCRT0
	__init();
#endif

	exit(main(argc, argv, environ));
}
Пример #4
0
void
__start(int argc, char **argv, char **envp,
    void (*cleanup)(void),			/* from shared loader */
    const Obj_Entry *obj,			/* from shared loader */
    struct ps_strings *ps_strings)
{
	environ = envp;

	if ((__progname = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
	}

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	if (&_DYNAMIC != NULL)
		_rtld_setup(cleanup, obj);
#endif

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Пример #5
0
void
_start(int argc, char *argv[], char *envp[])
{
	char *namep;

	environ = envp;
	NXArgc = argc;
	NXArgv = argv;

	if ((namep = argv[0]) != NULL) {
		if ((__progname = _strrchr(namep, '/')) == NULL)
			__progname = namep;
		else
			__progname++;
	}

	/*
	 * Initialise hooks inside libc
	 */
	if (mach_init_routine)
		(*mach_init_routine)();
	if (_cthread_init_routine)
		(*_cthread_init_routine)();

#ifdef PROFILE
	atexit(_mcleanup);
	moninit();
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Пример #6
0
// 指定した番号にステート削除
boolean PSPEMU_DeleteState(uint32 ulNum)
{
	char szFilePath[MAX_PATH], szThumbnailPath[MAX_PATH], szTemp[32], *pszExt;

	if (ulNum >= STATE_SLOT_MAX) return FALSE;
	GetStatePath(szFilePath, sizeof(szFilePath));
	_strcat(szFilePath, NES_ROM_GetRomName());
	_strcpy(szThumbnailPath, szFilePath);
	_strcat(szFilePath, ".ss");
	_itoa(ulNum, szTemp);
	_strcat(szFilePath, szTemp);
	// delete ss? file
	sceIoRemove(szFilePath);
	pszExt = _strrchr(szFilePath, '.');
	if (pszExt) {
		pszExt[1] = 'z';
		// delete zs? file
		sceIoRemove(szFilePath);
	}
	_strcat(szThumbnailPath, ".tn");
	_strcat(szThumbnailPath, szTemp);
	// delete thumbnail file
	sceIoRemove(szThumbnailPath);
	_strcat(szThumbnailPath, ".png");
	// delete thumbnail file(png)
	sceIoRemove(szThumbnailPath);
	return TRUE;
}
Пример #7
0
void
_start(int argc, char **argv, char **envp,
    const Obj_Entry *obj,			/* from shared loader */
    void (*cleanup)(void),			/* from shared loader */
    struct ps_strings *ps_strings)		/* NetBSD extension */
{
	char *namep;

	/*
	 * Initialize the Small Data Area registers.
	 * _SDA_BASE is defined in the SVR4 ABI for PPC.
	 *
	 * Do the initialization in a PIC manner.
	 */
	__asm(
		"bcl 20,31,1f;"
		"1: mflr 11;"
		"addis 13,11,rtld_SDA_BASE_-1b@ha;"
		"addi 13,13,rtld_SDA_BASE_-1b@l;"
	    ::: "lr" );

	if ((namep = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(namep, '/')) == NULL)
			__progname = namep;
		else
			__progname++;
	}

	environ = envp;

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	if (&rtld_DYNAMIC != NULL)
		_rtld_setup(cleanup, obj);
#endif

	_libc_init();

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Пример #8
0
char *strrchr(const char *s, int c) {
#if defined (CAMERA_s95)
	// unable to find strrchr in s95 - we use our own fn
	char *result = 0;

	c = (char) c;

	do {
		if (c == *s)
			result = (char*) s;
	} while (*s++ != '\0');

	return result;
#else
    return _strrchr(s, c);
#endif
}
Пример #9
0
void
_start(int argc, char **argv, char **envp,
    const Obj_Entry *obj,			/* from shared loader */
    void (*cleanup)(void),			/* from shared loader */
    struct ps_strings *ps_strings)		/* NetBSD extension */
{
	char *namep;

	/*
	 * Initialize the Small Data Area registers.
	 * _SDA_BASE is defined in the SVR4 ABI for PPC.
	 * _SDA2_BASE is defined in the E[mbedded] ABI for PPC.
	 */
	__asm(  "lis %r13,_SDA_BASE_@ha;"
		"addi %r13,%r13,_SDA_BASE_@l;"
		"lis %r2,_SDA2_BASE_@ha;"
		"addi %r2,%r2,_SDA2_BASE_@l" );

	if ((namep = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(namep, '/')) == NULL)
			__progname = namep;
		else
			__progname++;
	}

	environ = envp;

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	if (&_DYNAMIC != NULL)
		_rtld_setup(cleanup, obj);
#endif

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Пример #10
0
void
__prex_main(int argc, char *argv[], char *envp[])
{
	char *ap;

	environ = envp;

	if ((ap = argv[0])) {
		if ((__progname = _strrchr(ap, '/')) == NULL)
			__progname = ap;
		else
			++__progname;
	}

	__libc_init();

	exit(main(argc, argv, envp));
	/* NOTREACHED */
}
Пример #11
0
void
___start(char **sp,
         void (*cleanup)(void),			/* from shared loader */
         const Obj_Entry *obj,			/* from shared loader */
         struct ps_strings *ps_strings)
{
    long argc;
    char **argv, *namep;

    argc = *(long *)sp;
    argv = sp + 1;
    environ = sp + 2 + argc;		/* 2: argc + NULL ending argv */

    if ((namep = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
        if ((__progname = _strrchr(namep, '/')) == NULL)
            __progname = namep;
        else
            __progname++;
    }

    if (ps_strings != (struct ps_strings *)0 &&
            ps_strings != (struct ps_strings *)0xbabefacedeadbeef)
        __ps_strings = ps_strings;

#ifdef DYNAMIC
    if (&rtld_DYNAMIC != NULL)
        _rtld_setup(cleanup, obj);
#endif

    _libc_init();

#ifdef MCRT0
    atexit(_mcleanup);
    monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

    atexit(_fini);
    _init();

    exit(main(argc, argv, environ));
}
Пример #12
0
static void
___start(struct ps_strings *ps_strings,
    void (*cleanup)(void),			/* from shared loader */
    const Obj_Entry *obj,			/* from shared loader */
    int dp)
{
	int argc;
	char **argv;
	int fini_plabel[2];

	argc = ps_strings->ps_nargvstr;
	argv = ps_strings->ps_argvstr;
	environ = ps_strings->ps_envstr;

	if ((__progname = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
	}

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	/*
	 * XXX fredette - when not compiling PIC, you currently 
	 * can't detect an undefined weak symbol by seeing if 
	 * its address is NULL.  The compiler emits code to find 
	 * _DYNAMIC relative to %dp, the assembler notes the 
	 * needed relocations, but when the linker sees that the 
	 * (weak) symbol isn't defined it drops the ball - the 
	 * relocations are never filled, and the binary ends up 
	 * with code that sees an address of %dp plus zero, 
	 * which != NULL.
	 *
	 * Arguably the linker could/should distinguish between
	 * code that is after a weak undefined symbol's contents 
	 * from code that is after its address.  In the first case, 
	 * it would warn and/or bail.  In the second case, it 
	 * would fix up instructions to give a symbol address
	 * of NULL.
	 *
	 * For now, we take the easy way out and compare &_DYNAMIC 
	 * to %dp, as well as to NULL.
	 */
	if (&_DYNAMIC != NULL && (int)&_DYNAMIC != dp)
		_rtld_setup(cleanup, obj);
#endif

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	/*
	 * Since crt0.o, crtbegin.o, and crtend.o are always
	 * compiled PIC, they must have %r19 set correctly on
	 * entry to any function they contain.  However, when
	 * a program is linked statically, the linker does
	 * not fill a PLABEL relocation with a pointer to a 
	 * true PLABEL, it just fills it with the offset of the
	 * function.  This shows the linker's assumption that 
	 * when linking statically, *all* of the code has *not* 
	 * been compiled PIC.  I guess to assume otherwise
	 * would be a performance hit, as you would end up
	 * with unnecessary PLABELs for function pointers.
	 *
	 * But here, passing the address of the PIC _fini to
	 * atexit, we must make sure that we pass a PLABEL.
	 */
	fini_plabel[0] = (int)_fini;
	if (fini_plabel[0] & 2)
		/* _fini is already a PLABEL. */
		atexit(_fini);
	else {
		fini_plabel[1] = dp;
		atexit((void (*)(void))(((int)fini_plabel) | 2));
	}
	_init();

	exit(main(argc, argv, environ));
}
Пример #13
0
void quote_add_files_to_db_file(char *name)
{
	DB *db = NULL;
	FILE *fp;
	char *name_db;
	char buf[1024];

	char *tok_1 = NULL, *tok_2 = NULL;
	int count = 0;

	if (!name)
		return;

	name_db = _strrchr(name, '/');
	if (!name_db)
		return;

	fp = fopen(name, "r");
	if (!fp)
		return;

	name_db = str_unite_static("%s.quot", name);
	unlink(name_db);
	db = xdb_open(name_db);

	if (!db)
		goto cleanup;

	while (1) {
		_memset(buf, 0, sizeof(buf));

		if (fgets(buf, sizeof(buf) - 1, fp) == NULL)
			break;

		_strstrip_nl(buf);

		tok_2 = _eat_whitespace(buf);
		if (!_sNULL(tok_2))
			continue;

		str_shrink_quotes(tok_2);
		if (!_sNULL(tok_2))
			continue;

		if (buf[0] == '#')
			continue;

		if (!_sNULL(buf))
			continue;

		tok_1 = itocstr(count);

		if (!_sNULL(tok_1))
			continue;

		xdb_write(db, tok_1, tok_2);

		count++;
	}

 cleanup:
	if (fp)
		fclose(fp);

	if (db)
		xdb_fini(db);

	return;
}