Changeset 2074


Ignore:
Timestamp:
Nov 26, 2007, 2:04:32 AM (12 years ago)
Author:
Sam Hocevar
Message:
  • Add cucul_get_version() and caca_get_version() and updated C++ bindings accordingly.
  • The C++ test example no longer needs "config.h".
Location:
libcaca/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca.c

    r2061 r2074  
    199199}
    200200
     201/** \brief Return the \e libcaca version.
     202 *
     203 *  Return a read-only string with the \e libcaca version information.
     204 *
     205 *  This function never fails.
     206 *
     207 *  \return The \e libcaca version information.
     208 */
     209char const * caca_get_version(void)
     210{
     211    return VERSION;
     212}
     213
    201214/*
    202215 * XXX: The following functions are local.
  • libcaca/trunk/caca/caca.h

    r2073 r2074  
    165165__extern int caca_set_mouse(caca_display_t *, int);
    166166__extern int caca_set_cursor(caca_display_t *, int);
     167__extern char const * caca_get_version(void);
    167168/*  @} */
    168169
  • libcaca/trunk/cucul/cucul.c

    r2056 r2074  
    333333
    334334    return min + (int)((1.0 * (max - min)) * rand() / (RAND_MAX + 1.0));
     335}
     336
     337/** \brief Return the \e libcucul version.
     338 *
     339 *  Return a read-only string with the \e libcucul version information.
     340 *
     341 *  This function never fails.
     342 *
     343 *  \return The \e libcucul version information.
     344 */
     345char const * cucul_get_version(void)
     346{
     347    return VERSION;
    335348}
    336349
  • libcaca/trunk/cucul/cucul.h

    r2071 r2074  
    9494__extern int cucul_free_canvas(cucul_canvas_t *);
    9595__extern int cucul_rand(int, int);
     96__extern char const * cucul_get_version(void);
    9697/*  @} */
    9798
  • libcaca/trunk/cucul/export.c

    r2057 r2074  
    379379    /* HTML header */
    380380    cur += sprintf(cur, "<html><head>\n");
    381     cur += sprintf(cur, "<title>Generated by libcaca %s</title>\n", VERSION);
     381    cur += sprintf(cur, "<title>Generated by libcaca %s</title>\n",
     382                        cucul_get_version());
    382383    cur += sprintf(cur, "</head><body>\n");
    383384
  • libcaca/trunk/cxx/caca++.cpp

    r2050 r2074  
    9797}
    9898
     99const char * Caca::getVersion()
     100{
     101    return caca_get_version();
     102}
     103
  • libcaca/trunk/cxx/caca++.h

    r2071 r2074  
    7979    void setMouse(int);
    8080
     81    static char const * getVersion();
    8182 private:
    8283    caca_display_t *dp;
  • libcaca/trunk/cxx/cucul++.cpp

    r1952 r2074  
    237237}
    238238
     239const char * Cucul::getVersion()
     240{
     241    return cucul_get_version();
     242}
     243
    239244int Cucul::setAttr(unsigned long int attr)
    240245{
  • libcaca/trunk/cxx/cucul++.h

    r2071 r2074  
    130130    void drawThinTriangle(int, int, int, int, int, int);
    131131    void fillTriangle(int, int, int, int, int, int, unsigned long int);
    132     int Rand(int, int);
    133132    int setBoundaries(cucul_canvas_t *, int, int, unsigned int, unsigned int);
    134133    unsigned int getFrameCount();
     
    143142    void *exportMemory(char const *, unsigned long int *);
    144143
     144    static int Rand(int, int);
     145    static char const * getVersion();
    145146 protected:
    146147    cucul_canvas_t *get_cucul_canvas_t();
  • libcaca/trunk/cxx/cxxtest.cpp

    r2070 r2074  
    1212 *  http://sam.zoy.org/wtfpl/COPYING for more details.
    1313 */
    14 
    15 #include "config.h"
    1614
    1715#include <iostream>
     
    4240int main(int argc, char *argv[])
    4341{
    44     Cucul *qq, *pig;
    45     Caca  *kk;
     42    Cucul *cv, *pig;
     43    Caca  *dp;
    4644
    4745    int x = 0, y = 0, ix = 1, iy = 1;
    4846
    4947    try {
    50         qq = new Cucul();
     48        cv = new Cucul();
    5149    }
    5250    catch (int e) {
     
    5654
    5755    try {
    58         kk = new Caca(qq);
     56        dp = new Caca(cv);
    5957    }
    6058    catch(int e) {
     
    7472    }
    7573
    76     kk->setDisplayTime(20000);
     74    dp->setDisplayTime(20000);
    7775
    78     while(!kk->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0))
     76    while(!dp->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0))
    7977    {
    8078
    8179        /* In case of resize ...*/
    82         if((x + pig->getWidth())-1 >= qq->getWidth() || x < 0 )
     80        if((x + pig->getWidth())-1 >= cv->getWidth() || x < 0 )
    8381            x = 0;
    84         if((y + pig->getHeight())-1 >= qq->getHeight() || y < 0 )
     82        if((y + pig->getHeight())-1 >= cv->getHeight() || y < 0 )
    8583            y = 0;
    8684
    87         qq->Clear();
     85        cv->Clear();
    8886
    8987        /* Draw pig */
    90         qq->Blit(x, y, pig, NULL);
     88        cv->Blit(x, y, pig, NULL);
    9189
    9290        /* printf works */
    93         qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
    94         qq->Printf(qq->getWidth() / 2 - 10, qq->getHeight() / 2,
    95                    "Powered by libcaca %s", VERSION);
     91        cv->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
     92        cv->Printf(cv->getWidth() / 2 - 10, cv->getHeight() / 2,
     93                   "Powered by libcaca %s", dp->getVersion());
    9694
    9795        /* Blit */
    98         kk->Display();
     96        dp->Display();
    9997
    10098        x += ix;
    10199        y += iy;
    102100
    103         if(x + pig->getWidth() >= qq->getWidth() || x < 0 )
     101        if(x + pig->getWidth() >= cv->getWidth() || x < 0 )
    104102            ix = -ix;
    105         if(y + pig->getHeight() >= qq->getHeight() || y < 0 )
     103        if(y + pig->getHeight() >= cv->getHeight() || y < 0 )
    106104            iy = -iy;
    107105
    108106    }
    109107
    110     delete kk;
    111     delete qq;
     108    delete dp;
     109    delete cv;
    112110
    113111    return 0;
  • libcaca/trunk/src/img2txt.c

    r1919 r2074  
    8989    "The latest version of img2txt is available from the web site,\n"
    9090    "        http://libcaca.zoy.org/ in the libcaca package.\n"
    91     "\n"
    92     , VERSION, __DATE__);
     91    "\n",
     92    cucul_get_version(), __DATE__);
    9393}
    9494int main(int argc, char **argv)
Note: See TracChangeset for help on using the changeset viewer.