示例#1
0
文件: request.c 项目: ihrwein/webhdfs
int webhdfs_req_open (webhdfs_req_t *req,
                      webhdfs_t *fs,
                      const char *path)
{
    const webhdfs_conf_t *conf = fs->conf;
    int r;

    buffer_open(&(req->buffer));

    /* No upload by default */
    req->upload_data = NULL;
    req->upload = NULL;

    /* Fill URL */
    buffer_clear(&(req->buffer));
    r = buffer_append_format(&(req->buffer), "%s://%s:%d/webhdfs/v1/%s?",
                             conf->use_ssl ? "https" : "http",
                             conf->host, conf->port,
                             (path != NULL) ? path + 1 : "");

    if (conf->user != NULL)
        r |= buffer_append_format(&(req->buffer), "user.name=%s&", conf->user);

    if (conf->token != NULL)
        r |= buffer_append_format(&(req->buffer), "delegation=%s&", conf->token);

    return(r);
}
示例#2
0
文件: ff-save.c 项目: Distrotech/gegl
static void
init (GeglProperties *o)
{
  static gint inited = 0; /*< this is actually meant to be static, only to be done once */
  Priv       *p = (Priv*)o->user_data;

  if (p == NULL)
    {
      p = g_new0 (Priv, 1);
      o->user_data = (void*) p;
    }

  if (!inited)
    {
      av_register_all ();
      avcodec_register_all ();
      inited = 1;
    }

#ifndef DISABLE_AUDIO
  p->oxide_audio_instance = gggl_op_sym (op, "oxide_audio_instance");
  p->oxide_audio_query = gggl_op_sym (op, "oxide_audio_query()");
  p->oxide_audio_get_fragment =
    gggl_op_sym (op, "oxide_audio_get_fragment()");

  if (p->oxide_audio_instance && p->oxide_audio_query)
    {
      p->oxide_audio_query (p->oxide_audio_instance,
                            &p->sample_rate,
                            &p->bits,
                            &p->channels,
                            &p->fragment_samples, &p->fragment_size);

      /* FIXME: for now, the buffer is set to a size double that of a oxide
       * provided fragment,. should be enough no matter how things are handled,
       * but it should also be more than needed,. find out exact amount needed later
       */

      if (!p->buffer)
        {
          int size =
            (p->sample_rate / p->fps) * p->channels * (p->bits / 8) * 2;
          buffer_open (op, size);
        }

      if (!p->fragment)
        p->fragment = gggl_op_calloc (op, 1, p->fragment_size);
    }
#endif
}
示例#3
0
int su_load(su_state *s, su_reader reader, void *data) {
	prototype_t *prot = su_allocate(s, NULL, sizeof(prototype_t));
	reader_buffer_t *buffer = buffer_open(s, reader, data);

	if (verify_header(s, buffer)) {
		buffer_close(s, buffer);
		return -1;
	}

	if (read_prototype(s, buffer, prot)) {
		buffer_close(s, buffer);
		return -1;
	}

	buffer_close(s, buffer);
	gc_insert_object(s, &prot->gc, PROTOTYPE);
	lambda(s, prot, -1);
	return 0;
}
示例#4
0
static void save_button_clicked(GtkButton *btn, gpointer data)
{
	if (dev_opened) {
		g_source_remove(fill_buffer_function);
		buffer_close();
		dev_opened = false;
	}

	if (gtk_toggle_button_get_active((GtkToggleButton *)radio_single_val)){
		iio_save_widgets(tx_widgets, num_tx);
		iio_save_widgets(rx_widgets, num_rx);
		rx_update_device_sampling_freq("ad7303",
			USE_INTERN_SAMPLING_FREQ);
	} else if (gtk_toggle_button_get_active((GtkToggleButton *)radio_waveform)){
		generateWavePeriod();
		dev_opened = !buffer_open(buffer_size);
		startWaveGeneration();
	}
}