Hylafax Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-users] Modifying the Hylafax source code to interact with MySQL



Hello world,
 
Greetings!
 
I have created a table called logtable in MySQL.
 
When the fax is received apart from updating xferfaxlog file the following modified code is expected to update the MySQL logtable.
 
But while compiling using ?make? I am getting errors! (Displayed @ the bottom!)
 
FileTransfer.c++
 
void
HylaFAXServer::logTransfer(const char* direction,
    const SpoolDir& sd, const char* pathname, time_t start)
{
    char sql[250];
    time_t now = Sys::now();
    time_t xferfaxtime = now - start;
    if (xferfaxtime == 0)
 xferfaxtime++;
    const char* filename = strrchr(pathname, '/');
    fxStr msg(fxStr::format("%.24s %lu %s %lu %s/%s %s %s\n"
 , ctime(&now)
 , (u_long) xferfaxtime
 , (const char*) remotehost
 , (u_long) byte_count
 , sd.pathname, filename ? filename+1 : pathname
 , direction
 , (const char*) the_user
    ));
 sprintf(sql,"insert into logtable values(NULL,'%.24s',%lu,'%s',%lu,'%s','%s','%s','%s')"
        , ctime(&now)
 , (u_long) xferfaxtime
 , (const char*) remotehost
 , (u_long) byte_count
 , sd.pathname, filename ? filename+1 : pathname
 , direction
 , (const char*) the_user
    );
    InsertSQL(sql); 
    (void) Sys::write(xferfaxlog, msg, msg.length());
}
int HylaFAXServer::InsertSQL(char *sql)
{
        MYSQL      mysql;
        MYSQL_RES *res;
        MYSQL_ROW  row;
 

        assert(mysql_init(&mysql) != NULL);
        /* this only works in 3.23 */
        assert(mysql_options(&mysql, MYSQL_READ_DEFAULT_GROUP, "simple") == 0);
        if (mysql_real_connect(&mysql, NULL, NULL, NULL, NULL, 0, NULL, 0) == NULL) {
                fprintf(stderr, "error on connect: %s\n", mysql_error(&mysql));
                exit(EXIT_FAILURE);
        }
        if(mysql_select_db(&mysql, "accusys") != 0) {
                fprintf(stderr, "error on query: %s\n", mysql_error(&mysql));
                exit(EXIT_FAILURE);
           }
        if(mysql_query(&mysql,sql)!=0)
        {
           fprintf(stderr, "error on query: %s\n", mysql_error(&mysql));
           exit(EXIT_FAILURE);
        }
        mysql_close(&mysql);
        exit(EXIT_SUCCESS);
}
 
Error messages while running ?make? :-
 
FileTransfer.o(.text+0x144): In function `HylaFAXServer::InsertSQL(char*)':
/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:119: undefined reference to `mysql_init'
FileTransfer.o(.text+0x174):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:121: undefined reference to `mysql_options'
FileTransfer.o(.text+0x1ab):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:122: undefined reference to `mysql_real_connect'
FileTransfer.o(.text+0x1bb):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:123: undefined reference to `mysql_error'
FileTransfer.o(.text+0x1da):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:127: undefined reference to `mysql_select_db'
FileTransfer.o(.text+0x1ea):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:128: undefined reference to `mysql_error'
FileTransfer.o(.text+0x219):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:132: undefined reference to `mysql_query'
FileTransfer.o(.text+0x22f):/var/fax/hylafax-4.1.8/hfaxd/FileTransfer.c++:139: undefined reference to `mysql_close'

Where should I make changes in the ?make? file to compile the modified code properly!
Regards
Lawrence


Do you Yahoo!?
Yahoo! Search - Find what you?re looking for faster.

Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services