dbus_bool_t
test_connection_setup (DBusLoop       *loop,
                       DBusConnection *connection)
{
  CData *cd;

  cd = NULL;
  
  dbus_connection_set_dispatch_status_function (connection, dispatch_status_function,
                                                loop, NULL);
  
  cd = cdata_new (loop, connection);
  if (cd == NULL)
    goto nomem;

  if (!dbus_connection_set_watch_functions (connection,
                                            add_watch,
                                            remove_watch,
                                            toggle_watch,
                                            cd, cdata_free))
    goto nomem;


  cd = cdata_new (loop, connection);
  if (cd == NULL)
    goto nomem;
  
  if (!dbus_connection_set_timeout_functions (connection,
                                              add_timeout,
                                              remove_timeout,
                                              NULL,
                                              cd, cdata_free))
    goto nomem;

  if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE)
    {
      if (!_dbus_loop_queue_dispatch (loop, connection))
        goto nomem;
    }
  
  return TRUE;
  
 nomem:
  if (cd)
    cdata_free (cd);
  
  dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
  dbus_connection_set_watch_functions (connection, NULL, NULL, NULL, NULL, NULL);
  dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL);
  
  return FALSE;
}
Example #2
0
int main(int argc, char *argv[])
{
	printf("@@@@@@@@@@ hello cstock @@@@@@@@@@ \n");
	cdata* data;
	data = cdata_new();
	if (data)
	{
		//data->ops->get_foreign_investor_sorting_data(data, 104, 8, 8);
		//data->ops->update_data(data);
		data->ops->get_bshtm_data(data, 2317, 104, 8, 5);
		data->ops->close(data);
	}
	
/*
	chttp* 	c;
	char* 	data_buf;
	int		read_size; 
	
	data_buf = (char*)malloc(PAGE_SIZE);
	
	c = chttp_new();
	c->ops->connect(c, "www.twse.com.tw");
	c->ops->post(c, "/ch/trading/fund/TWT38U/TWT38U.php", "download=csv&qdate=104%2F08%2F06&sorting=by_issue", data_buf, PAGE_SIZE, &read_size);
	c->ops->close(c);

	FILE *fp = fopen("data.html", "wb+");
    fwrite(data_buf, 1, read_size, fp);
    fclose(fp);
	
	free(data_buf);*/
	return 1;
}