コード例 #1
0
ファイル: check_type.c プロジェクト: spk121/guile-curl
int test_can_convert_to_slist__empty_list (void)
{
  SCM str_list = scm_list_n(SCM_UNDEFINED);
  int ret = _scm_can_convert_to_slist (str_list);
  printf("test that _scm_can_convert_to_slist returns 1 when passed an empty list: %d\n", ret == 1);
  return ret == 1;
}
コード例 #2
0
ファイル: check_type.c プロジェクト: spk121/guile-curl
int test_scm_convert_to_slist__empty_list (void)
{
  SCM str_list = scm_list_n(SCM_UNDEFINED);
  struct curl_slist *ret = _scm_convert_to_slist (str_list);
  printf("test that _scm_convert_to_slist returns NULL when passed an empty list: %d\n", ret == NULL);
  return ret == NULL;
}
コード例 #3
0
ファイル: check_type.c プロジェクト: spk121/guile-curl
void test_free_handle_empty_slist_option (SCM option)
{
  SCM handle = cl_easy_init();
  SCM str_list = scm_list_n(SCM_UNDEFINED);
  SCM ret = cl_easy_setopt(handle, scm_variable_ref(option), str_list, SCM_BOOL_F);
  gc_free_handle(handle);
}
コード例 #4
0
ファイル: scripting.c プロジェクト: pimp-my-code/sxiv
bool call_guile_keypress(char key, bool ctrl, bool mod1) {
  return scm_to_bool (scm_eval (scm_list_n (scm_from_locale_symbol ("on-key-press"),
                                            scm_from_char(key),
                                            scm_from_bool(ctrl),
                                            scm_from_bool(mod1),
                                            SCM_UNDEFINED
                                            ), scm_interaction_environment()));
}
コード例 #5
0
ファイル: scripting.c プロジェクト: pimp-my-code/sxiv
bool call_guile_buttonpress(unsigned int button, bool ctrl, int x, int y) {
  return scm_to_bool (scm_eval (scm_list_n (scm_from_locale_symbol ("on-button-press"),
                                            scm_from_int(button),
                                            scm_from_bool(ctrl),
                                            scm_from_int(x),
                                            scm_from_int(y),
                                            SCM_UNDEFINED
                                            ), scm_interaction_environment()));
}
コード例 #6
0
ファイル: s_netlist.c プロジェクト: gareth8118/geda-gaf
static SCM
scm_from_netlist (NETLIST *netlist)
{
  return scm_list_n (netlist->component_uref ? scm_from_utf8_string (netlist->component_uref) : SCM_BOOL_F,
                     netlist->hierarchy_tag ? scm_from_utf8_string (netlist->hierarchy_tag) : SCM_BOOL_F,
                     scm_from_bool (netlist->composite_component),
                     netlist->object_ptr ? edascm_from_object (netlist->object_ptr) : SCM_BOOL_F,
                     scm_from_pin_list (netlist->cpins),
                     SCM_UNDEFINED);
}
コード例 #7
0
ファイル: s_cpinlist.c プロジェクト: gareth8118/geda-gaf
static SCM
scm_from_pin (CPINLIST *pin)
{
  return scm_list_n (pin->object_ptr ? edascm_from_object (pin->object_ptr) : SCM_BOOL_F,
                     pin->pin_number ? scm_from_utf8_string (pin->pin_number) : SCM_BOOL_F,
                     pin->net_name ? scm_from_utf8_string (pin->net_name) : SCM_BOOL_F,
                     pin->pin_label ? scm_from_utf8_string (pin->pin_label) : SCM_BOOL_F,
                     scm_from_net_list (pin->nets),
                     SCM_UNDEFINED);
}
コード例 #8
0
ファイル: weechat-guile.c プロジェクト: AlexTalker/weechat
SCM
weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
{
    SCM alist;

    alist = scm_list_n (SCM_UNDEFINED);

    weechat_hashtable_map_string (hashtable,
                                  &weechat_guile_hashtable_map_cb,
                                  &alist);

    return alist;
}
コード例 #9
0
ファイル: ffmpeg.c プロジェクト: wedesoft/aiscm
static SCM list_audio_frame_info(struct ffmpeg_t *self, AVFrame *frame)
{
  int channels = audio_codec_ctx(self)->channels;
  int64_t offsets[AV_NUM_DATA_POINTERS];
  offsets_from_pointers(frame->data, offsets, AV_NUM_DATA_POINTERS);
  int frame_size =
    av_samples_get_buffer_size(NULL, channels, frame->nb_samples, frame->format, 1);

  return scm_list_n(scm_from_int(frame->format),
                    scm_list_2(scm_from_int(frame->nb_samples), scm_from_int(channels)),
                    scm_from_int(self->audio_codec_ctx->sample_rate),
                    from_non_zero_array(offsets, AV_NUM_DATA_POINTERS, 1),
                    scm_from_pointer(*frame->data, NULL),
                    scm_from_int(frame_size),
                    SCM_UNDEFINED);
}
コード例 #10
0
ファイル: g_netlist.c プロジェクト: jgriessen/geda-gaf
/* 
   This function returns certain calling flags to the calling guile prog. 
   The calling flags are returned to Guile as a list of option/value pairs [e.g. 
   ((verbose_mode #t) (interactive_mode #f) . . . ) ]
   It is used primarily to enable refdes sorting during netlisting via 
   the -s flag.  Note that this prog is not very flexible -- the allowed 
   calling flags are hard coded into the function.  At some point this 
   should be fixed . . . 
   9.1.2003 -- SDB 
 
   8.2.2005 -- Carlos Nieves Onega
   Different modes are now included in the backend_params list, as well as
   the backend parameters given from the command line. Since the function 
   calling-flag? in scheme/gnetlist.scm returns false if the calling flag was
   not found, it's only necessary to include the flags being true.
*/
SCM g_get_calling_flags()
{
    SCM arglist = SCM_EOL;

    GSList *aux;
  
    aux = backend_params;
    while (aux != NULL) {
      arglist = scm_cons (scm_list_n (scm_makfrom0str (aux->data),
				      SCM_BOOL (TRUE),
				      SCM_UNDEFINED), 
			  arglist);
      aux = aux->next;
    }
    
    return (arglist);
}
コード例 #11
0
ファイル: callbacks.c プロジェクト: nikola-benes/freetalk
static void
ft_disconnect_function (LmConnection *conn,
                        LmDisconnectReason reason,
                        gpointer user_data)
{
        lm_connection_unref (state.conn);
        state.conn = NULL;
        ft_roster_flush ();
        // TODO: ft_file_flush ();

        scm_run_hook (ex_disconnect_hook, scm_list_n (scm_from_int (reason),
                                                      SCM_UNDEFINED));
        /* set conn_status after hook so that discon hook procedures can get
           the previous state from ft-get-conn-status. helps in deciding
           if an automatic reconnection logic (dont auto reconnect if previous
           state was not FT_AUTH, etc)
        */

        do_set_conn_status (FT_DEAD);

        return;
}
コード例 #12
0
ファイル: s_rename.c プロジェクト: eivindkv/geda-gaf
SCM g_get_renamed_nets(SCM scm_level)
{
    SCM pairlist = SCM_EOL;
    SCM outerlist = SCM_EOL;
    SET * temp_set;
    RENAME * temp_rename;
    char *level;

    level = scm_to_utf8_string (scm_level);

    for (temp_set = first_set; temp_set; temp_set = temp_set->next_set)
    {
        for (temp_rename = temp_set->first_rename; temp_rename; temp_rename = temp_rename->next)
        {
            pairlist = scm_list_n (scm_from_utf8_string (temp_rename->src),
                                   scm_from_utf8_string (temp_rename->dest),
                                   SCM_UNDEFINED);
            outerlist = scm_cons (pairlist, outerlist);
        }
    }

    free (level);
    return (outerlist);
}
コード例 #13
0
ファイル: ffmpeg.c プロジェクト: wedesoft/aiscm
static SCM list_video_frame_info(struct ffmpeg_t *self, AVFrame *frame)
{
  // note that the pointer offsets can be negative for FFmpeg frames because av_frame_get_buffer
  // allocates separate memory locations for each image plane.
  int64_t offsets[AV_NUM_DATA_POINTERS];
  offsets_from_pointers(frame->data, offsets, AV_NUM_DATA_POINTERS);

  int64_t linesize[AV_NUM_DATA_POINTERS];
  int_array_to_long(linesize, frame->linesize, AV_NUM_DATA_POINTERS);

#ifdef HAVE_IMAGE_BUFFER_SIZE
  int size = av_image_get_buffer_size(frame->format, frame->width, frame->height, 32);
#else
  int size = avpicture_get_size(frame->format, frame->width, frame->height);
#endif

  return scm_list_n(scm_from_int(frame->format),
                    scm_list_2(scm_from_int(frame->height), scm_from_int(frame->width)),
                    from_non_zero_array(offsets, AV_NUM_DATA_POINTERS, 1),
                    from_non_zero_array(linesize, AV_NUM_DATA_POINTERS, 1),
                    scm_from_pointer(*frame->data, NULL),
                    scm_from_int(size),
                    SCM_UNDEFINED);
}
コード例 #14
0
ファイル: g_netlist.c プロジェクト: jgriessen/geda-gaf
/*  (netname (uref pin) (uref pin) ... ) */
SCM g_get_nets(SCM scm_uref, SCM scm_pin)
{
    SCM outerlist = SCM_EOL;
    SCM pinslist = SCM_EOL;
    SCM pairlist = SCM_EOL;
    NETLIST *nl_current = NULL;
    CPINLIST *pl_current = NULL;
    NET *n_current;
    char *wanted_uref = NULL;
    char *wanted_pin = NULL;
    char *net_name = NULL;

    char *pin;
    char *uref;

    SCM_ASSERT(scm_is_string (scm_uref), scm_uref, SCM_ARG1, 
	       "gnetlist:get-nets");

    SCM_ASSERT(scm_is_string (scm_pin), scm_pin, SCM_ARG2, 
	       "gnetlist:get-nets");


    wanted_uref = SCM_STRING_CHARS (scm_uref);
    wanted_pin  = SCM_STRING_CHARS (scm_pin);

    nl_current = netlist_head;

    /* search for the first instance */
    /* through the entire list */
    while (nl_current != NULL) {

	if (nl_current->component_uref) {

	    if (strcmp(nl_current->component_uref, wanted_uref) == 0) {

		pl_current = nl_current->cpins;
		while (pl_current != NULL) {

		    if (pl_current->pin_number) {
			if (strcmp(pl_current->pin_number, wanted_pin) ==
			    0) {

			    n_current = pl_current->nets;

			    if (pl_current->net_name) {
				net_name = pl_current->net_name;
			    }

			    while (n_current != NULL) {

				if (n_current->connected_to) {

				    pairlist = SCM_EOL;
				    pin = (char *) g_malloc(sizeof(char) *
							  strlen
							  (n_current->
							   connected_to));
				    uref =
					(char *) g_malloc(sizeof(char) *
							strlen(n_current->
							       connected_to));

				    sscanf(n_current->connected_to,
					   "%s %s", uref, pin);

				    pairlist = scm_list_n (scm_makfrom0str (uref),
                                           scm_makfrom0str (pin),
                                           SCM_UNDEFINED);

				    pinslist = scm_cons (pairlist, pinslist);

				    g_free(uref);
				    g_free(pin);
				}
				n_current = n_current->next;
			    }
			}
		    }
		    pl_current = pl_current->next;
		}
	    }
	}
	nl_current = nl_current->next;
    }

    if (net_name != NULL) {
      outerlist = scm_cons (scm_makfrom0str (net_name), pinslist);
    } else {
      outerlist = scm_cons (scm_makfrom0str ("ERROR_INVALID_PIN"),
                            outerlist);
	fprintf(stderr, "Invalid wanted_pin passed to get-nets [%s]\n",
		wanted_pin);
    }

    return (outerlist);
}
コード例 #15
0
ファイル: g_netlist.c プロジェクト: jgriessen/geda-gaf
/* given a net name, return all connections */
SCM g_get_all_connections(SCM scm_netname)
{

    SCM list = SCM_EOL;
    SCM x = SCM_EOL;
    SCM is_member = SCM_EOL;
    SCM connlist = SCM_EOL;
    SCM pairlist = SCM_EOL;
    NETLIST *nl_current;
    CPINLIST *pl_current;
    NET *n_current;
    char *wanted_net_name;
    char *net_name;
    char *pin;
    char *uref;

    SCM_ASSERT(scm_is_string(scm_netname), scm_netname, SCM_ARG1, 
	       "gnetlist:get-all-connections");

    wanted_net_name = SCM_STRING_CHARS (scm_netname);

    if (wanted_net_name == NULL) {
	return list;
    }


    nl_current = netlist_head;

    /* walk through the list of components, and through the list
     * of individual pins on each, adding net names to the list
     * being careful to ignore duplicates, and unconnected pins 
     */
    while (nl_current != NULL) {
	pl_current = nl_current->cpins;
	while (pl_current != NULL) {
	    if (pl_current->net_name) {

		net_name = pl_current->net_name;
		/* filter off unconnected pins */
		if (strcmp(net_name, wanted_net_name) == 0) {
		    /* add the net name to the list */

#if DEBUG
		    printf("found net: `%s'\n", net_name);
#endif

		    n_current = pl_current->nets;
		    while (n_current != NULL) {

			if (n_current->connected_to) {

			    pairlist = SCM_EOL;
			    pin = (char *) g_malloc(sizeof(char) *
						  strlen(n_current->
							 connected_to));
			    uref =
				(char *) g_malloc(sizeof(char) *
						strlen(n_current->
						       connected_to));

			    sscanf(n_current->connected_to,
				   "%s %s", uref, pin);

			    pairlist = scm_list_n (scm_makfrom0str (uref),
                                       scm_makfrom0str (pin),
                                       SCM_UNDEFINED);

			    x = pairlist;
			    is_member = scm_member(x, connlist);

			    if (is_member == SCM_BOOL_F) {
				connlist = scm_cons (pairlist, connlist);
			    }

			    g_free(uref);
			    g_free(pin);
			}
			n_current = n_current->next;
		    }
		}
	    }
	    pl_current = pl_current->next;
	}
	nl_current = nl_current->next;
    }

    return connlist;
}
コード例 #16
0
ファイル: g_netlist.c プロジェクト: blueantst/geda-gaf
/*  (netname (uref pin) (uref pin) ... ) */
SCM g_get_nets(SCM scm_uref, SCM scm_pin)
{
  SCM outerlist = SCM_EOL;
  SCM pinslist = SCM_EOL;
  SCM pairlist = SCM_EOL;
  NETLIST *nl_current = NULL;
  CPINLIST *pl_current = NULL;
  NET *n_current;
  char *wanted_uref = NULL;
  char *wanted_pin = NULL;
  char *net_name = NULL;

  char *pin;
  char *uref;

  SCM_ASSERT(scm_is_string (scm_uref), scm_uref, SCM_ARG1, 
             "gnetlist:get-nets");

  SCM_ASSERT(scm_is_string (scm_pin), scm_pin, SCM_ARG2, 
             "gnetlist:get-nets");

  scm_dynwind_begin (0);

  wanted_uref = scm_to_utf8_string (scm_uref);
  scm_dynwind_free (wanted_uref);

  wanted_pin = scm_to_utf8_string (scm_pin);
  scm_dynwind_free (wanted_pin);

  nl_current = netlist_head;

  /* search for the first instance */
  /* through the entire list */
  for (nl_current = netlist_head;
       nl_current != NULL;
       nl_current = nl_current->next) {

    if (!nl_current->component_uref) continue;
    if (strcmp (nl_current->component_uref, wanted_uref) != 0) continue;

    for (pl_current = nl_current->cpins;
         pl_current != NULL;
         pl_current = pl_current->next) {

      if (!pl_current->pin_number) continue;
      if (strcmp(pl_current->pin_number, wanted_pin) != 0) continue;

      if (pl_current->net_name) {
        net_name = pl_current->net_name;
      }

      for (n_current = pl_current->nets;
           n_current != NULL;
           n_current = n_current->next) {

        if (!n_current->connected_to) continue;

        pairlist = SCM_EOL;
        pin = (char *) g_malloc(sizeof(char) *
                                strlen
                                (n_current->
                                 connected_to));
        uref =
          (char *) g_malloc(sizeof(char) *
                            strlen(n_current->
                                   connected_to));

        sscanf(n_current->connected_to,
               "%s %s", uref, pin);

        pairlist = scm_list_n (scm_from_utf8_string (uref),
                               scm_from_utf8_string (pin),
                               SCM_UNDEFINED);

        pinslist = scm_cons (pairlist, pinslist);

        g_free(uref);
        g_free(pin);
      }
    }
  }

  if (net_name != NULL) {
    outerlist = scm_cons (scm_from_utf8_string (net_name), pinslist);
  } else {
    outerlist = scm_cons (scm_from_utf8_string ("ERROR_INVALID_PIN"),
                          outerlist);
    fprintf(stderr, _("Invalid refdes ('%s') and pin ('%s') passed to get-nets\n"),
            wanted_uref, wanted_pin);
  }

  scm_dynwind_end ();

  return (outerlist);
}
コード例 #17
0
ファイル: callbacks.c プロジェクト: nikola-benes/freetalk
static LmHandlerResult
ft_msg_msg_handler (LmMessageHandler *handler, LmConnection *conn,
                    LmMessage *msg, gpointer user_data)
{
        LmMessageNode *root, *body, *x;
        const char *from, *msg_str, *type;
        char *ts = NULL;
        char *new_from = NULL;

        root = lm_message_get_node (msg);
        if (!root)
                goto out;

        body = lm_message_node_get_child (root, "body");
        if (!body)
                goto out;

        from = lm_message_node_get_attribute (msg->node, "from");
        if (!from)
                goto out;

        msg_str = lm_message_node_get_value (body);

        type = lm_message_node_get_attribute (msg->node, "type");
        if (type && g_ascii_strcasecmp (type, "chat") != 0) {
                PRINTF (_("[message of type '%s']"), type);
                goto out;
        }

        // Offline messages
        for (x = root->children; x != NULL; x = x->next) {
                if (!g_ascii_strcasecmp (x->name, "x")) {
                        const char *xmlns = lm_message_node_get_attribute (x,
                                                                           "xmlns");
                        if (xmlns &&
                            !g_ascii_strcasecmp (xmlns, "jabber:x:delay")) {
                                ts = parse_timestamp ((char *)lm_message_node_get_attribute (x, "stamp"));
                        }
                }
        }

        set_hook_return (0);
        {
                FtRosterItem *item = NULL;
                char *nickname;

                new_from = g_strdup (from);
                item = ft_roster_lookup (new_from);

                if (!item)
                        nickname = NULL;
                else
                        nickname = item->nickname;

                scm_run_hook (ex_message_receive_hook,
                              scm_list_n (ts ? scm_from_locale_string (ts) :
                                          scm_from_locale_string (""),
                                          scm_from_locale_string (new_from),
                                          nickname ?
                                          scm_from_locale_string (nickname) :
                                          scm_from_locale_string (""),
                                          scm_from_locale_string (msg_str),
                                          SCM_UNDEFINED));
        }

        if (get_hook_return () == 1)
                goto out;

        PRINTF ("%s: %s", new_from, msg_str);
out:
        if (ts)
                g_free (ts);

        if (new_from)
                g_free (new_from);

        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
コード例 #18
0
ファイル: weechat-guile.c プロジェクト: munkee/weechat
void *
weechat_guile_exec (struct t_plugin_script *script,
                    int ret_type, const char *function,
                    char *format, void **argv)
{
    struct t_plugin_script *old_guile_current_script;
    SCM argv_list, rc;
    void *argv2[17], *ret_value;
    int i, argc, *ret_int;

    old_guile_current_script = guile_current_script;
    scm_set_current_module ((SCM)(script->interpreter));
    guile_current_script = script;

    if (argv && argv[0])
    {
        argc = strlen (format);
        for (i = 0; i < argc; i++)
        {
            switch (format[i])
            {
                case 's': /* string */
                    argv2[i] = scm_from_locale_string ((char *)argv[i]);
                    break;
                case 'i': /* integer */
                    argv2[i] = scm_from_int (*((int *)argv[i]));
                    break;
                case 'h': /* hash */
                    argv2[i] = weechat_guile_hashtable_to_alist (argv[i]);
                    break;
            }
        }
        for (i = argc; i < 17; i++)
        {
            argv2[i] = SCM_UNDEFINED;
        }
        argv_list = scm_list_n (argv2[0], argv2[1],
                                argv2[2], argv2[3],
                                argv2[4], argv2[5],
                                argv2[6], argv2[7],
                                argv2[8], argv2[9],
                                argv2[10], argv2[11],
                                argv2[12], argv2[13],
                                argv2[14], argv2[15],
                                argv2[16]);
        rc = weechat_guile_exec_function (function, argv_list);
    }
    else
    {
        rc = weechat_guile_exec_function (function, NULL);
    }

    ret_value = NULL;

    if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (scm_is_string (rc)))
    {
        ret_value = scm_to_locale_string (rc);
    }
    else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (scm_is_integer (rc)))
    {
        ret_int = malloc (sizeof (*ret_int));
        if (ret_int)
            *ret_int = scm_to_int (rc);
        ret_value = ret_int;
    }
    else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
    {
        ret_value = weechat_guile_alist_to_hashtable (rc,
                                                      WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
    }
    else
    {
        weechat_printf (NULL,
                        weechat_gettext ("%s%s: function \"%s\" must return "
                                         "a valid value"),
                        weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
    }

    if (ret_value == NULL)
    {
        weechat_printf (NULL,
                        weechat_gettext ("%s%s: error in function \"%s\""),
                        weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
    }

    if (old_guile_current_script)
        scm_set_current_module ((SCM)(old_guile_current_script->interpreter));

    guile_current_script = old_guile_current_script;

    return ret_value;
}