コード例 #1
0
static int dash_server_onvod(void* /*dash*/, http_session_t* session, const char* /*method*/, const char* path)
{
    char fullpath[PATH_MAX];
    int r = path_concat(path + 5 /* /vod/ */, LOCALPATH, fullpath);
	printf("vod: %s\n", fullpath);

	if (0 == r && path_testfile(fullpath))
	{
		// MIME
		if (strendswith(fullpath, ".mpd"))
			http_server_set_content_type(session, "application/xml+dash");
		else if (strendswith(fullpath, ".mp4") || strendswith(fullpath, ".m4v"))
            http_server_set_header(session, "content-type", "video/mp4");
        else if (strendswith(fullpath, ".m4a"))
            http_server_set_header(session, "content-type", "audio/mp4");

		//http_server_set_header(session, "Transfer-Encoding", "chunked");

		// cross domain
		http_server_set_header(session, "Access-Control-Allow-Origin", "*");
		http_server_set_header(session, "Access-Control-Allow-Methods", "GET, POST, PUT");

		return http_server_sendfile(session, fullpath, NULL, NULL);
	}

	return http_server_send(session, 404, "", 0, NULL, NULL);
}
コード例 #2
0
/**
 * Produce an IN_CREATE notification for a new file and start wathing on it.
 *
 * This function is used as a callback and is invoked from the dep-list
 * routines.
 *
 * @param[in] udata  A pointer to user data (#handle_context).
 * @param[in] path   File name of a new file.
 * @param[in] inode  Inode number of a new file.
 **/
static void
handle_added (void *udata, const char *path, ino_t inode)
{
    assert (udata != NULL);

    handle_context *ctx = (handle_context *) udata;
    assert (ctx->wrk != NULL);
    assert (ctx->w != NULL);
    assert (ctx->be != NULL);

    struct inotify_event *ie = NULL;
    int ie_len = 0;

    ie = create_inotify_event (ctx->w->fd, IN_CREATE, 0, path, &ie_len);
    if (ie != NULL) {
        bulk_write (ctx->be, ie, ie_len);
        free (ie);
    } else {
        perror_msg ("Failed to create an IN_CREATE event for %s", path);
    }

    char *npath = path_concat (ctx->w->filename, path);
    if (npath != NULL) {
        watch *neww = worker_start_watching (ctx->wrk, npath, path, ctx->w->flags, WATCH_DEPENDENCY);
        if (neww == NULL) {
            perror_msg ("Failed to start watching on a new dependency %s", npath);
        } else {
            neww->parent = ctx->w;
        }
        free (npath);
    } else {
        perror_msg ("Failed to allocate a path to start watching a dependency");
    }
}
コード例 #3
0
ファイル: restore.c プロジェクト: GiorgioRegni/Droplet-backup
static void unhash_tree(storage_t storage, const char *path, const struct element *elem)
{
    char *download_path;
    FILE *descr;
    char buf[4096];

    if (options['v'])
        printf("%s\n", path);

    if (mkdir(path, 0700) == -1 && errno != EEXIST)
        err(EXIT_FAILURE, "unable to restore: %s", path);

    download_path = path_concat("objects", elem->hash);
    if ((descr = storage_retrieve_file(storage, download_path)) == NULL)
        errx(EXIT_FAILURE, "unable to retrieve: %s", path);
    free(download_path);

    while (fgets(buf, 4096, descr) != NULL)
        unhash_dispatch(storage, path, buf);

    if (ferror(descr))
        errx(EXIT_FAILURE, "unable to restore: %s", path);

    fclose(descr);

    if (chmod(path, elem->perm) == -1)
        warn("unable to set mode for %s", path);
    if (lchown(path, elem->uid, elem->gid) == -1)
        warn("unable to set uid/gid for %s", path);
}
コード例 #4
0
ファイル: purge.c プロジェクト: sas/Droplet-backup
static void purge_file(storage_t storage, strset_t objects, char *hash)
{
  char *download_path;
  FILE *descr;
  char buf[4096];
  char *blob_hash;

  download_path = path_concat("objects", hash);
  if ((descr = storage_retrieve_file(storage, download_path)) == NULL)
    logger(LOG_ERROR, "unable to retrieve: %s", hash);
  free(download_path);

  while ((blob_hash = fgets(buf, 4096, descr)) != NULL)
  {
    size_t size;

    size = strlen(blob_hash);
    if (blob_hash[size - 1] != '\n')
      logger(LOG_ERROR, "invalid object: %s", hash);
    blob_hash[size - 1] = '\0';

    strset_del(objects, blob_hash);
  }

  if (ferror(descr))
    logger(LOG_ERROR, "unable to purge: %s", hash);

  fclose(descr);
}
コード例 #5
0
ファイル: copy.c プロジェクト: brokendragon/PERDICE
static int
copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
	  const struct stat *src_sb, struct dir_list *ancestors,
	  const struct cp_options *x, int *copy_into_self)
{
  char *name_space;
  char *namep;
  struct cp_options non_command_line_options = *x;
  int ret = 0;

  name_space = savedir (src_path_in);
  if (name_space == NULL)
    {
      /* This diagnostic is a bit vague because savedir can fail in
         several different ways.  */
      error (0, errno, _("cannot access %s"), quote (src_path_in));
      return -1;
    }

  /* For cp's -H option, dereference command line arguments, but do not
     dereference symlinks that are found via recursive traversal.  */
  if (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
    non_command_line_options.xstat = lstat;

  namep = name_space;
  while (*namep != '\0')
    {
      int local_copy_into_self;
      char *src_path = path_concat (src_path_in, namep, NULL);
      char *dst_path = path_concat (dst_path_in, namep, NULL);

      if (dst_path == NULL || src_path == NULL)
	xalloc_die ();

      ret |= copy_internal (src_path, dst_path, new_dst, src_sb->st_dev,
			    ancestors, &non_command_line_options, 0,
			    &local_copy_into_self, NULL);
      *copy_into_self |= local_copy_into_self;

      free (dst_path);
      free (src_path);

      namep += strlen (namep) + 1;
    }
  free (name_space);
  return -ret;
}
コード例 #6
0
char *
xpath_concat (const char *dir, const char *base, char **base_in_result)
{
  char *res = path_concat (dir, base, base_in_result);
  if (! res)
    xalloc_die ();
  return res;
}
コード例 #7
0
ファイル: path.c プロジェクト: danilaslau/frotznet
char *path_combine (const char *s, const char *t, char *d)
{
	const char *c;
	char *node;

	*d = 0;
	node = d;
	if (*t == '/')
		return path_concat (node, t);

	c = s;
	while (*c)
		*d++ = *c++;
	if (*d != '/')
		*d++ = '/';

	return path_concat (node, t);
}
コード例 #8
0
ファイル: path_utils.c プロジェクト: SSSD/ding-libs
int directory_list(const char *path, bool recursive,
                   directory_list_callback_t callback, void *user_data)
{
    DIR *dir;
    struct dirent *entry;
    struct stat info;
    int error = 0;
    char entry_path[PATH_MAX];
    bool prune = false;

    if (!(dir = opendir(path))) {
        error = errno;
        return error;
    }

    for (entry = readdir(dir); entry; entry = readdir(dir)) {

        if (strcmp(entry->d_name, ".") == 0 ||
            strcmp(entry->d_name, "..") == 0) {
            continue;
        }

        error = path_concat(entry_path, sizeof(entry_path),
                            path, entry->d_name);
        if (error != SUCCESS) {
            closedir(dir);
            /* Don't bother checking the return here.
             * The path_concat error is more important
             */
            return error;
        }

        if (lstat(entry_path, &info) < 0) {
            continue;
        }

        prune = !callback(path, entry->d_name, entry_path, &info, user_data);
        if (S_ISDIR(info.st_mode)) {
            if (recursive && !prune) {
                error = directory_list(entry_path, recursive,
                                       callback, user_data);
                if (error != SUCCESS) {
                    closedir(dir);
                    /* Don't bother checking the return here.
                     * The directory_list error is more important
                     */
                    return error;
                }
            }
        }
    }
    error = closedir(dir);
    if (error) {
        return error;
    }
    return SUCCESS;
}
コード例 #9
0
ファイル: purge.c プロジェクト: sas/Droplet-backup
static void delete_object(const char *str, void *data)
{
  storage_t storage = (storage_t) data;
  char *unlink_path;

  logger(LOG_VERBOSE, "%s", str);

  unlink_path = path_concat("objects", str);
  if (!storage_unlink(storage, unlink_path))
    logger(LOG_ERROR, "%s: unable to delete object", str);
  free(unlink_path);
}
コード例 #10
0
ファイル: restore.c プロジェクト: GiorgioRegni/Droplet-backup
static struct buffer *unhash_blob(storage_t storage, const char *path, const char *hash)
{
    char *download_path;
    struct buffer *res;

    download_path = path_concat("objects", hash);
    if ((res = storage_retrieve_buffer(storage, download_path)) == NULL)
        errx(EXIT_FAILURE, "unable to retrieve: %s", path);
    free(download_path);

    return res;
}
コード例 #11
0
static int
in_original_tree (char* other_path)
{
  char* abs_src_path = abspath (NULL, src_path);
  char* abs_src_path_slash = path_concat (abs_src_path, "");
  char* abs_other_path = abspath (NULL, other_path);
  int ret_val =  !strncmp (abs_src_path_slash, abs_other_path, strlen (abs_src_path_slash));

  free (abs_src_path);
  free (abs_src_path_slash);
  free (abs_other_path);
  return ret_val;
}
コード例 #12
0
ファイル: restore.c プロジェクト: GiorgioRegni/Droplet-backup
int cmd_restore(int argc, char *argv[])
{
    storage_t storage;
    FILE *backup;
    char *backup_name;
    char *download_path;
    char buf[4096];

    if (!(argc == 3 || (argc == 2 && options['i'])))
    {
        int help_argc = 2;
        char *help_argv[] = { "help_err", "restore", NULL };
        return cmd_help(help_argc, help_argv);
    }

    if ((storage = storage_new(argv[1], 0)) == NULL)
        errx(EXIT_FAILURE, "unable to open storage: %s", argv[1]);

    if (argc == 3)
    {
        backup_name = estrdup(argv[2]);
    }
    else
    {
        printf("Available backups:\n");
        if (cmd_list(argc, argv) == EXIT_FAILURE)
            return EXIT_FAILURE;
        backup_name = readline("Enter the backup name to restore: ");
        /* Cleanly exit if the user did not enter any backup to restore. */
        if (backup_name == NULL || strlen(backup_name) == 0)
            return EXIT_SUCCESS;
    }

    download_path = path_concat("backups", backup_name);
    free(backup_name);
    if ((backup = storage_retrieve_file(storage, download_path)) == NULL)
        errx(EXIT_FAILURE, "unable to retrieve the backup description file");
    free(download_path);

    while (fgets(buf, 4096, backup) != NULL)
        unhash_dispatch(storage, "", buf);

    if (ferror(backup))
        errx(EXIT_FAILURE, "unable to restore the backup");

    fclose(backup);
    storage_delete(storage);

    return EXIT_SUCCESS;
}
コード例 #13
0
ファイル: restore.c プロジェクト: GiorgioRegni/Droplet-backup
static void unhash_link(storage_t storage, const char *path, const struct element *elem)
{
    char *download_path;
    struct buffer *descr;

    if (options['v'])
        printf("%s\n", path);

    download_path = path_concat("objects", elem->hash);
    if ((descr = storage_retrieve_buffer(storage, download_path)) == NULL)
        errx(EXIT_FAILURE, "unable to retrieve: %s", path);
    free(download_path);

    if (symlink((char *) descr->data, path) == -1 && errno != EEXIST)
        err(EXIT_FAILURE, "unable to restore: %s", path);

    buffer_delete(descr);
}
コード例 #14
0
ファイル: restore.c プロジェクト: GiorgioRegni/Droplet-backup
static void unhash_dispatch(storage_t storage, const char *path, char *elem_str)
{
    struct element elem;
    char *tmp_elem;
    char *new_path;

    if ((elem.type = strsep(&elem_str, " ")) == NULL)
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    if ((elem.hash = strsep(&elem_str, " ")) == NULL)
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    tmp_elem = elem_str;
    elem.uid = strtol(elem_str, &elem_str, 10);
    if (tmp_elem == elem_str)
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    tmp_elem = elem_str;
    elem.gid = strtol(elem_str, &elem_str, 10);
    if (tmp_elem == elem_str)
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    tmp_elem = elem_str;
    elem.perm = strtol(elem_str, &elem_str, 8);
    if (tmp_elem == elem_str)
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    ++elem_str; // Skip the space before the name
    if ((elem.name = strsep(&elem_str, "\n")) == NULL)
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    new_path = path_concat(path, elem.name);

    if (strcmp(elem.type, "file") == 0)
        unhash_file(storage, new_path, &elem);
    else if (strcmp(elem.type, "tree") == 0)
        unhash_tree(storage, new_path, &elem);
    else if (strcmp(elem.type, "link") == 0)
        unhash_link(storage, new_path, &elem);
    else
        errx(EXIT_FAILURE, "invalid description file: %s", path);

    free(new_path);
}
コード例 #15
0
ファイル: restore.c プロジェクト: GiorgioRegni/Droplet-backup
static void unhash_file(storage_t storage, const char *path, const struct element *elem)
{
    FILE *res;
    char *download_path;
    FILE *descr;
    char buf[4096];
    char *blob_hash;
    struct buffer *blob;

    if (options['v'])
        printf("%s\n", path);

    if ((res = fopen(path, "wb")) == NULL)
        err(EXIT_FAILURE, "unable to restore: %s", path);

    download_path = path_concat("objects", elem->hash);
    if ((descr = storage_retrieve_file(storage, download_path)) == NULL)
        errx(EXIT_FAILURE, "unable to retrieve: %s", path);
    free(download_path);

    while ((blob_hash = fgets(buf, 4096, descr)) != NULL)
    {
        size_t size, full_size;

        size = strlen(blob_hash);
        if (blob_hash[size - 1] != '\n')
            errx(EXIT_FAILURE, "invalid description file: %s", path);
        blob_hash[size - 1] = '\0';

        blob = unhash_blob(storage, path, blob_hash);

        full_size = 0;
        while ((size = fwrite(blob->data + full_size, 1, blob->used - full_size, res)) > 0)
            full_size += size;

        buffer_delete(blob);
    }

    if (ferror(descr))
        errx(EXIT_FAILURE, "unable to restore: %s", path);

    fclose(res);
    fclose(descr);
}
コード例 #16
0
static void
clone_symbolic_link (char* s_path,char* d_path)
{
  char symlink_buf[MAXPATHLEN + 1];
  int count;

  if ((count = readlink (s_path, symlink_buf, MAXPATHLEN)) == -1)
    {
      fprintf (stderr, "%s: error: can't read symlink %s: %s\n",
        pname, s_path, sys_errlist[errno]);
      fprintf (stderr, "%s: input file %s will be ignored\n",
        pname, s_path);
      return;
    }
  symlink_buf[count] = '\0';

  if (symlink_buf[0] == '/')		/* symlink is absolute */
    {
      if (in_original_tree (symlink_buf))
        {
           if (!quiet_flag)
	     fprintf (stderr, 
	       "%s: warning: absolute symlink points into source tree %s -> %s\n",
	       pname, s_path, symlink_buf);
	}
    }
  else					/* symlink is relative */
    {
      char* src_root_relative = path_concat (s_path, symlink_buf);
      int in_orig = in_original_tree (src_root_relative);

      free (src_root_relative);
      if (!in_orig)
        {
          if (!quiet_flag)
	    fprintf (stderr, 
              "%s: warning: relative symlink points out of source tree %s -> %s\n",
	      pname, s_path, symlink_buf);
	}
    }

  mk_symbolic_link(symlink_buf, d_path, 0); /* Make an identical symlink.  */
}
コード例 #17
0
ファイル: purge.c プロジェクト: sas/Droplet-backup
static void purge_tree(storage_t storage, strset_t objects, char *hash)
{
  char *download_path;
  FILE *descr;
  char buf[4096];

  download_path = path_concat("objects", hash);
  if ((descr = storage_retrieve_file(storage, download_path)) == NULL)
    logger(LOG_ERROR, "unable to retrieve: %s", hash);
  free(download_path);

  while (fgets(buf, 4096, descr) != NULL)
    purge_dispatch(storage, objects, buf);

  if (ferror(descr))
    logger(LOG_ERROR, "unable to purge: %s", hash);

  fclose(descr);
}
コード例 #18
0
ファイル: purge.c プロジェクト: sas/Droplet-backup
static void mark_backup(const char *str, void *data)
{
  struct mark_backup_args *args = data;
  char *download_path;
  FILE *backup;
  char buf[4096];

  download_path = path_concat("backups", str);
  if ((backup = storage_retrieve_file(args->storage, download_path)) == NULL)
    logger(LOG_ERROR, "%s: unable to retrieve the description file", str);
  free(download_path);

  while (fgets(buf, 4096, backup) != NULL)
    purge_dispatch(args->storage, args->objects, buf);

  if (ferror(backup))
    logger(LOG_ERROR, "unable to restore the backup");

  fclose(backup);
}
コード例 #19
0
ファイル: delete.c プロジェクト: sas/Droplet-backup
int cmd_delete(int argc, char *argv[])
{
  storage_t storage;
  char *backup_name;
  char *unlink_path;

  if (!(argc == 3 || (argc == 2 && options_get()->interactive)))
  {
    int help_argc = 2;
    char *help_argv[] = { "help_err", "delete", NULL };
    return cmd_help_err(help_argc, help_argv);
  }

  if ((storage = storage_new(argv[1], false, false)) == NULL)
    logger(LOG_ERROR, "unable to open storage: %s", argv[1]);

  if (argc == 3)
  {
    backup_name = estrdup(argv[2]);
  }
  else
  {
    printf("Available backups:\n");
    if (cmd_list(argc, argv) == EXIT_FAILURE)
      return EXIT_FAILURE;
    backup_name = readline("Enter the backup name to delete: ");
    /* Cleanly exit if the user did not enter any backup to delete. */
    if (backup_name == NULL || strlen(backup_name) == 0)
      return EXIT_SUCCESS;
  }

  unlink_path = path_concat("backups", backup_name);
  free(backup_name);
  if (!storage_unlink(storage, unlink_path))
    logger(LOG_ERROR, "unable to delete the backup");
  free(unlink_path);

  storage_delete(storage);

  return EXIT_SUCCESS;
}
コード例 #20
0
ファイル: vgtoolview.c プロジェクト: GNOME/alleyoop
char *
vg_tool_view_scan_path (const char *program)
{
	const char *pathenv, *path, *p;
	char *filename;
	int len;
	
	if (program[0] == '/') {
		if (path_is_rx (program))
			return g_strdup (program);
		
		return NULL;
	}
	
	if (!(pathenv = getenv ("PATH")))
		return NULL;
	
	path = pathenv;
	len = strlen (program);
	while ((p = strchr (path, ':'))) {
		if (p > path) {
			filename = path_concat (path, (p - path), program, len);
			if (path_is_rx (filename))
				return filename;
			
			g_free (filename);
		}
		
		path = p + 1;
	}
	
	if (path[0] != '\0') {
		filename = g_strdup_printf ("%s/%s", path, program);
		if (path_is_rx (filename))
			return filename;
		
		g_free (filename);
	}
	
	return NULL;
}
コード例 #21
0
static int dash_server_onlive(void* dash, http_session_t* session, const char* /*method*/, const char* path)
{
    char fullpath[PATH_MAX];
    int r = path_concat(path + 6 /* /live/ */, LOCALPATH, fullpath);
	printf("live: %s\n", fullpath);

	const char* name = path_basename(fullpath);
	if (strendswith(name, ".mpd"))
	{
        return dash_server_mpd(session, (dash_playlist_t*)dash);
	}
	else if (path_testfile(name))
	{
		// cross domain
		http_server_set_header(session, "Access-Control-Allow-Origin", "*");
		http_server_set_header(session, "Access-Control-Allow-Methods", "GET, POST, PUT");
		return http_server_sendfile(session, name, NULL, NULL);
	}

	return http_server_send(session, 404, "", 0, NULL, NULL);
}
コード例 #22
0
ファイル: import.c プロジェクト: rampantpixels/render_lib
static int
render_import_program(stream_t* stream, const uuid_t uuid) {
	char buffer[1024];
	char pathbuf[BUILD_MAX_PATHLEN];
	resource_source_t source;
	resource_platform_t platformdecl = {-1, -1, -1, -1, -1, -1};
	uint64_t platform;
	tick_t timestamp;
	int ret = 0;

	resource_source_initialize(&source);
	resource_source_read(&source, uuid);

	platform = resource_platform(platformdecl);
	timestamp = time_system();

	while (!stream_eos(stream)) {
		string_const_t type, ref;
		string_const_t fullpath;
		string_const_t uuidstr;
		uuid_t shaderuuid;
		hash_t typehash;
		string_t line = stream_read_line_buffer(stream, buffer, sizeof(buffer), '\n');
		string_split(STRING_ARGS(line), STRING_CONST(" \t"),
		             &type, &ref, false);

		type = string_strip(STRING_ARGS(type), STRING_CONST(STRING_WHITESPACE));
		ref = string_strip(STRING_ARGS(ref), STRING_CONST(STRING_WHITESPACE));
		if (!type.length || !ref.length)
			continue;

		typehash = hash(STRING_ARGS(type));
		if ((typehash != HASH_VERTEXSHADER) && (typehash != HASH_PIXELSHADER)) {
			log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS, STRING_CONST("Ignore invalid line: %.*s"),
			          STRING_FORMAT(line));
			continue;
		}

		shaderuuid = string_to_uuid(STRING_ARGS(ref));
		if (uuid_is_null(shaderuuid)) {
			if (path_is_absolute(STRING_ARGS(ref))) {
				fullpath = ref;
			}
			else {
				string_t full;
				string_const_t path = stream_path(stream);
				path = path_directory_name(STRING_ARGS(path));
				full = path_concat(pathbuf, sizeof(pathbuf),
				                   STRING_ARGS(path), STRING_ARGS(ref));
				full = path_absolute(STRING_ARGS(full), sizeof(pathbuf));
				fullpath = string_const(STRING_ARGS(full));
			}

			resource_signature_t sig = resource_import_lookup(STRING_ARGS(fullpath));
			if (uuid_is_null(sig.uuid)) {
				if (!resource_import(STRING_ARGS(fullpath), uuid_null())) {
					log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS, STRING_CONST("Unable to import linked shader: %.*s"),
					          STRING_FORMAT(fullpath));
					ret = -1;
					goto finalize;
				}
				sig = resource_import_lookup(STRING_ARGS(fullpath));
				if (uuid_is_null(sig.uuid)) {
					log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS,
					          STRING_CONST("Import linked shader gave no UUID: %.*s"),
					          STRING_FORMAT(fullpath));
					ret = -1;
					goto finalize;
				}
			}
			shaderuuid = sig.uuid;
		}

		if (!uuid_is_null(shaderuuid)) {
			uuidstr = string_from_uuid_static(shaderuuid);
			resource_source_set(&source, timestamp, typehash,
			                    platform, STRING_ARGS(uuidstr));
		}
	}

	resource_source_set(&source, timestamp, HASH_RESOURCE_TYPE,
	                    0, STRING_CONST("program"));

	if (!resource_source_write(&source, uuid, false)) {
		string_const_t uuidstr = string_from_uuid_static(uuid);
		log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS, STRING_CONST("Failed writing imported program: %.*s"),
		          STRING_FORMAT(uuidstr));
		ret = -1;
		goto finalize;
	}
	else {
		string_const_t uuidstr = string_from_uuid_static(uuid);
		log_infof(HASH_RESOURCE, STRING_CONST("Wrote imported program: %.*s"),
		          STRING_FORMAT(uuidstr));
	}

finalize:
	resource_source_finalize(&source);

	return ret;
}
コード例 #23
0
ファイル: import.c プロジェクト: rampantpixels/render_lib
static int
render_import_shader(stream_t* stream, const uuid_t uuid) {
	char buffer[1024];
	char pathbuf[BUILD_MAX_PATHLEN];
	resource_source_t source;
	resource_platform_t platformdecl = {-1, -1, -1, -1, -1, -1};
	uint64_t platform;
	tick_t timestamp;
	int ret = 0;

	resource_source_initialize(&source);
	resource_source_read(&source, uuid);

	platform = resource_platform(platformdecl);
	timestamp = time_system();

	while (!stream_eos(stream)) {
		uuid_t shaderuuid;
		string_const_t target, ref, fullpath;
		string_t line = stream_read_line_buffer(stream, buffer, sizeof(buffer), '\n');
		string_split(STRING_ARGS(line), STRING_CONST(" \t"),
		             &target, &ref, false);

		ref = string_strip(STRING_ARGS(ref), STRING_CONST(STRING_WHITESPACE));
		shaderuuid = string_to_uuid(STRING_ARGS(ref));
		if (uuid_is_null(shaderuuid)) {
			if (path_is_absolute(STRING_ARGS(ref))) {
				fullpath = ref;
			}
			else {
				string_t full;
				string_const_t path = stream_path(stream);
				path = path_directory_name(STRING_ARGS(path));
				full = path_concat(pathbuf, sizeof(pathbuf),
				                   STRING_ARGS(path), STRING_ARGS(ref));
				full = path_absolute(STRING_ARGS(full), sizeof(pathbuf));
				fullpath = string_const(STRING_ARGS(full));
			}

			resource_signature_t sig = resource_import_lookup(STRING_ARGS(fullpath));
			if (uuid_is_null(sig.uuid)) {
				if (!resource_import(STRING_ARGS(fullpath), uuid_null())) {
					log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS,
					          STRING_CONST("Unable to import linked shader: %.*s"),
					          STRING_FORMAT(fullpath));
					ret = -1;
					goto finalize;
				}
				sig = resource_import_lookup(STRING_ARGS(fullpath));
				if (uuid_is_null(sig.uuid)) {
					log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS,
					          STRING_CONST("Import linked shader gave no UUID: %.*s"),
					          STRING_FORMAT(fullpath));
					ret = -1;
					goto finalize;
				}
			}
			shaderuuid = sig.uuid;
		}

		if (!uuid_is_null(shaderuuid)) {
			resource_platform_t targetplatformdecl =
			    render_import_parse_target(STRING_ARGS(target), platformdecl);
			uint64_t targetplatform = resource_platform(targetplatformdecl);

			if (resource_autoimport_need_update(shaderuuid, targetplatform))
				resource_autoimport(shaderuuid);

			const string_const_t uuidstr = string_from_uuid_static(shaderuuid);
			resource_source_set(&source, timestamp, HASH_SHADER,
			                    targetplatform, STRING_ARGS(uuidstr));
			resource_source_set_dependencies(uuid, targetplatform, &shaderuuid, 1);
		}
	}

	resource_source_set(&source, timestamp, HASH_RESOURCE_TYPE,
	                    0, STRING_CONST("shader"));

	if (!resource_source_write(&source, uuid, false)) {
		string_const_t uuidstr = string_from_uuid_static(uuid);
		log_warnf(HASH_RESOURCE, WARNING_SUSPICIOUS, STRING_CONST("Failed writing imported shader: %.*s"),
		          STRING_FORMAT(uuidstr));
		ret = -1;
		goto finalize;
	}
	else {
		string_const_t uuidstr = string_from_uuid_static(uuid);
		log_infof(HASH_RESOURCE, STRING_CONST("Wrote imported shader: %.*s"),
		          STRING_FORMAT(uuidstr));
	}

finalize:
	resource_source_finalize(&source);

	return 0;
}
コード例 #24
0
ファイル: main.c プロジェクト: rampantpixels/task_lib
int
main_run(void* main_arg) {
#if !BUILD_MONOLITHIC
	string_const_t pattern;
	string_t* exe_paths = 0;
	size_t iexe, exesize;
	process_t* process = 0;
	string_t process_path = { 0, 0 };
	unsigned int* exe_flags = 0;
#else
	void* test_result;
#endif
#if FOUNDATION_PLATFORM_IOS || FOUNDATION_PLATFORM_ANDROID || FOUNDATION_PLATFORM_PNACL
	int remain_counter = 0;
#endif
#if BUILD_DEBUG
	const string_const_t build_name = string_const(STRING_CONST("debug"));
#elif BUILD_RELEASE
	const string_const_t build_name = string_const(STRING_CONST("release"));
#elif BUILD_PROFILE
	const string_const_t build_name = string_const(STRING_CONST("profile"));
#elif BUILD_DEPLOY
	const string_const_t build_name = string_const(STRING_CONST("deploy"));
#endif
#if BUILD_MONOLITHIC
	const string_const_t build_type = string_const(STRING_CONST(" monolithic"));
#else
	const string_const_t build_type = string_empty();
#endif
	char* pathbuf;
	int process_result = 0;
	thread_t event_thread;
	FOUNDATION_UNUSED(main_arg);
	FOUNDATION_UNUSED(build_name);

	log_set_suppress(HASH_TEST, ERRORLEVEL_DEBUG);

	log_infof(HASH_TEST, STRING_CONST("Task library v%s built for %s using %s (%.*s%.*s)"),
	          string_from_version_static(task_module_version()).str, FOUNDATION_PLATFORM_DESCRIPTION,
	          FOUNDATION_COMPILER_DESCRIPTION, STRING_FORMAT(build_name), STRING_FORMAT(build_type));

	thread_initialize(&event_thread, event_loop, 0, STRING_CONST("event_thread"),
	                  THREAD_PRIORITY_NORMAL, 0);
	thread_start(&event_thread);

	pathbuf = memory_allocate(HASH_STRING, BUILD_MAX_PATHLEN, 0, MEMORY_PERSISTENT);

	while (!thread_is_running(&event_thread))
		thread_sleep(10);

#if FOUNDATION_PLATFORM_IOS || FOUNDATION_PLATFORM_ANDROID || FOUNDATION_PLATFORM_PNACL
	while (!_test_should_start) {
#if FOUNDATION_PLATFORM_ANDROID
		system_process_events();
#endif
		thread_sleep(100);
	}
#endif

	fs_remove_directory(STRING_ARGS(environment_temporary_directory()));

#if BUILD_MONOLITHIC

	test_run_fn tests[] = {
		test_task_run,
		0
	};

#if FOUNDATION_PLATFORM_ANDROID

	thread_t test_thread;
	thread_initialize(&test_thread, test_runner, tests, STRING_CONST("test_runner"),
	                  THREAD_PRIORITY_NORMAL, 0);
	thread_start(&test_thread);

	log_debug(HASH_TEST, STRING_CONST("Starting test runner thread"));

	while (!thread_is_running(&test_thread)) {
		system_process_events();
		thread_sleep(10);
	}

	while (thread_is_running(&test_thread)) {
		system_process_events();
		thread_sleep(10);
	}

	test_result = thread_join(&test_thread);
	process_result = (int)(intptr_t)test_result;

	thread_finalize(&test_thread);

#else

	test_result = test_runner(tests);
	process_result = (int)(intptr_t)test_result;

#endif

	if (process_result != 0)
		log_warnf(HASH_TEST, WARNING_SUSPICIOUS, STRING_CONST("Tests failed with exit code %d"),
		          process_result);

#if FOUNDATION_PLATFORM_IOS || FOUNDATION_PLATFORM_ANDROID || FOUNDATION_PLATFORM_PNACL

	while (!_test_should_terminate && _test_have_focus && (remain_counter < 50)) {
		system_process_events();
		thread_sleep(100);
		++remain_counter;
	}

#endif

	log_debug(HASH_TEST, STRING_CONST("Exiting main loop"));

#else // !BUILD_MONOLITHIC

	//Find all test executables in the current executable directory
#if FOUNDATION_PLATFORM_WINDOWS
	pattern = string_const(STRING_CONST("^test-.*\\.exe$"));
#elif FOUNDATION_PLATFORM_MACOSX
	pattern = string_const(STRING_CONST("^test-.*$"));
#elif FOUNDATION_PLATFORM_POSIX
	pattern = string_const(STRING_CONST("^test-.*$"));
#else
#  error Not implemented
#endif
	exe_paths = fs_matching_files(STRING_ARGS(environment_executable_directory()),
	                              STRING_ARGS(pattern), false);
	array_resize(exe_flags, array_size(exe_paths));
	memset(exe_flags, 0, sizeof(unsigned int) * array_size(exe_flags));
#if FOUNDATION_PLATFORM_MACOSX
	//Also search for test applications
	string_const_t app_pattern = string_const(STRING_CONST("^test-.*\\.app$"));
	regex_t* app_regex = regex_compile(app_pattern.str, app_pattern.length);
	string_t* subdirs = fs_subdirs(STRING_ARGS(environment_executable_directory()));
	for (size_t idir = 0, dirsize = array_size(subdirs); idir < dirsize; ++idir) {
		if (regex_match(app_regex, subdirs[idir].str, subdirs[idir].length, 0, 0)) {
			string_t exe_path = { subdirs[idir].str, subdirs[idir].length - 4 };
			array_push(exe_paths, exe_path);
			array_push(exe_flags, PROCESS_MACOSX_USE_OPENAPPLICATION);
		}
	}
	string_array_deallocate(subdirs);
	regex_deallocate(app_regex);
#endif
	for (iexe = 0, exesize = array_size(exe_paths); iexe < exesize; ++iexe) {
		string_const_t* process_args = 0;
		string_const_t exe_file_name = path_base_file_name(STRING_ARGS(exe_paths[iexe]));
		if (string_equal(STRING_ARGS(exe_file_name), STRING_ARGS(environment_executable_name())))
			continue; //Don't run self

		process_path = path_concat(pathbuf, BUILD_MAX_PATHLEN,
		                           STRING_ARGS(environment_executable_directory()),
		                           STRING_ARGS(exe_paths[iexe]));
		process = process_allocate();

		process_set_executable_path(process, STRING_ARGS(process_path));
		process_set_working_directory(process, STRING_ARGS(environment_executable_directory()));
		process_set_flags(process, PROCESS_ATTACHED | exe_flags[iexe]);

		if (!_test_memory_tracker)
			array_push(process_args, string_const(STRING_CONST("--no-memory-tracker")));
		process_set_arguments(process, process_args, array_size(process_args));

		log_infof(HASH_TEST, STRING_CONST("Running test executable: %.*s"),
		          STRING_FORMAT(exe_paths[iexe]));

		process_result = process_spawn(process);
		while (process_result == PROCESS_WAIT_INTERRUPTED) {
			thread_sleep(10);
			process_result = process_wait(process);
		}
		process_deallocate(process);
		array_deallocate(process_args);

		if (process_result != 0) {
			if (process_result >= PROCESS_INVALID_ARGS)
				log_warnf(HASH_TEST, WARNING_SUSPICIOUS,
				          STRING_CONST("Tests failed, process terminated with error %x"),
				          process_result);
			else
				log_warnf(HASH_TEST, WARNING_SUSPICIOUS, STRING_CONST("Tests failed with exit code %d"),
				          process_result);
			process_set_exit_code(-1);
			goto exit;
		}

		log_infof(HASH_TEST, STRING_CONST("All tests from %.*s passed (%d)"),
		          STRING_FORMAT(exe_paths[iexe]), process_result);
	}

	log_info(HASH_TEST, STRING_CONST("All tests passed"));

exit:

	if (exe_paths)
		string_array_deallocate(exe_paths);
	array_deallocate(exe_flags);

#endif

	_test_should_terminate = true;

	thread_signal(&event_thread);
	thread_finalize(&event_thread);

	memory_deallocate(pathbuf);

	log_infof(HASH_TEST, STRING_CONST("Tests exiting: %s (%d)"),
	          process_result ? "FAILED" : "PASSED", process_result);

	if (process_result)
		memory_set_tracker(memory_tracker_none());

	return process_result;
}
コード例 #25
0
void quotes::remove( std::string name ) {
	ifile::remove( path_concat( name, "base" ) );
	stringarray::remove( path_concat( name, "docs" ) );
}
コード例 #26
0
quotes::quotes( std::string name ):
	impl_( path_concat( name, "base" ) ),
	docs_( path_concat( name, "docs" ) )
{
}
コード例 #27
0
static void
clone_dir (char* s_path, char* d_path, int level)
{
  DIR* dirp;

  if (access (s_path, R_OK) != 0)
    {
      if (!quiet_flag)
        {
          fprintf (stderr, 
            "%s: error: don't have read permission for input directory %s\n"
,
	    pname, s_path);
          fprintf (stderr, "%s: input directory %s will be ignored\n",
	    pname, s_path);
	 }
        return;
    }

  if (access (s_path, X_OK) != 0)
    {
      if (!quiet_flag)
        {
           fprintf (stderr, 
             "%s: error: don't have search permission for input directory %s\n",
	     pname, s_path);
           fprintf (stderr, "%s: input directory %s will be ignored\n",
	     pname, s_path);
	 }
       return;
    }

  if ((dirp = opendir (s_path)) == NULL)
    {
      if (!quiet_flag)
        {
          fprintf (stderr, "%s: error: can't open directory %s for reading: %s\n",
            pname, s_path, sys_errlist[errno]);
          fprintf (stderr, "%s: input directory %s will be ignored\n",
            pname, s_path);
        }
      return;
    }

  for (;;)
    {
      struct dirent* dir_entry_p;
      char* new_s_path;
      char* new_d_path;
      char  symlink_buf[MAXPATHLEN + 1];
      int   len;

      if ((dir_entry_p = readdir (dirp)) == NULL)
        break;
      if (!strcmp (dir_entry_p->d_name, "."))
        continue;
      if (!strcmp (dir_entry_p->d_name, ".."))
        continue;

      new_s_path = path_concat (s_path, dir_entry_p->d_name);
      new_d_path = path_concat (d_path, dir_entry_p->d_name);

      if (sccs_flag && !strcmp (dir_entry_p->d_name, "SCCS"))
        symlink_SCCS(new_s_path, new_d_path);
      else
        clone (new_s_path, new_d_path, 0, level+1);

      free (new_s_path);
      free (new_d_path);
    }

  closedir (dirp);
}
コード例 #28
0
ファイル: config.c プロジェクト: XQF/xqf
static struct config_key *parse_path (const char *path,
		int create,
		char **defval,
		struct config_file **file1,
		struct config_section **section1) {
	const char *filename;
	char *secname = NULL;
	char *keyname = NULL;
	char *def;
	char *buf = NULL;
	char *ptr = NULL;
	struct config_file *file;
	struct config_key *key = NULL;

	if (defval) {
		*defval = NULL;
		def = strchr (path, '=');
		if (def)
			*defval = def + 1;
	}

	if (*path != '/') {
		if (prefix_stack)
			buf = path_concat ((const char *) prefix_stack->data, path);
		else
			return NULL;

		if (*buf != '/') {
			g_free (buf);
			return NULL;
		}
	}
	else {
		buf = g_strdup (path);
	}

	def = strchr (buf, '=');
	if (def)
		*def = '\0';

	filename = ptr = &buf[1];

	// XXX:
	if (!strncmp(buf, "/scripts", strlen("/scripts"))) {
		ptr = strchr (ptr, '/');
		if (ptr)
			++ptr;
	}

	secname = strchr (ptr, '/');
	if (secname) {
		*secname++ = '\0';

		keyname = strchr (secname, '/');
		if (keyname)
			*keyname++ = '\0';
	}

	/* Ensure that the file is loaded */

	find_key (filename, NULL, NULL, FALSE, &file, NULL, NULL);
	if (!file)
		load_file (filename);

	/* Actually look up the key */

	find_key (filename, secname, keyname, create, file1, section1, &key);

	if (buf)
		g_free (buf);

	return key;
}
コード例 #29
0
ファイル: voxel.c プロジェクト: poftwaresatent/cerebrate
FILE * voxel_resolve_file(char const * fname, int verbose)
{
  FILE * result = NULL;
  char buf[PATH_MAX];
  char * home = getenv("HOME");
  char * haiko_path = getenv("HAIKO_PATH");
  char userdir_path[PATH_MAX];
  char sharedir_path[PATH_MAX];
  
  if (NULL == home) {
    if (verbose)
      printf("no home directory\n");
    userdir_path[0] = '\0';
  }
  else {
    if (verbose)
      printf("abspath of userdir \"%s\" + \"%s\"\n", home, userdir);
    switch (path_concat(userdir_path, home, userdir, verbose)) {
    case -1:
      if (verbose)
	printf("  ERROR in path_concat()\n");
      userdir_path[0] = '\0';
      break;
    case -2:
      if (verbose)
	printf("  realpath() failed\n");
      userdir_path[0] = '\0';
      break;
    case 0:
      if (verbose)
	printf("  RESOLVED \"%s\"\n", userdir_path);
      break;
    default:
      fprintf(stderr,
	      "voxel_resolve_file(): BUG? unhandled path_concat() retval\n");
      userdir_path[0] = '\0';
    }
    if (('\0' != userdir_path[0]) && verbose)
      printf("userdir_path \"%s\"\n", userdir_path);
  }
  
  if (NULL == realpath(sharedir, sharedir_path)) {
    if (verbose)
      printf("invalid sharedir \"%s\"\n  %s: %s\n",
	     sharedir, sharedir_path, strerror(errno));
    sharedir_path[0] = '\0';
  }
  else if (verbose)
    printf("sharedir_path \"%s\"\n", sharedir_path);

  if (verbose)
    printf("resolving filename \"%s\"\n", fname);
  
  switch (is_absolute(fname)) {
  case -1:
    if (verbose)
      printf("  ERROR in is_absolute()\n");
    break;
  case 0:
    /* not absolute */
    break;
  case 1:
    if (verbose)
      printf("  resolved absolute path\n");
    result = fopen(fname, "r");
    if (NULL != result) {
      if (verbose)
	printf("  FOUND absolute path\n");
      return result;
    }
    if (verbose)
      printf("  absolute path is not a (valid) file\n");
    break;
  default:
    fprintf(stderr,
	    "voxel_resolve_file(): BUG? unhandled is_absolute() retval\n");
  }
  
  switch (has_dirsep(fname)) {
  case -1:
    if (verbose)
      printf("  ERROR in has_dirsep()\n");
    break;
  case 0:
    /* no dirsep in fname */
    break;
  case 1:
    if (verbose)
      printf("  resolved relative path\n");
    result = fopen(fname, "r");
    if (NULL != result) {
      if (verbose)
	printf("  FOUND relative path\n");
      return result;
    }
    if (verbose)
      printf("  relative path is not a (valid) file\n");
    break;
  default:
    fprintf(stderr,
	    "voxel_resolve_file(): BUG? unhandled has_dirsep() retval\n");
  }
  
  if (NULL == haiko_path) {
    if (verbose)
      printf("  no HAIKO_PATH\n");
  }
  else {
    if (verbose)
      printf("  HAIKO_PATH + fname = \"%s\" + \"%s\"\n", haiko_path, fname);
    switch (path_concat(buf, haiko_path, fname, verbose)) {
    case -1:
      if (verbose)
	printf("    ERROR in path_concat()\n");
      break;
    case -2:
      if (verbose)
	printf("    realpath() failed\n");
      break;
    case 0:
      if (verbose)
	printf("    resolved file in HAIKO_PATH: \"%s\"\n", buf);
      result = fopen(buf, "r");
      if (NULL != result) {
	if (verbose)
	  printf("  FOUND in HAIKO_PATH\n");
	return result;
      }
      if (verbose)
	printf("  invalid file in HAIKO_PATH\n");
      break;
    default:
      fprintf(stderr,
	      "voxel_resolve_file(): BUG? unhandled path_concat() retval\n");
    }
  }
  
  if ('\0' == userdir_path[0]) {
    if (verbose)
      printf("  no userdir_path\n");
  }
  else {
    if (verbose)
      printf("  userdir_path + fname = \"%s\" + \"%s\"\n",
	     userdir_path, fname);
    switch (path_concat(buf, userdir_path, fname, verbose)) {
    case -1:
      if (verbose)
	printf("    ERROR in path_concat()\n");
      break;
    case -2:
      if (verbose)
	printf("    realpath() failed\n");
      break;
    case 0:
      if (verbose)
	printf("    resolved file in userdir: \"%s\"\n", buf);
      result = fopen(buf, "r");
      if (NULL != result) {
	if (verbose)
	  printf("  FOUND in userdir\n");
	return result;
      }
      if (verbose)
	printf("  invalid file in userdir\n");
      break;
    default:
      fprintf(stderr,
	      "voxel_resolve_file(): BUG? unhandled path_concat() retval\n");
    }
  }
  
  if ('\0' == sharedir_path[0]) {
    if (verbose)
      printf("  no sharedir_path\n");
  }
  else {
    if (verbose)
      printf("  sharedir_path + fname = \"%s\" + \"%s\"\n",
	     sharedir_path, fname);
    switch (path_concat(buf, sharedir_path, fname, verbose)) {
    case -1:
      if (verbose)
	printf("    ERROR in path_concat()\n");
      break;
    case -2:
      if (verbose)
	printf("    realpath() failed\n");
      break;
    case 0:
      if (verbose)
	printf("    resolved file in sharedir: \"%s\"\n", buf);
      result = fopen(buf, "r");
      if (NULL != result) {
	if (verbose)
	  printf("  FOUND in sharedir\n");
	return result;
      }
      if (verbose)
	printf("  invalid file in sharedir\n");
      break;
    default:
      fprintf(stderr,
	      "voxel_resolve_file(): BUG? unhandled path_concat() retval\n");
    }
  }
  
  if (verbose)
    printf("  SORRY, could not resolve file \"%s\"\n", fname);
  return NULL;
}
コード例 #30
0
ファイル: tpath.c プロジェクト: poftwaresatent/cerebrate
int main(int argc, char ** argv)
{
  char buf[PATH_MAX];
  char * home = getenv("HOME");
  char * haiko_path = getenv("HAIKO_PATH");
  char userdir_path[PATH_MAX];
  char sharedir_path[PATH_MAX];
  int ii;
  int verbose = 0;
  
  if (NULL == home) {
    printf("no home directory\n");
    userdir_path[0] = '\0';
  }
  else {
    if (verbose)
      printf("abspath of userdir \"%s\" + \"%s\"\n", home, userdir);
    switch (path_concat(userdir_path, home, userdir, verbose)) {
    case -1:
      printf("  ERROR in path_concat()\n");
      userdir_path[0] = '\0';
      break;
    case -2:
      printf("  realpath() failed\n");
      userdir_path[0] = '\0';
      break;
    case 0:
      if (verbose)
	printf("  RESOLVED \"%s\"\n", userdir_path);
      break;
    default:
      printf("  ERROR unhandled path_concat() retval\n");
      userdir_path[0] = '\0';
    }
    if ('\0' != userdir_path[0])
      printf("userdir_path \"%s\"\n", userdir_path);
  }
  
  if (NULL == realpath(sharedir, sharedir_path)) {
    printf("invalid sharedir \"%s\"\n  %s: %s\n",
	   sharedir, sharedir_path, strerror(errno));
    sharedir_path[0] = '\0';
  }
  else
    printf("sharedir_path \"%s\"\n", sharedir_path);
  
  for (ii = 1; ii < argc; ii++) {
    printf("checking filename \"%s\"\n", argv[ii]);
    switch (is_absolute(argv[ii])) {
    case -1:
      printf("  ERROR in is_absolute()\n");
      continue;
    case 0:
      /* not absolute */
      break;
    case 1:
      printf("  resolved absolute path\n");
      if (file_exists(argv[ii])) {
	printf("  FOUND absolute path\n");
	continue;
      }
      printf("  absolute path is not a (valid) file\n");
      break;
    default:
      printf("  ERROR unhandled is_absolute() retval\n");
    }
    
    switch (has_dirsep(argv[ii])) {
    case -1:
      printf("  ERROR in has_dirsep()\n");
      continue;
    case 0:
      /* no dirsep in fname */
      break;
    case 1:
      printf("  RESOLVED relative path\n");
      continue;
    default:
      printf("  ERROR unhandled has_dirsep() retval\n");
    }
    
    if (NULL == haiko_path)
      printf("  no HAIKO_PATH\n");
    else {
      printf("  HAIKO_PATH + fname = \"%s%s\"\n", haiko_path, argv[ii]);
      switch (path_concat(buf, haiko_path, argv[ii], verbose)) {
      case -1:
	printf("    ERROR in path_concat()\n");
	break;
      case -2:
	printf("    realpath() failed\n");
	break;
      case 0:
	printf("    resolved file in HAIKO_PATH: \"%s\"\n", buf);
	if (file_exists(buf)) {
	  printf("    FOUND in HAIKO_PATH\n");
	  continue;
	}
	printf("    but it is not a (valid) file\n");
	break;
      default:
	printf("    ERROR unhandled path_concat() retval\n");
      }
    }
    
    if ('\0' == userdir_path[0])
      printf("  no userdir_path\n");
    else {
      printf("  userdir_path + fname = \"%s%s\"\n", userdir_path, argv[ii]);
      switch (path_concat(buf, userdir_path, argv[ii], verbose)) {
      case -1:
	printf("    ERROR in path_concat()\n");
	break;
      case -2:
	printf("    realpath() failed\n");
	break;
      case 0:
	printf("    resolved file in userdir: \"%s\"\n", buf);
	if (file_exists(buf)) {
	  printf("    FOUND in userdir\n");
	  continue;
	}
	printf("    but it is not a (valid) file\n");
	break;
      default:
	printf("    ERROR unhandled path_concat() retval\n");
      }
    }
    
    if ('\0' == sharedir_path[0])
      printf("  no sharedir_path\n");
    else {
      printf("  sharedir_path + fname = \"%s%s\"\n", sharedir_path, argv[ii]);
      switch (path_concat(buf, sharedir_path, argv[ii], verbose)) {
      case -1:
	printf("    ERROR in path_concat()\n");
	break;
      case -2:
	printf("    realpath() failed\n");
	break;
      case 0:
	printf("    resolved file in sharedir: \"%s\"\n", buf);
	if (file_exists(buf)) {
	  printf("    FOUND in sharedir\n");
	  continue;
	}
	printf("    but it is not a (valid) file\n");
	break;
      default:
	printf("    ERROR unhandled path_concat() retval\n");
      }
    }
    
    printf("  SORRY, could not resolve file \"%s\"\n", argv[ii]);
  }
  
  return 0;
}