summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-03-17 11:26:30 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-03-17 11:26:30 +0000
commit66f6e9eff5c2b9f0d5c0bcffcfbc93bf2edaa7b3 (patch)
treed3d621e6074ce3e663d2d910ed5afeb9c60c2acf /utils
parent603de48f10dd0580db5658484c03bd4fd6dc4690 (diff)
downloadnetsurf-66f6e9eff5c2b9f0d5c0bcffcfbc93bf2edaa7b3.tar.gz
netsurf-66f6e9eff5c2b9f0d5c0bcffcfbc93bf2edaa7b3.tar.bz2
Rename utils/resource to utils/filepath to avoid confusion with resource: fetcher.
svn path=/trunk/netsurf/; revision=12088
Diffstat (limited to 'utils')
-rw-r--r--utils/filepath.c (renamed from utils/resource.c)48
-rw-r--r--utils/filepath.h (renamed from utils/resource.h)41
2 files changed, 49 insertions, 40 deletions
diff --git a/utils/resource.c b/utils/filepath.c
index 80b1c8280..e2d90bbb7 100644
--- a/utils/resource.c
+++ b/utils/filepath.c
@@ -32,13 +32,13 @@
#include <string.h>
#include "utils/config.h"
-#include "utils/resource.h"
+#include "utils/filepath.h"
/** maximum number of elements in the resource vector */
#define MAX_RESPATH 128
-/* exported interface documented in findresource.h */
-char *resource_vsfindfile(char *str, const char *format, va_list ap)
+/* exported interface documented in filepath.h */
+char *filepath_vsfindfile(char *str, const char *format, va_list ap)
{
char *realpathname;
char *pathname;
@@ -73,21 +73,21 @@ char *resource_vsfindfile(char *str, const char *format, va_list ap)
return realpathname;
}
-/* exported interface documented in findresource.h */
-char *resource_sfindfile(char *str, const char *format, ...)
+/* exported interface documented in filepath.h */
+char *filepath_sfindfile(char *str, const char *format, ...)
{
va_list ap;
char *ret;
va_start(ap, format);
- ret = resource_vsfindfile(str, format, ap);
+ ret = filepath_vsfindfile(str, format, ap);
va_end(ap);
return ret;
}
-/* exported interface documented in findresource.h */
-char *resource_findfile(const char *format, ...)
+/* exported interface documented in filepath.h */
+char *filepath_findfile(const char *format, ...)
{
char *str;
char *ret;
@@ -98,7 +98,7 @@ char *resource_findfile(const char *format, ...)
return NULL; /* unable to allocate memory */
va_start(ap, format);
- ret = resource_vsfindfile(str, format, ap);
+ ret = filepath_vsfindfile(str, format, ap);
va_end(ap);
if (ret == NULL)
@@ -107,8 +107,8 @@ char *resource_findfile(const char *format, ...)
return ret;
}
-/* exported interface documented in findresource.h */
-char *resource_sfind(char **respathv, char *filepath, const char *filename)
+/* exported interface documented in filepath.h */
+char *filepath_sfind(char **respathv, char *filepath, const char *filename)
{
int respathc = 0;
@@ -116,7 +116,7 @@ char *resource_sfind(char **respathv, char *filepath, const char *filename)
return NULL;
while (respathv[respathc] != NULL) {
- if (resource_sfindfile(filepath, "%s/%s", respathv[respathc], filename) != NULL)
+ if (filepath_sfindfile(filepath, "%s/%s", respathv[respathc], filename) != NULL)
return filepath;
respathc++;
@@ -125,8 +125,8 @@ char *resource_sfind(char **respathv, char *filepath, const char *filename)
return NULL;
}
-/* exported interface documented in findresource.h */
-char *resource_find(char **respathv, const char *filename)
+/* exported interface documented in filepath.h */
+char *filepath_find(char **respathv, const char *filename)
{
char *ret;
char *filepath;
@@ -138,7 +138,7 @@ char *resource_find(char **respathv, const char *filename)
if (filepath == NULL)
return NULL;
- ret = resource_sfind(respathv, filepath, filename);
+ ret = filepath_sfind(respathv, filepath, filename);
if (ret == NULL)
free(filepath);
@@ -146,8 +146,8 @@ char *resource_find(char **respathv, const char *filename)
return ret;
}
-/* exported interface documented in findresource.h */
-char *resource_sfinddef(char **respathv, char *filepath, const char *filename, const char *def)
+/* exported interface documented in filepath.h */
+char *filepath_sfinddef(char **respathv, char *filepath, const char *filename, const char *def)
{
char t[PATH_MAX];
char *ret;
@@ -155,7 +155,7 @@ char *resource_sfinddef(char **respathv, char *filepath, const char *filename, c
if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
return NULL;
- ret = resource_sfind(respathv, filepath, filename);
+ ret = filepath_sfind(respathv, filepath, filename);
if ((ret == NULL) && (def != NULL)) {
/* search failed, return the path specified */
@@ -174,9 +174,9 @@ char *resource_sfinddef(char **respathv, char *filepath, const char *filename, c
}
-/* exported interface documented in resource.h */
+/* exported interface documented in filepath.h */
char **
-resource_generate(char * const *pathv, const char * const *langv)
+filepath_generate(char * const *pathv, const char * const *langv)
{
char **respath; /* resource paths vector */
int pathc = 0;
@@ -262,9 +262,9 @@ expand_path(const char *path)
return exp;
}
-/* exported interface documented in resource.h */
+/* exported interface documented in filepath.h */
char **
-resource_path_to_strvec(const char *path)
+filepath_path_to_strvec(const char *path)
{
char **strvec;
int strc = 0;
@@ -302,8 +302,8 @@ resource_path_to_strvec(const char *path)
return strvec;
}
-/* exported interface documented in resource.h */
-void resource_free_strvec(char **pathv)
+/* exported interface documented in filepath.h */
+void filepath_free_strvec(char **pathv)
{
free(pathv[0]);
free(pathv);
diff --git a/utils/resource.h b/utils/filepath.h
index fb717cdea..08dd050d3 100644
--- a/utils/resource.h
+++ b/utils/filepath.h
@@ -16,13 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file Utility routines to locate file resources. */
+/** \file Utility routines to obtain paths to file resources. */
-#ifndef _NETSURF_UTILS_RESOURCE_H_
-#define _NETSURF_UTILS_RESOURCE_H_
+#ifndef _NETSURF_UTILS_FILEPATH_H_
+#define _NETSURF_UTILS_FILEPATH_H_
#include <stdarg.h>
+
/** Create a normalised file name.
*
* If the file described by the format exists and is accessible the
@@ -36,20 +37,23 @@
* @return A pointer to the expanded filename or NULL if the file is
* not present or accessible.
*/
-char *resource_vsfindfile(char *str, const char *format, va_list ap);
+char *filepath_vsfindfile(char *str, const char *format, va_list ap);
+
/** Create a normalised file name.
*
* Similar to vsfindfile but takes variadic (printf like) parameters
*/
-char *resource_sfindfile(char *str, const char *format, ...);
+char *filepath_sfindfile(char *str, const char *format, ...);
+
/** Create a normalised file name.
*
* Similar to sfindfile but allocates its own storage for the
* returned string. The caller must free this sorage.
*/
-char *resource_findfile(const char *format, ...);
+char *filepath_findfile(const char *format, ...);
+
/** Searches an array of resource paths for a file.
*
@@ -62,23 +66,27 @@ char *resource_findfile(const char *format, ...);
* @param filename The filename of the resource to search for.
* @return A pointer to filepath if a target is found or NULL if not.
*/
-char *resource_sfind(char **respathv, char *filepath, const char *filename);
+char *filepath_sfind(char **respathv, char *filepath, const char *filename);
+
/** Searches an array of resource paths for a file.
*
- * Similar to resource_sfind except it allocates its own storage for
+ * Similar to filepath_sfind except it allocates its own storage for
* the returned string. The caller must free this sorage.
*/
-char *resource_find(char **respathv, const char *filename);
+char *filepath_find(char **respathv, const char *filename);
+
/** Searches an array of resource paths for a file optionally forcing a default.
*
- * Similar to resource_sfind except if no resource is found the default
+ * Similar to filepath_sfind except if no resource is found the default
* is used as an additional path element to search, if that still
* fails the returned path is set to the concatination of the default
* path and the filename.
*/
-char *resource_sfinddef(char **respathv, char *filepath, const char *filename, const char *def);
+char *filepath_sfinddef(char **respathv, char *filepath, const char *filename,
+ const char *def);
+
/** Merge two string vectors into a resource search path vector.
*
@@ -87,7 +95,7 @@ char *resource_sfinddef(char **respathv, char *filepath, const char *filename, c
* @return A pointer to a NULL terminated string vector of valid
* resource directories.
*/
-char **resource_generate(char * const *pathv, const char * const *langv);
+char **filepath_generate(char * const *pathv, const char * const *langv);
/** Convert a colon separated list of path elements into a string vector.
@@ -96,12 +104,13 @@ char **resource_generate(char * const *pathv, const char * const *langv);
* @return A pointer to a NULL terminated string vector of valid
* resource directories.
*/
-char **resource_path_to_strvec(const char *path);
+char **filepath_path_to_strvec(const char *path);
+
/** Free a string vector
*
- * Free a string vector allocated by resource_path_to_strvec
+ * Free a string vector allocated by filepath_path_to_strvec
*/
-void resource_free_strvec(char **pathv);
+void filepath_free_strvec(char **pathv);
-#endif /* _NETSURF_UTILS_RESOURCE_H_ */
+#endif /* _NETSURF_UTILS_FILEPATH_H_ */