diff --git a/caca/caca.c b/caca/caca.c
index c0b4fac..b36da20 100644
--- a/caca/caca.c
+++ b/caca/caca.c
@@ -198,6 +198,19 @@ cucul_canvas_t * caca_get_canvas(caca_display_t *dp)
return dp->cv;
}
+/** \brief Return the \e libcaca version.
+ *
+ * Return a read-only string with the \e libcaca version information.
+ *
+ * This function never fails.
+ *
+ * \return The \e libcaca version information.
+ */
+char const * caca_get_version(void)
+{
+ return VERSION;
+}
+
/*
* XXX: The following functions are local.
*/
diff --git a/caca/caca.h b/caca/caca.h
index edb667d..7f16182 100644
--- a/caca/caca.h
+++ b/caca/caca.h
@@ -164,6 +164,7 @@ __extern unsigned int caca_get_display_height(caca_display_t const *);
__extern int caca_set_display_title(caca_display_t *, char const *);
__extern int caca_set_mouse(caca_display_t *, int);
__extern int caca_set_cursor(caca_display_t *, int);
+__extern char const * caca_get_version(void);
/* @} */
/** \defgroup caca_event libcaca event handling
diff --git a/cucul/cucul.c b/cucul/cucul.c
index 985b236..9a976f2 100644
--- a/cucul/cucul.c
+++ b/cucul/cucul.c
@@ -334,6 +334,19 @@ int cucul_rand(int min, int max)
return min + (int)((1.0 * (max - min)) * rand() / (RAND_MAX + 1.0));
}
+/** \brief Return the \e libcucul version.
+ *
+ * Return a read-only string with the \e libcucul version information.
+ *
+ * This function never fails.
+ *
+ * \return The \e libcucul version information.
+ */
+char const * cucul_get_version(void)
+{
+ return VERSION;
+}
+
/*
* XXX: The following functions are local.
*/
diff --git a/cucul/cucul.h b/cucul/cucul.h
index f9ab032..9ac38a8 100644
--- a/cucul/cucul.h
+++ b/cucul/cucul.h
@@ -93,6 +93,7 @@ __extern unsigned char const * cucul_get_canvas_chars(cucul_canvas_t const *);
__extern unsigned char const * cucul_get_canvas_attrs(cucul_canvas_t const *);
__extern int cucul_free_canvas(cucul_canvas_t *);
__extern int cucul_rand(int, int);
+__extern char const * cucul_get_version(void);
/* @} */
/** \defgroup cucul_canvas libcucul canvas drawing
diff --git a/cucul/export.c b/cucul/export.c
index b458753..03b1f0c 100644
--- a/cucul/export.c
+++ b/cucul/export.c
@@ -378,7 +378,8 @@ static void *export_html(cucul_canvas_t const *cv, unsigned long int *bytes)
/* HTML header */
cur += sprintf(cur, "
\n");
- cur += sprintf(cur, "Generated by libcaca %s\n", VERSION);
+ cur += sprintf(cur, "Generated by libcaca %s\n",
+ cucul_get_version());
cur += sprintf(cur, "\n");
cur += sprintf(cur, "\n",
diff --git a/cxx/caca++.cpp b/cxx/caca++.cpp
index a8734b3..a50cfd7 100644
--- a/cxx/caca++.cpp
+++ b/cxx/caca++.cpp
@@ -96,3 +96,8 @@ void Caca::setMouse(int v)
caca_set_mouse(dp, v);
}
+const char * Caca::getVersion()
+{
+ return caca_get_version();
+}
+
diff --git a/cxx/caca++.h b/cxx/caca++.h
index 10cc83d..383e2f2 100644
--- a/cxx/caca++.h
+++ b/cxx/caca++.h
@@ -78,6 +78,7 @@ __class Caca
unsigned int getMouseY();
void setMouse(int);
+ static char const * getVersion();
private:
caca_display_t *dp;
};
diff --git a/cxx/cucul++.cpp b/cxx/cucul++.cpp
index 45e1752..ad36912 100644
--- a/cxx/cucul++.cpp
+++ b/cxx/cucul++.cpp
@@ -236,6 +236,11 @@ int Cucul::Rand(int min, int max)
return cucul_rand(min, max);
}
+const char * Cucul::getVersion()
+{
+ return cucul_get_version();
+}
+
int Cucul::setAttr(unsigned long int attr)
{
return cucul_set_attr(cv, attr);
diff --git a/cxx/cucul++.h b/cxx/cucul++.h
index a3be116..b941680 100644
--- a/cxx/cucul++.h
+++ b/cxx/cucul++.h
@@ -129,7 +129,6 @@ __class Cucul
void drawTriangle(int, int, int, int, int, int, unsigned long int);
void drawThinTriangle(int, int, int, int, int, int);
void fillTriangle(int, int, int, int, int, int, unsigned long int);
- int Rand(int, int);
int setBoundaries(cucul_canvas_t *, int, int, unsigned int, unsigned int);
unsigned int getFrameCount();
int setFrame(unsigned int);
@@ -142,6 +141,8 @@ __class Cucul
char const * const * getExportList(void);
void *exportMemory(char const *, unsigned long int *);
+ static int Rand(int, int);
+ static char const * getVersion();
protected:
cucul_canvas_t *get_cucul_canvas_t();
diff --git a/cxx/cxxtest.cpp b/cxx/cxxtest.cpp
index 4348e22..64ec2b1 100644
--- a/cxx/cxxtest.cpp
+++ b/cxx/cxxtest.cpp
@@ -12,8 +12,6 @@
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/
-#include "config.h"
-
#include
#include
@@ -41,13 +39,13 @@ static char const pigstring[] =
int main(int argc, char *argv[])
{
- Cucul *qq, *pig;
- Caca *kk;
+ Cucul *cv, *pig;
+ Caca *dp;
int x = 0, y = 0, ix = 1, iy = 1;
try {
- qq = new Cucul();
+ cv = new Cucul();
}
catch (int e) {
cerr << "Error while initializing cucul (" << e << ")" << endl;
@@ -55,7 +53,7 @@ int main(int argc, char *argv[])
}
try {
- kk = new Caca(qq);
+ dp = new Caca(cv);
}
catch(int e) {
cerr << "Error while attaching cucul to caca (" << e << ")" << endl;
@@ -73,42 +71,42 @@ int main(int argc, char *argv[])
return -1;
}
- kk->setDisplayTime(20000);
+ dp->setDisplayTime(20000);
- while(!kk->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0))
+ while(!dp->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0))
{
/* In case of resize ...*/
- if((x + pig->getWidth())-1 >= qq->getWidth() || x < 0 )
+ if((x + pig->getWidth())-1 >= cv->getWidth() || x < 0 )
x = 0;
- if((y + pig->getHeight())-1 >= qq->getHeight() || y < 0 )
+ if((y + pig->getHeight())-1 >= cv->getHeight() || y < 0 )
y = 0;
- qq->Clear();
+ cv->Clear();
/* Draw pig */
- qq->Blit(x, y, pig, NULL);
+ cv->Blit(x, y, pig, NULL);
/* printf works */
- qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
- qq->Printf(qq->getWidth() / 2 - 10, qq->getHeight() / 2,
- "Powered by libcaca %s", VERSION);
+ cv->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
+ cv->Printf(cv->getWidth() / 2 - 10, cv->getHeight() / 2,
+ "Powered by libcaca %s", dp->getVersion());
/* Blit */
- kk->Display();
+ dp->Display();
x += ix;
y += iy;
- if(x + pig->getWidth() >= qq->getWidth() || x < 0 )
+ if(x + pig->getWidth() >= cv->getWidth() || x < 0 )
ix = -ix;
- if(y + pig->getHeight() >= qq->getHeight() || y < 0 )
+ if(y + pig->getHeight() >= cv->getHeight() || y < 0 )
iy = -iy;
}
- delete kk;
- delete qq;
+ delete dp;
+ delete cv;
return 0;
}
diff --git a/src/img2txt.c b/src/img2txt.c
index 69c3835..5d90c02 100644
--- a/src/img2txt.c
+++ b/src/img2txt.c
@@ -88,8 +88,8 @@ static void version(void)
"\n"
"The latest version of img2txt is available from the web site,\n"
" http://libcaca.zoy.org/ in the libcaca package.\n"
- "\n"
- , VERSION, __DATE__);
+ "\n",
+ cucul_get_version(), __DATE__);
}
int main(int argc, char **argv)
{