slang-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] Complex Structure (MYSQL)


How can I create such a complex structure as the MYSQL structure? It's:

typedef struct st_mysql {
  NET		net;			/* Communication parameters */
  gptr		connector_fd;		/* ConnectorFd for SSL */
  char		*host,*user,*passwd,*unix_socket,*server_version,*host_info,
		*info,*db;
  struct charset_info_st *charset;
  MYSQL_FIELD	*fields;
  MEM_ROOT	field_alloc;
  my_ulonglong affected_rows;
  my_ulonglong insert_id;		/* id if insert on table with NEXTNR */
  my_ulonglong extra_info;		/* Used by mysqlshow */
  unsigned long thread_id;		/* Id for connection in server */
  unsigned long packet_length;
  unsigned int	port,client_flag,server_capabilities;
  unsigned int	protocol_version;
  unsigned int	field_count;
  unsigned int 	server_status;
  unsigned int  server_language;
  struct st_mysql_options options;
  enum mysql_status status;
  my_bool	free_me;		/* If free in mysql_close */
  my_bool	reconnect;		/* set to 1 if automatic reconnect */
  char	        scramble_buff[9];

 /*
   Set if this is the original connection, not a master or a slave we have
   added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
 */
  my_bool rpl_pivot;
  /*
    Pointers to the master, and the next slave connections, points to
    itself if lone connection.
  */
  struct st_mysql* master, *next_slave;

  struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
 /* needed for send/read/store/use result to work correctly with replication */
  struct st_mysql* last_used_con;
} MYSQL;

and some of the other structures (MYSQL_FIELD, NET) are just as complex. All
I want to do is pass the pointer to this structure around... for instance:

variable m = mysql_init();
mysql_query(m, "SELECT * FROM names");
mysql_close(m);

I never need to do anything with it, just use it as a reference. I therefore
tried to create mysql_init intrinstic as:

MAKE_INTRINSIC_1("mysql_init", mysql_init, SLANG_REF_TYPE, SLANG_NULL_TYPE)

but that results in:

[jeremy@mylaptop modules]$ slsh -
import("mysql");
variable m = mysql_init(NULL);
S-Lang Error: Not Implemented: Support for intrinsic functions returning Ref_Type is not provided
Segmentation fault

Any ideas?

Jeremy


_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]