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.

problem witch a function in a c modul

Old posts that have not been replied to for several years.
Locked
M
Majesticc

Post by Majesticc »

Hello,
I have a little problem with a c funtion with my stand alone program it will be work but included in the eggdrop modul i get a sigint on sending the bind. I have reached the error function but i dont find any error. Here is the fuction code:

Code: Select all

static char*** get_table_data(char *table)	
{
  MYSQL_RES *result; 
  MYSQL_ROW row;
  unsigned int i; 
  int numrows;
  int numfields;
  int rowcount;
  int fieldcount;
  int rowi;
  char ***erow;
  char query[] = "SELECT * from ";
  strcat(query,table); 
  mysql_query(dbh,query);
  result = mysql_store_result(dbh); 
  numrows = mysql_num_rows(result);
  numfields = mysql_num_fields(result);
  erow=(char ***)nmalloc(numrows*sizeof(char *));
  for(rowi=0;rowi<numrows;rowi++)
   erow[rowi] = (char **)nmalloc(numfields*sizeof(char *));
  /*
  while((field = mysql_fetch_field(result)))
    {
      printf("%s ", field->name);
    }
  */
  //printf("n");
  rowcount = 0;
  //printf("R:%d F:%dn",numrows,numfields);
  while ((row = mysql_fetch_row(result)) != NULL) 
    {
      fieldcount = 0;
      //printf("n");
      for (i=0; i<numfields; i++) 
	{ 
	  //printf("%s ",row[i] != NULL ? row[i] : "NULL"); 
	  erow[rowcount][fieldcount] = row[i];
	  fieldcount++;
	  //printf("%d",fieldcount);
	}
      
      //printf("%sn",row[0]); 
      rowcount++;
    }
  //printf("n");
  //printf("TEST: %sn",erow[0][2]);
  mysql_free_result(result);
  mysql_close(dbh);
return erow;
//  for(i=0; i<numrows; i++) 
//   { 
//      nfree(erow[i]); 
//    } 
//  nfree(erow);
}
I hope anyone can help me.



<font size=-1>[ This Message was edited by: Majesticc on 2001-12-16 02:54 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Well I didn't look at all of it, but right away I noticed this:

strcat(query,table);

You can't do that, there's no room in the query array for more data the way it's defined.
M
Majesticc

Post by Majesticc »

I have fix it but nothing now i have a question about the Makefile. I must insert this lines for the compiler:

Code: Select all

 -L/usr/lib/mysql -lmysqlclient -lnsl
This is needed for the mysql database. Where is the right location in the Makefile i think this is maybe the error...

<font size=-1>[ This Message was edited by: Majesticc on 2001-12-16 08:56 ]</font>
t
tajson

Post by tajson »

My Makefile for my mod mod.mysql looks like this:

Code: Select all

# Makefile for src/mod/mysql.mod/
# $Id: Makefile,v 1.9 2000/07/09 14:10:49 fabian Exp $

srcdir = .


doofus:
	@echo ""
	@echo "Let's try this from the right directory..."
	@echo ""
	@cd ../../../ && make

static: ../mysql.o

modules: ../../../mysql.$(MOD_EXT)

../mysql.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -I/usr/local/mysql/include/mysql -DMAKING_MODS -c $(srcdir)/mysql.c
	@rm -f ../mysql.o
	mv mysql.o ../

../../../mysql.$(MOD_EXT): ../mysql.o
	$(LD)  -L/usr/local/mysql/lib/mysql -lmysqlclient -o ../../../mysql.$(MOD_EXT) ../mysql.o
	$(STRIP) ../../../mysql.$(MOD_EXT)

depend:
	$(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/mysql.c > .depend

clean:
	@rm -f .depend *.o *.$(MOD_EXT) *~
distclean: clean

#safety hash
../mysql.o: .././mysql.mod/mysql.c ../../../src/mod/module.h 
 ../../../src/main.h ../../../src/lang.h ../../../src/eggdrop.h 
 ../../../src/flags.h ../../../src/proto.h ../../../lush.h 
 ../../../src/misc_file.h ../../../src/cmdt.h ../../../src/tclegg.h 
 ../../../src/tclhash.h ../../../src/chan.h ../../../src/users.h 
 ../../../src/compat/compat.h ../../../src/compat/inet_aton.h 
 ../../../src/compat/snprintf.h ../../../src/compat/memset.h 
 ../../../src/compat/memcpy.h ../../../src/compat/strcasecmp.h 
 ../../../src/mod/modvals.h ../../../src/tandem.h
_________________
http://joakim.gissberg.nu/ | joakim@gissberg.nu

<font size=-1>[ This Message was edited by: tajson on 2001-12-31 02:50 ]</font>
g
guppy
eggdrop engineer
Posts: 199
Joined: Mon Sep 24, 2001 8:00 pm
Location: Canada
Contact:

Post by guppy »

Why is no one sharing their mysql modules with the rest of the community? :)
t
tajson

Post by tajson »

On 2001-12-31 14:16, guppy wrote:
Why is no one sharing their mysql modules with the rest of the community? :smile:
I am, but mine is not just ready yet. Right now if you want mine, just mail me. I will put up a snapshot of it when I feel it's ready for testing.

My homepage is http://joakim.gissberg.nu/, as shown below.


Locked