[ekg2-commit] ekg2: stuff.c (HEAD) stuff.h (HEAD) [darkjames]
CVS commit
cvs w toxygen.net
Śro, 2 Maj 2007, 18:31:11 CEST
Module name: ekg2
Changes by: darkjames 2007-05-02 18:31:09
Modified files:
stuff.c stuff.h
Log message:
new function: prepare_sapath()
Index: stuff.c
===================================================================
RCS file: /home/cvs/ekg2/ekg/stuff.c,v
diff -d -u -r1.188 -r1.189
--- stuff.c 2 May 2007 14:23:54 -0000 1.188
+++ stuff.c 2 May 2007 16:31:08 -0000 1.189
@@ -61,6 +61,11 @@
#include <iconv.h>
+#ifndef HAVE_STRLCPY
+# include "compat/strlcpy.h"
+#endif
+
+
#include "debug.h"
#include "commands.h"
#include "dynstuff.h"
@@ -1503,6 +1508,24 @@
return 0;
}
+const char *prepare_sapath(const char *filename, ...) {
+ static char path[PATH_MAX];
+ size_t len;
+
+ len = strlcpy(path, config_dir ? config_dir : "", sizeof(path));
+
+ if (filename && *filename && len < sizeof(path)-1) { /* -1 coz of '/' */
+ va_list ap;
+
+ va_start(ap, filename);
+ path[len++] = '/';
+ vsnprintf(&path[len], sizeof(path)-len, filename, ap);
+ va_end(ap);
+ }
+
+ return path;
+}
+
/*
* prepare_path()
*
Index: stuff.h
===================================================================
RCS file: /home/cvs/ekg2/ekg/stuff.h,v
diff -d -u -r1.99 -r1.100
--- stuff.h 1 May 2007 14:09:07 -0000 1.99
+++ stuff.h 2 May 2007 16:31:09 -0000 1.100
@@ -316,6 +316,7 @@
int play_sound(const char *sound_path);
const char *prepare_path(const char *filename, int do_mkdir);
+const char *prepare_sapath(const char *filename, ...);
char *read_file(FILE *f, int alloc);
const char *timestamp(const char *format);
Więcej informacji o liście dyskusyjnej ekg2-commit