2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
gbc_archive.c
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-08-03 17:38:01 +02:00
|
|
|
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __GBC_ARCHIVE_C
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gb_error.h"
|
|
|
|
#include "gb_str.h"
|
|
|
|
#include "gb_file.h"
|
|
|
|
#include "gb_magic.h"
|
|
|
|
#include "gb_common_swap.h"
|
2008-05-11 20:07:16 +02:00
|
|
|
#include "gbc_chown.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbc_archive.h"
|
|
|
|
|
|
|
|
/*#define DEBUG*/
|
|
|
|
|
2010-10-31 23:05:29 +01:00
|
|
|
#define TEMP_EXEC ".temp.gambas"
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
char *ARCH_project;
|
|
|
|
char *ARCH_project_name;
|
|
|
|
char *ARCH_output = NULL;
|
|
|
|
bool ARCH_verbose = FALSE;
|
|
|
|
bool ARCH_swap = FALSE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
static int arch_dir_pos;
|
|
|
|
static TABLE *arch_table;
|
|
|
|
static FILE *arch_file = NULL;
|
2013-01-06 17:13:31 +01:00
|
|
|
|
|
|
|
#define ARCH_BUFFER_SIZE 4096
|
2007-12-30 17:41:49 +01:00
|
|
|
static char *arch_buffer;
|
|
|
|
|
|
|
|
static int pos_start;
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static void write_int(uint val)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
if (ARCH_swap)
|
|
|
|
SWAP_int((int *)&val);
|
|
|
|
if (fwrite(&val, sizeof(uint), 1, arch_file) < 1)
|
|
|
|
THROW("Write error");
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_short(ushort val)
|
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
if (ARCH_swap)
|
|
|
|
SWAP_short((short *)&val);
|
|
|
|
if (fwrite(&val, sizeof(ushort), 1, arch_file) < 1)
|
|
|
|
THROW("Write error");
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-06 17:13:31 +01:00
|
|
|
static long get_pos(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2013-01-06 17:13:31 +01:00
|
|
|
long pos = ftell(arch_file);
|
|
|
|
if (pos < 0)
|
|
|
|
THROW("Unable to get file position");
|
|
|
|
return (int)pos; // No archive file greater then 2 Go!
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static void write_int_at(int pos, uint val)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
int old_pos = get_pos();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
fseek(arch_file, pos, SEEK_SET);
|
|
|
|
write_int(val);
|
|
|
|
fseek(arch_file, old_pos, SEEK_SET);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_string(const char *str, int len)
|
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
if (fwrite(str, sizeof(char), len, arch_file) < len)
|
|
|
|
THROW("Write error");
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void make_executable(void)
|
|
|
|
{
|
2010-10-31 23:05:29 +01:00
|
|
|
const char *err;
|
2012-10-10 16:58:14 +02:00
|
|
|
struct stat info;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-03-31 08:24:30 +02:00
|
|
|
FILE_chdir(FILE_get_dir(ARCH_output));
|
2010-10-31 23:05:29 +01:00
|
|
|
|
2013-03-31 08:24:30 +02:00
|
|
|
// If we cannot make the archive executable, just print a warning. gbs creates an executable cache
|
2011-06-11 03:53:30 +02:00
|
|
|
// inside /tmp, and /tmp may be mounted with the "noexec" flag.
|
|
|
|
|
2010-10-31 23:05:29 +01:00
|
|
|
if (stat(TEMP_EXEC, &info) || chmod(TEMP_EXEC, info.st_mode | S_IXUSR | S_IXGRP | S_IXOTH))
|
2011-06-11 03:53:30 +02:00
|
|
|
fprintf(stderr, "gba: warning: cannot change executable permissions\n");
|
2010-10-31 23:05:29 +01:00
|
|
|
|
|
|
|
FILE_set_owner(TEMP_EXEC, FILE_cat(FILE_get_dir(ARCH_project), ".project", NULL));
|
|
|
|
|
|
|
|
if (FILE_exist(ARCH_output) && unlink(ARCH_output))
|
|
|
|
{
|
|
|
|
err = "Cannot remove previous executable";
|
|
|
|
goto __ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rename(TEMP_EXEC, ARCH_output))
|
|
|
|
{
|
2013-03-31 08:24:30 +02:00
|
|
|
err = "Cannot create executable";
|
|
|
|
goto __ERROR;
|
2010-10-31 23:05:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
__ERROR:
|
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
THROW("Cannot make executable: &1: &2", err, strerror(errno));
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void ARCH_define_output(const char *path)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
|
|
|
STR_free(ARCH_output);
|
2010-10-31 23:05:29 +01:00
|
|
|
|
|
|
|
if (path && *path != '/')
|
|
|
|
path = FILE_cat(FILE_get_current_dir(), path, NULL);
|
2013-01-06 17:13:31 +01:00
|
|
|
else if (!path)
|
|
|
|
path = "";
|
2010-10-31 23:05:29 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
ARCH_output = STR_copy(path);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void ARCH_define_project(const char *project)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
char *name;
|
|
|
|
char *dir;
|
|
|
|
const char *path;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
if (project == NULL)
|
|
|
|
project = FILE_get_current_dir();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
FILE_chdir(project);
|
|
|
|
dir = STR_copy(FILE_get_current_dir());
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
arch_dir_pos = strlen(dir) + 1;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-04-17 12:18:25 +02:00
|
|
|
path = FILE_cat(dir, ".startup", NULL);
|
|
|
|
if (FILE_exist(path))
|
2012-10-10 16:58:14 +02:00
|
|
|
ARCH_project = STR_copy(path);
|
|
|
|
else
|
|
|
|
ARCH_project = STR_copy(FILE_cat(dir, ".project", NULL));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
name = STR_copy(FILE_get_name(dir));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
/*ARCH_project_name = STR_copy(FILE_set_ext(name, NULL));*/
|
|
|
|
ARCH_project_name = STR_copy(name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
if (!ARCH_output)
|
2012-10-10 16:58:14 +02:00
|
|
|
ARCH_define_output(strcat((char *)FILE_cat(dir, ARCH_project_name, NULL), ".gambas"));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
STR_free(name);
|
|
|
|
STR_free(dir);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void ARCH_init(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
TABLE_create(&arch_table, sizeof(ARCH_SYMBOL), TF_NORMAL);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-03-30 00:33:01 +01:00
|
|
|
ALLOC(&arch_buffer, ARCH_BUFFER_SIZE);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-03-31 08:24:30 +02:00
|
|
|
arch_file = fopen(FILE_cat(FILE_get_dir(ARCH_output), TEMP_EXEC, NULL), "w");
|
2012-10-10 16:58:14 +02:00
|
|
|
if (arch_file == NULL)
|
|
|
|
THROW("Cannot create temporary archive file: &1", ARCH_output);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
fputs("#! /usr/bin/env gbr" GAMBAS_VERSION_STRING "\n", arch_file);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
while (get_pos() < 31)
|
|
|
|
fprintf(arch_file, " ");
|
|
|
|
fprintf(arch_file, "\n");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
write_int(ARCH_MAGIC);
|
|
|
|
write_int(ARCH_VERSION);
|
|
|
|
|
|
|
|
if (ARCH_verbose)
|
|
|
|
printf("Format version: %d\n", ARCH_VERSION);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
pos_start = get_pos();
|
|
|
|
write_int(0);
|
|
|
|
write_int(0);
|
|
|
|
write_int(0);
|
|
|
|
write_int(0);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
write_int_at(pos_start, get_pos());
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if ARCH_VERSION == 2
|
|
|
|
static void compress_file_name(const char *src, int lsrc, char **dst, int *ldst)
|
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
char *p;
|
|
|
|
static char tpath[PATH_MAX];
|
|
|
|
char tpath2[PATH_MAX];
|
|
|
|
int len;
|
|
|
|
int ind;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
strncpy(tpath, src, lsrc);
|
|
|
|
tpath[lsrc] = 0;
|
|
|
|
len = lsrc;
|
|
|
|
|
|
|
|
if (ARCH_verbose)
|
|
|
|
printf("%s", tpath);
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
p = index(tpath + 1, '/');
|
|
|
|
if (!p)
|
|
|
|
break;
|
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
if (!TABLE_find_symbol(arch_table, tpath, p - tpath, &ind))
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
THROW("&1: not in archive", tpath);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-01-06 21:06:44 +01:00
|
|
|
len = snprintf(tpath2, sizeof(tpath2), "/%d:%s", ind, p + 1);
|
2008-02-19 00:07:24 +01:00
|
|
|
strcpy(tpath, tpath2);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ARCH_verbose)
|
|
|
|
printf(" -> %s\n", tpath);
|
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
*dst = tpath;
|
|
|
|
*ldst = len;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void ARCH_exit(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
int i;
|
|
|
|
ARCH_SYMBOL *sym;
|
|
|
|
int pos_str;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
/* Write strings */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
write_int_at(pos_start + sizeof(int), get_pos());
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
pos_str = 0;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
for (i = 0; i < TABLE_count(arch_table); i++)
|
|
|
|
{
|
|
|
|
sym = (ARCH_SYMBOL *)TABLE_get_symbol(arch_table, i);
|
|
|
|
write_string(sym->sym.name, sym->sym.len);
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
/* Write file names */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
write_int_at(pos_start + sizeof(int) * 2, get_pos());
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
write_int_at(pos_start + sizeof(int) * 3, TABLE_count(arch_table));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
for (i = 0; i < TABLE_count(arch_table); i++)
|
|
|
|
{
|
|
|
|
sym = (ARCH_SYMBOL *)TABLE_get_symbol(arch_table, i);
|
|
|
|
//write_short((ushort)i);
|
|
|
|
write_int(pos_str);
|
|
|
|
write_int(sym->sym.len);
|
|
|
|
write_int(sym->pos);
|
|
|
|
write_int(sym->len);
|
|
|
|
|
|
|
|
pos_str += sym->sym.len;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-27 15:51:09 +02:00
|
|
|
for (i = 0; i < TABLE_count(arch_table); i++)
|
2012-10-10 16:58:14 +02:00
|
|
|
write_short(arch_table->sort[i]);
|
|
|
|
|
|
|
|
/* Close file */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
fclose(arch_file);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
make_executable();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
/* Free everything */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
for (i = 0; i < TABLE_count(arch_table); i++)
|
|
|
|
STR_free(TABLE_get_symbol(arch_table, i)->name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
TABLE_delete(&arch_table);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
STR_free(ARCH_output);
|
|
|
|
STR_free(ARCH_project);
|
|
|
|
STR_free(ARCH_project_name);
|
|
|
|
|
2013-03-30 00:33:01 +01:00
|
|
|
FREE(&arch_buffer);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
int ARCH_add_file(const char *path)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2012-10-10 16:58:14 +02:00
|
|
|
char *rel_path;
|
|
|
|
ARCH_SYMBOL *sym;
|
|
|
|
FILE *file;
|
|
|
|
struct stat info;
|
|
|
|
int len, len_read;
|
|
|
|
|
|
|
|
int ind;
|
|
|
|
|
|
|
|
#if ARCH_VERSION == 2
|
|
|
|
compress_file_name(&path[arch_dir_pos], strlen(&path[arch_dir_pos]), &rel_path, &len);
|
|
|
|
rel_path = STR_copy(rel_path);
|
|
|
|
#else
|
|
|
|
rel_path = STR_copy(&path[arch_dir_pos]);
|
|
|
|
len = strlen(rel_path);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TABLE_add_symbol(arch_table, rel_path, len, &ind);
|
2010-05-25 13:19:00 +02:00
|
|
|
sym = (ARCH_SYMBOL *)TABLE_get_symbol(arch_table, ind);
|
2012-10-10 16:58:14 +02:00
|
|
|
sym->pos = get_pos();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
file = fopen(path, "r");
|
|
|
|
if (file == NULL)
|
|
|
|
THROW("Cannot open file: &1", path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
fstat(fileno(file), &info);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-10 16:58:14 +02:00
|
|
|
if (S_ISDIR(info.st_mode))
|
|
|
|
{
|
|
|
|
sym->pos = -1;
|
|
|
|
sym->len = 0;
|
2007-12-30 17:41:49 +01:00
|
|
|
fclose(file);
|
|
|
|
if (ARCH_verbose)
|
|
|
|
printf("Adding directory %s", rel_path);
|
2012-10-10 16:58:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-30 17:41:49 +01:00
|
|
|
sym->len = info.st_size;
|
|
|
|
|
|
|
|
len = sym->len;
|
|
|
|
while (len > 0)
|
|
|
|
{
|
2013-01-06 17:13:31 +01:00
|
|
|
len_read = fread(arch_buffer, 1, ARCH_BUFFER_SIZE, file);
|
2007-12-30 17:41:49 +01:00
|
|
|
if (len_read > 0)
|
|
|
|
fwrite(arch_buffer, 1, len_read, arch_file);
|
|
|
|
|
2013-01-06 17:13:31 +01:00
|
|
|
if (len_read < ARCH_BUFFER_SIZE)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
|
|
|
if (ferror(file))
|
2009-09-21 18:57:21 +02:00
|
|
|
THROW("Cannot read file: &1: &2", path, strerror(errno));
|
2007-12-30 17:41:49 +01:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
if (ARCH_verbose)
|
|
|
|
printf("Adding file %s (%d bytes)", rel_path, sym->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ARCH_verbose)
|
|
|
|
printf(" -> %d\n", ind);
|
|
|
|
|
|
|
|
return ind;
|
|
|
|
}
|
2010-04-25 12:46:57 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
void ARCH_browse(ARCH *a, void (*found)(const char *path, int64_t size))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ARCH_SYMBOL *asym;
|
2012-10-10 16:58:14 +02:00
|
|
|
SYMBOL *sym;
|
2010-04-25 12:46:57 +02:00
|
|
|
char *path;
|
|
|
|
char *temp;
|
|
|
|
int size;
|
|
|
|
int ip;
|
|
|
|
|
|
|
|
for (i = 0; i < a->header.n_symbol; i++)
|
|
|
|
{
|
|
|
|
asym = &a->symbol[i];
|
|
|
|
sym = &asym->sym;
|
|
|
|
|
|
|
|
size = asym->len;
|
|
|
|
|
|
|
|
path = STR_copy_len(sym->name, sym->len);
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (*path != '/')
|
|
|
|
break;
|
|
|
|
|
|
|
|
ip = atoi(&path[1]);
|
|
|
|
sym = &a->symbol[ip].sym;
|
|
|
|
|
|
|
|
temp = path;
|
|
|
|
path = STR_copy_len(sym->name, sym->len);
|
|
|
|
if (path[sym->len - 1] != '/')
|
|
|
|
STRING_add(&path, "/", 1);
|
|
|
|
STRING_add(&path, strchr(temp, ':') + 1, 0);
|
|
|
|
STRING_free(&temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
(*found)(path, size);
|
|
|
|
STR_free(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|