This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

compile problems, mod with mysql

Discussion of Eggdrop's code and module programming in C.
Post Reply
m
mayatekla
Voice
Posts: 3
Joined: Mon Sep 08, 2008 8:21 am

compile problems, mod with mysql

Post by mayatekla »

ok, I have been trying to compile this for the last couple days but i cant for the life of me work out whats going wrong... from the error message it seems to be saying its a problem with an inlude of an included header which should be perfectly correct....

Code: Select all

make[2]: Entering directory `/home/xxxxxxxxxxxx/IRC/eggdropStuff/eggdropSource/eggdrop1.6.19/src/mod/al.mod'
gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H   `(mysql_config --cflags)` -DMAKING_MODS -c .././al.mod/al.c
In file included from /usr/include/mysql/mysql.h:76,
                 from .././al.mod/al.c:13:
/usr/include/mysql/my_list.h:31: error: expected identifier or ‘(’ before ‘int’
/usr/include/mysql/my_list.h:31: error: expected ‘)’ before ‘global’
make[2]: *** [../al.o] Error 1
make[2]: Leaving directory `/home/xxxxxxxxxxxx/IRC/eggdropStuff/eggdropSource/eggdrop1.6.19/src/mod/al.mod'
make[1]: *** [al.mod_so] Error 2
make[1]: Leaving directory `/home/xxxxxxxxxxxx/IRC/eggdropStuff/eggdropSource/eggdrop1.6.19/src/mod'
make: *** [modules] Error 2
anyone have any clue whats going on here or what to do with it??

[/code]
m
mayatekla
Voice
Posts: 3
Joined: Mon Sep 08, 2008 8:21 am

Post by mayatekla »

oh, for reference:

Code: Select all


/*
 *
 *
 *
 *
*/

#define MODULE_NAME "al"
#define MAKING_AL

#include "src/mod/module.h"
#include <mysql.h>
#include <stdio.h>



#undef global

static Function *global = NULL;

static void do_list();

static int al_expmem()
{
  return 0;
}

static int pub_al(char *nick, char *host, char *hand, char *channel, char *text)
{
    dprintf(DP_HELP, "PRIVMSG %s :Test :: %s :: %s :: %s :: %s :: %s", nick, nick, host, hand, channel, text);
    do_list(nick, text);
    return 0;
}

static int msg_al(char *nick, char *host, struct userrec *u, char *text)
{
    dprintf(DP_SERVER, "PRIVMSG %s : Test :: %s :: %s :: %s", nick, nick, host, text);
    do_list(nick, text);
    return 0;
}

static void do_list(char *nick, char *text)
{
    dprintf(DP_SERVER, "PRIVMSG %s : Test :: %s :: %s", nick, nick, text);


/*
 * SQL stuff start
 */
 
    MYSQL *conn;
    MYSQL_RES *res;
    MYSQL_ROW row;

    char *server = "localhost";
    char *user = "eggdrop-xxxx";
    char *password = "xxxxxxx"; /* set me first */
    char *database = "eggdrop_al";

    conn = mysql_init(NULL);

    /* Connect to database */
    if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) {
	dprintf(DP_SERVER, "PRIVMSG %s : There was an error of some kind please report to an owner: %s\n", nick, mysql_error(conn));
	exit(1);
    }

    /* send SQL query */
    if (mysql_query(conn, "SELECT * FROM `eggdrop_al`.`denylist`")) {
	dprintf(DP_SERVER, "PRIVMSG %s : There was an error of some kind please report to an owner: %s\n", nick, mysql_error(conn));
	exit(1);
    }

    res = mysql_use_result(conn);

    /* output table name */
	dprintf(DP_SERVER, "PRIVMSG %s :id :: nick :: date :: reason :: by:\n");
    while ((row = mysql_fetch_row(res)) != NULL)
	dprintf(DP_SERVER, "PRIVMSG %s :%s  %s  %s  %s  %s\n", nick, row[0], row[1], row[2], row[3], row[4]);

    /* close connection */
    mysql_free_result(res);
    mysql_close(conn);



 
/*
 * SQL stuff end
 */
}

static cmd_t al_pub[] = {
  /* command  flags  function     tcl-name */
  {"!list", "", pub_al, NULL},
  {NULL, NULL, NULL, NULL}  /* Mark end. */
};

static cmd_t al_msg[] = {
  {"!list", "", msg_al, NULL},
  {NULL, NULL, NULL, NULL}
};

static void al_report(int idx, int details)
{
  if (details) {
    int size = al_expmem();

    dprintf(idx, "    Using %d byte%s of memory\n", size,
            (size != 1) ? "s" : "");
  }
}

static char *al_close()
{
  //Context;
    p_tcl_bind_list H_temp;
    
    if ((H_temp = find_bind_table("pub")))
	rem_builtins(H_temp, al_pub);
    if ((H_temp = find_bind_table("msg")))
	rem_builtins(H_temp, al_msg);
 
  module_undepend(MODULE_NAME);
  return NULL;
}

EXPORT_SCOPE char *al_start();

static Function al_table[] = {
  (Function) al_start,
  (Function) al_close,
  (Function) al_expmem,
  (Function) al_report,
};


char *al_start(Function *global_funcs)
{
  /* Assign the core function table. After this point you use all normal
   * functions defined in src/mod/modules.h
   */
  global = global_funcs;

  Context;
  /* Register the module. */
  module_register(MODULE_NAME, al_table, 1, 0);

  if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
    module_undepend(MODULE_NAME);
    return "This module requires Eggdrop 1.6.0 or later.";
  }

    p_tcl_bind_list H_temp;

    if ((H_temp = find_bind_table("msg")))
	add_builtins(H_temp, al_msg);
    if ((H_temp = find_bind_table("pub")))
	add_builtins(H_temp, al_pub);

  return NULL;
}

m
mayatekla
Voice
Posts: 3
Joined: Mon Sep 08, 2008 8:21 am

Post by mayatekla »

[solved]

It seems list_delete is defined in eggdrops users.h as well as mysql's my_list.h

so for a nice solution:

Code: Select all

#define MODULE_NAME "al"
#define MAKING_AL

#define list_delete egg_list_delete
#include "src/mod/module.h"
#undef list_delete

#include <mysql.h>
reorganisation of the includes, redefine eggdrops list_delete to egg_list_delete then undef list_delete before including mysql.h


Evil things like this give me headaches
Post Reply