Ejemplo n.º 1
0
OBJECT * make_class_module( LIST * xname, LIST * bases, FRAME * frame )
{
    OBJECT     * name = class_module_name( list_front( xname ) );
    OBJECT   * * pp;
    module_t   * class_module = 0;
    module_t   * outer_module = frame->module;
    int found;
    LISTITER iter, end;

    if ( !classes )
        classes = hashinit( sizeof( OBJECT * ), "classes" );

    pp = (OBJECT * *)hash_insert( classes, list_front( xname ), &found );
    if ( !found )
    {
        *pp = object_copy( list_front( xname ) );
    }
    else
    {
        printf( "Class %s already defined\n", object_str( list_front( xname ) ) );
        abort();
    }
    check_defined( bases );

    class_module = bindmodule( name );

    var_set( class_module, constant_name, xname, VAR_SET );
    var_set( class_module, constant_bases, bases, VAR_SET );

    iter = list_begin( bases ), end = list_end( bases );
    for ( ; iter != end; iter = list_next( iter ) )
        import_base_rules( class_module, list_item( iter ) );

    return name;
}
Ejemplo n.º 2
0
void filecache_disable(TARGET *t)
{
	BUFFER buff;
	LIST *filecache;
	pushsettings( t->settings );
	filecache = var_get( "FILECACHE" );
	if ( !filecache ) {
		popsettings( t->settings );
		return;
	}

	buffer_init(&buff);
	buffer_addstring(&buff, filecache->string, strlen(filecache->string));
	buffer_addstring(&buff, ".USE", 4);
	buffer_addchar(&buff, 0);
	var_set(buffer_ptr(&buff), list_new(L0, "0", 0), VAR_SET);
	buffer_free(&buff);

	buffer_init(&buff);
	buffer_addstring(&buff, filecache->string, strlen(filecache->string));
	buffer_addstring(&buff, ".GENERATE", 9);
	buffer_addchar(&buff, 0);
	var_set(buffer_ptr(&buff), list_new(L0, "0", 0), VAR_SET);
	buffer_free(&buff);
}
Ejemplo n.º 3
0
void filecache_disable(TARGET *t)
{
	BUFFER buff;
	LIST *filecache;
	char const* filecacheStr;
	pushsettings( t->settings );
	filecache = var_get( "FILECACHE" );
	if ( !list_first(filecache) ) {
		popsettings( t->settings );
		return;
	}

	filecacheStr = list_value(list_first(filecache));

	buffer_init(&buff);
	buffer_addstring(&buff, filecacheStr, strlen(filecacheStr));
	buffer_addstring(&buff, ".USE", 4);
	buffer_addchar(&buff, 0);
	var_set(buffer_ptr(&buff), list_append(L0, "0", 0), VAR_SET);
	buffer_free(&buff);

	buffer_init(&buff);
	buffer_addstring(&buff, filecacheStr, strlen(filecacheStr));
	buffer_addstring(&buff, ".GENERATE", 9);
	buffer_addchar(&buff, 0);
	var_set(buffer_ptr(&buff), list_append(L0, "0", 0), VAR_SET);
	buffer_free(&buff);
}
Ejemplo n.º 4
0
void var_expand_unit_test()
{
    LOL lol[1];
    LIST* l, *l2;
    LIST *expected = list_new( list_new( L0, newstr( "axb" ) ), newstr( "ayb" ) );
    LIST *e2;
    char axyb[] = "a$(xy)b";
    char azb[] = "a$($(z))b";
    
    lol_init(lol);
    var_set("xy", list_new( list_new( L0, newstr( "x" ) ), newstr( "y" ) ), VAR_SET );
    var_set("z", list_new( L0, newstr( "xy" ) ), VAR_SET );
    
    l = var_expand( 0, axyb, axyb + sizeof(axyb) - 1, lol, 0 );
    for ( l2 = l, e2 = expected; l2 && e2; l2 = list_next(l2), e2 = list_next(e2) )
        assert( !strcmp( e2->string, l2->string ) );
    list_free(l);
    
    l = var_expand( 0, azb, azb + sizeof(azb) - 1, lol, 0 );
    for ( l2 = l, e2 = expected; l2 && e2; l2 = list_next(l2), e2 = list_next(e2) )
        assert( !strcmp( e2->string, l2->string ) );
    list_free(l);

    list_free(expected);
    
    lol_free(lol);
}
Ejemplo n.º 5
0
int LS_jam_setvar(ls_lua_State *L)
{
    int numParams = ls_lua_gettop(L);
    if (numParams < 2  ||  numParams > 3)
	return 0;

    if (!ls_lua_isstring(L, 1))
	return 0;

    if (numParams == 2)
    {
	var_set(ls_lua_tostring(L, 1), luahelper_addtolist(L, L0, 2), VAR_SET);
    }
    else
    {
	TARGET *t;

	if (!ls_lua_isstring(L, 2))
	    return 0;

	t = bindtarget(ls_lua_tostring(L, 1));
	pushsettings(t->settings);
	var_set(ls_lua_tostring(L, 2), luahelper_addtolist(L, L0, 3), VAR_SET);
	popsettings(t->settings);
    }

    return 0;
}
Ejemplo n.º 6
0
STATIC void
cmd_esw_dma_set_count_size(uint32 count, uint32 size)
{

    var_unset(CMD_ESW_DMA_BYTES,  TRUE, FALSE, FALSE);
    var_unset(CMD_ESW_DMA_SHORTS, TRUE, FALSE, FALSE);
    var_unset(CMD_ESW_DMA_WORDS,  TRUE, FALSE, FALSE);

    switch (size) {
    case 1:
        var_set(CMD_ESW_DMA_SIZE, "b", TRUE, FALSE);
        var_set_integer(CMD_ESW_DMA_BYTES, count, TRUE, FALSE);
        break;
    case 2:
        var_set(CMD_ESW_DMA_SIZE, "h", TRUE, FALSE);
        var_set_integer(CMD_ESW_DMA_SHORTS, count, TRUE, FALSE);
        break;
    case 4:
        var_set(CMD_ESW_DMA_SIZE, "w", TRUE, FALSE);
        var_set_integer(CMD_ESW_DMA_WORDS, count, TRUE, FALSE);
        break;
    default:
        var_set(CMD_ESW_DMA_SIZE, "?", TRUE, FALSE);
        break;
    }

}
Ejemplo n.º 7
0
int
cmd_setattr(int argc,
         char **argv)
{
  int ret;
  char opt;
  char *path = NULL;
  dpl_dict_t *metadata = NULL;

  var_set("status", "1", VAR_CMD_SET, NULL);

  optind = 0;

  while ((opt = getopt(argc, argv, usage_getoptstr(setattr_usage))) != -1)
    switch (opt)
      {
      case 'm':
        metadata = dpl_parse_metadata(optarg);
        if (NULL == metadata)
          {
            fprintf(stderr, "error parsing metadata\n");
            return SHELL_CONT;
          }
        break ;
      case '?':
      default:
        usage_help(&setattr_cmd);
      return SHELL_CONT;
      }
  argc -= optind;
  argv += optind;

  if (1 != argc)
    {
      usage_help(&setattr_cmd);
      return SHELL_CONT;
    }

  path = argv[0];

  ret = dpl_setattr(ctx, path, metadata);
  if (DPL_SUCCESS != ret)
    {
      fprintf(stderr, "status: %s (%d)\n", dpl_status_str(ret), ret);
      goto end;
    }

  var_set("status", "0", VAR_CMD_SET, NULL);

 end:

  if (NULL != metadata)
    dpl_dict_free(metadata);

  return SHELL_CONT;
}
Ejemplo n.º 8
0
static gboolean c_connect_set_hubaddr(char *addr) {
  // Validate and parse
  GRegex *reg = g_regex_new(
    //   1 - proto                2 - host             3 - port                       4 - kp
    "^(?:(dchub|nmdcs?|adcs?)://)?([^ :/<>\\(\\)]+)(?::([0-9]+))?(?:/|/\\?kp=SHA256\\/([a-zA-Z2-7]{52}))?$",
    0, 0, NULL);
  g_assert(reg);
  GMatchInfo *nfo;
  if(!g_regex_match(reg, addr, 0, &nfo)) {
    ui_m(NULL, 0, "Invalid URL format."); // not very specific
    g_regex_unref(reg);
    return FALSE;
  }
  g_regex_unref(reg);
  char *proto = g_match_info_fetch(nfo, 1);
  char *kp = g_match_info_fetch(nfo, 4);

  if(kp && *kp && strcmp(proto, "adcs") != 0 && strcmp(proto, "nmdcs") != 0) {
    ui_m(NULL, 0, "Keyprint is only valid for adcs:// or nmdcs:// URLs.");
    g_match_info_free(nfo);
    g_free(proto);
    g_free(kp);
    return FALSE;
  }

  char *host = g_match_info_fetch(nfo, 2);
  char *port = g_match_info_fetch(nfo, 3);
  g_match_info_free(nfo);

  struct ui_tab *tab = ui_tab_cur->data;
  char *old = g_strdup(var_get(tab->hub->id, VAR_hubaddr));

  // Reconstruct (without the kp) and save
  GString *a = g_string_new("");
  g_string_printf(a, "%s://%s:%s/", !proto || !*proto ? "dchub" : proto, host, !port || !*port ? "411" : port);
  var_set(tab->hub->id, VAR_hubaddr, a->str, NULL);

  // Save kp if specified, or throw it away if the URL changed
  if(kp && *kp)
    var_set(tab->hub->id, VAR_hubkp, kp, NULL);
  else if(old && strcmp(old, a->str) != 0)
    var_set(tab->hub->id, VAR_hubkp, NULL, NULL);

  g_string_free(a, TRUE);
  g_free(old);
  g_free(proto);
  g_free(kp);
  g_free(host);
  g_free(port);
  return TRUE;
}
Ejemplo n.º 9
0
STATIC void
cmd_esw_dma_set_dv(dv_t *dv, int dcb_size)
{
    char buf[20];

    sal_sprintf(buf, "%p", (void *)dv);
    var_set(CMD_ESW_DMA_DV, buf, TRUE, FALSE);

    sal_sprintf(buf, "%p", dv->dv_dcb);
    var_set(CMD_ESW_DMA_DCB, buf, TRUE, FALSE);

    var_set_integer(CMD_ESW_DMA_DCB_COUNT, dv->dv_cnt, TRUE, FALSE);
    var_set_integer(CMD_ESW_DMA_DCB_SIZE,  dcb_size,   TRUE, FALSE);
}
Ejemplo n.º 10
0
OBJECT * make_class_module( LIST * xname, LIST * bases, FRAME * frame )
{
    OBJECT     * name = class_module_name( list_front( xname ) );
    OBJECT   * * pp;
    module_t   * class_module = 0;
    module_t   * outer_module = frame->module;
    int found;

    if ( !classes )
        classes = hashinit( sizeof( OBJECT * ), "classes" );

    pp = (OBJECT * *)hash_insert( classes, list_front( xname ), &found );
    if ( !found )
    {
        *pp = object_copy( list_front( xname ) );
    }
    else
    {
        out_printf( "Class %s already defined\n", object_str( list_front( xname ) )
            );
        abort();
    }
    check_defined( bases );

    class_module = bindmodule( name );

    {
        /*
            Initialize variables that Boost.Build inserts in every object.
            We want to avoid creating the object's hash if it isn't needed.
         */
        int num = class_module->num_fixed_variables;
        module_add_fixed_var( class_module, constant_name, &num );
        module_add_fixed_var( class_module, constant_class, &num );
        module_set_fixed_variables( class_module, num );
    }

    var_set( class_module, constant_name, xname, VAR_SET );
    var_set( class_module, constant_bases, bases, VAR_SET );

    {
        LISTITER iter = list_begin( bases );
        LISTITER const end = list_end( bases );
        for ( ; iter != end; iter = list_next( iter ) )
            import_base_rules( class_module, list_item( iter ) );
    }

    return name;
}
Ejemplo n.º 11
0
void var_expand_unit_test()
{
    LOL lol[1];
    LIST* l, *l2;
    LIST *expected = list_new( list_new( L0, newstr( "axb" ) ), newstr( "ayb" ) );
    LIST *e2;
    char axyb[] = "a$(xy)b";
    char azb[] = "a$($(z))b";
    char path[] = "$(p:W)";
    
    # ifdef OS_CYGWIN
    char cygpath[256];
    cygwin_conv_to_posix_path("c:\\foo\\bar", cygpath);
    # else
    char cygpath[] = "/cygdrive/c/foo/bar";
    # endif
        
    lol_init(lol);
    var_set("xy", list_new( list_new( L0, newstr( "x" ) ), newstr( "y" ) ), VAR_SET );
    var_set("z", list_new( L0, newstr( "xy" ) ), VAR_SET );
    var_set("p", list_new( L0, newstr( cygpath ) ), VAR_SET );

    l = var_expand( 0, axyb, axyb + sizeof(axyb) - 1, lol, 0 );
    for ( l2 = l, e2 = expected; l2 && e2; l2 = list_next(l2), e2 = list_next(e2) )
        assert( !strcmp( e2->string, l2->string ) );
    assert(l2 == 0 && e2 == 0);
    list_free(l);
    
    l = var_expand( 0, azb, azb + sizeof(azb) - 1, lol, 0 );
    for ( l2 = l, e2 = expected; l2 && e2; l2 = list_next(l2), e2 = list_next(e2) )
        assert( !strcmp( e2->string, l2->string ) );
    assert(l2 == 0 && e2 == 0);
    list_free(l);

    l = var_expand( 0, path, path + sizeof(path) - 1, lol, 0 );
    assert(l != 0);
    assert(list_next(l) == 0);
    # ifdef OS_CYGWIN
    assert( !strcmp( l->string, "c:\\foo\\bar" ) );
    # else 
    assert( !strcmp( l->string, cygpath ) );
    # endif   
    list_free(l);

    list_free(expected);
    
    lol_free(lol);
}
Ejemplo n.º 12
0
LIST * compile_foreach( PARSE * parse, FRAME * frame )
{
    LIST     * nv = parse_evaluate( parse->left, frame );
    LIST     * l;
    SETTINGS * s = 0;

    if ( parse->num )
    {
        s = addsettings( s, VAR_SET, parse->string, L0 );
        pushsettings( s );
    }

    /* Call var_set to reset $(parse->string) for each val. */

    for ( l = nv; l; l = list_next( l ) )
    {
        LIST * val = list_new( L0, copystr( l->string ) );
        var_set( parse->string, val, VAR_SET );
        list_free( parse_evaluate( parse->right, frame ) );
    }

    if ( parse->num )
    {
        popsettings( s );
        freesettings( s );
    }

    list_free( nv );

    return L0;
}
Ejemplo n.º 13
0
LIST *
compile_set(
	PARSE	*parse,
	LOL	*args,
	int	*jmp )
{
	LIST	*nt = (*parse->left->func)( parse->left, args, jmp );
	LIST	*ns = (*parse->right->func)( parse->right, args, jmp );
	LISTITEM	*l;

	if( DEBUG_COMPILE )
	{
	    debug_compile( 0, "set" );
	    list_print( nt );
	    printf( " %s ", set_names[ parse->num ] );
	    list_print( ns );
	    printf( "\n" );
	}

	/* Call var_set to set variable */
	/* var_set keeps ns, so need to copy it */

	for( l = list_first(nt); l; l = list_next( l ) )
	    var_set( list_value(l), list_copy( L0, ns ), parse->num );

	list_free( nt );

	return ns;
}
Ejemplo n.º 14
0
/*
 * wiki_handle_get - show a wiki page in normal interactive form
 */
static void
wiki_handle_page()
{
    char* name;

    if (!user_is_authenticated()) {
	html_login_page();
	return;
    }

    if (var_get_val(server->variables, "logoff") != NULL) {
        user_logoff(server);
	html_login_page();
	return;
    }


    name = wiki_get_pagename("/Wiki/");
    if (is_wikiword(name)) {
	var_set(&server->variables, "page", name);
	out_write_page(name, MODE_NORMAL);
    } else {
        name = "StartPage";
        out_write_page(name, MODE_NORMAL);
        svr_set_response(server, "404");    /* not found */
    }
    wiki->calls++;
}
Ejemplo n.º 15
0
/* Use quite klugy approach: when we add order dependency from 'a' to 'b',
   just append 'b' to of value of variable 'a'.
*/
LIST *add_pair( PARSE *parse, FRAME *frame )
{
    LIST* arg = lol_get( frame->args, 0 );

    var_set(arg->string, list_copy(0, arg->next), VAR_APPEND);

    return L0;
}
Ejemplo n.º 16
0
STATIC void
cmd_esw_dma_set_paddr(uint32 paddr)
{
    char buf[20];

    sal_sprintf(buf, "0x%08x", paddr);
    var_set(CMD_ESW_DMA_PADDR, buf, TRUE, FALSE);
}
Ejemplo n.º 17
0
/* Use quite klugy approach: when we add order dependency from 'a' to 'b',
   just append 'b' to of value of variable 'a'.
*/
LIST *add_pair( FRAME *frame, int flags )
{
    LIST* arg = lol_get( frame->args, 0 );    

    var_set(arg->value, list_copy(0, arg->next), VAR_APPEND);

    return L0;
}
Ejemplo n.º 18
0
int	trap_Set(lua_State *s)
{
	const char *varname, *value;
	
	trap_args(s, "Set", "ss", &varname, &value);
	var_set(varname, value);
	return 0;	
}
Ejemplo n.º 19
0
STATIC void
cmd_esw_dma_set_laddr(void *laddr)
{
    char buf[20];

    sal_sprintf(buf, "%p", laddr);
    var_set(CMD_ESW_DMA_LADDR, buf, TRUE, FALSE);
}
Ejemplo n.º 20
0
LIST *property_set_create( PARSE *parse, FRAME *frame )
{
    LIST* properties = lol_get( frame->args, 0 );    
    LIST* sorted = 0;
    LIST* order_sensitive = 0;
    LIST* unique;
    LIST* tmp;
    LIST* val;
    string var[1];

#if 0
    /* Sort all properties which are not order sensitive */
    for(tmp = properties; tmp; tmp = tmp->next) {
        LIST* g = get_grist(tmp->string);
        LIST* att = call_rule("feature.attributes", frame, g, 0);
        if (list_in(att, "order-sensitive")) {
            order_sensitive = list_new( order_sensitive, tmp->string);
        } else {
            sorted = list_new( sorted, tmp->string);
        }
        list_free(att);
    }
    
    sorted = list_sort(sorted);
    sorted = list_append(sorted, order_sensitive);
    unique = list_unique(sorted);
#endif
    sorted = list_sort(properties);
    unique = list_unique(sorted);

    string_new(var);
    string_append(var, ".ps.");
    
    for(tmp = unique; tmp; tmp = tmp->next) {
        string_append(var, tmp->string);
        string_push_back(var, '-');
    }
    val = var_get(var->value);
    if (val == 0) 
    {          
        val = call_rule("new", frame, 
                        list_append(list_new(0, "property-set"), unique), 0);                
        
        var_set(newstr(var->value), list_copy(0, val), VAR_SET);
    }
    else
    {
        val = list_copy(0, val);
    }
    
    string_free(var);
    /* The 'unique' variable is freed in 'call_rule'. */
    list_free(sorted);

    return val;

}
Ejemplo n.º 21
0
Archivo: order.c Proyecto: Kirija/XPIR
/* Use quite klugy approach: when we add order dependency from 'a' to 'b', just
 * append 'b' to of value of variable 'a'.
 */
LIST * add_pair( FRAME * frame, int flags )
{
    LIST * arg = lol_get( frame->args, 0 );
    LISTITER iter = list_begin( arg );
    LISTITER const end = list_end( arg );
    var_set( frame->module, list_item( iter ), list_copy_range( arg, list_next(
        iter ), end ), VAR_APPEND );
    return L0;
}
Ejemplo n.º 22
0
OBJECT * make_class_module( LIST * xname, LIST * bases, FRAME * frame )
{
    OBJECT     * name = class_module_name( xname->value );
    OBJECT   * * pp = &xname->value;
    module_t   * class_module = 0;
    module_t   * outer_module = frame->module;
    OBJECT     * name_ = object_new( "__name__" );
    OBJECT     * bases_ = object_new( "__bases__" );

    if ( !classes )
        classes = hashinit( sizeof( OBJECT * ), "classes" );

    if ( hashenter( classes, (HASHDATA * *)&pp ) )
    {
        *pp = object_copy( xname->value );
    }
    else
    {
        printf( "Class %s already defined\n", object_str( xname->value ) );
        abort();
    }
    check_defined( bases );

    class_module = bindmodule( name );

    exit_module( outer_module );
    enter_module( class_module );

    var_set( name_, xname, VAR_SET );
    var_set( bases_, bases, VAR_SET );

    exit_module( class_module );
    enter_module( outer_module );

    for ( ; bases; bases = bases->next )
        import_base_rules( class_module, bases->value );

    object_free( bases_ );
    object_free( name_ );

    return name;
}
Ejemplo n.º 23
0
Archivo: storage.c Proyecto: barak/lush
void init_storage()
{
   assert(ST_FIRST==0);
   assert(sizeof(char)==sizeof(uchar));

#ifdef HAVE_MMAP                           
   size_t storage_size = offsetof(storage_t, mmap_addr);
#else
   size_t storage_size = sizeof(storage_t);
#endif

   mt_storage = MM_REGTYPE("storage", storage_size,
                           clear_storage, mark_storage, 0);

   /* set up storage_classes */
   abstract_storage_class = new_builtin_class(NIL);
   class_define("storage", abstract_storage_class);
   Generic_storage_class_init(ST_BOOL, Bool);
   Generic_storage_class_init(ST_AT, Atom);
   Generic_storage_class_init(ST_FLOAT, Float);
   Generic_storage_class_init(ST_DOUBLE, Double);
   Generic_storage_class_init(ST_INT, Int);
   Generic_storage_class_init(ST_SHORT, Short);
   Generic_storage_class_init(ST_CHAR, Char);
   Generic_storage_class_init(ST_UCHAR, UChar);
   Generic_storage_class_init(ST_GPTR, Gptr);
   Generic_storage_class_init(ST_MPTR, Mptr);

   at *p = var_define("storage-classes");
   at *l = NIL;
   for (storage_type_t st=ST_FIRST; st<ST_LAST; st++)
      l = new_cons(storage_class[st]->backptr, l);
   var_set(p, reverse(l));
   var_lock(p);

   dx_define("new-storage", xnew_storage);
   dx_define("new-storage/managed", xnew_storage_managed);
   dx_define("new-storage/foreign", xnew_storage_foreign);
#ifdef HAVE_MMAP
   dx_define("new-storage/mmap",xnew_storage_mmap);
#endif
   dx_define("storage-alloc",xstorage_alloc);
   dx_define("storage-realloc",xstorage_realloc);
   dx_define("storage-clear",xstorage_clear);
   dx_define("storagep",xstoragep);
   dx_define("storage-readonlyp",xstorage_readonlyp);
   dx_define("storage-set-readonly", xstorage_set_readonly);
   dx_define("storage-load",xstorage_load);
   dx_define("storage-save",xstorage_save);
   dx_define("storage-nelems",xstorage_nelems);
   dx_define("storage-nbytes",xstorage_nbytes);
}
Ejemplo n.º 24
0
int
mark_as_automatic_installed(const char *pkg, int value)
{
	char *filename;
	int retval;

	assert(pkg[0] != '/');

	filename = pkgdb_pkg_file(pkg, INSTALLED_INFO_FNAME);

	retval = var_set(filename, AUTOMATIC_VARNAME, value ? "yes" : NULL);

	free(filename);

	return retval;
}
Ejemplo n.º 25
0
Archivo: main.c Proyecto: petabi/pkgsrc
static int
set_installed_info_var(const char *name, void *cookie)
{
    struct set_installed_info_arg *arg = cookie;
    char *filename;
    int retval;

    filename = pkgdb_pkg_file(name, INSTALLED_INFO_FNAME);

    retval = var_set(filename, arg->variable, arg->value);

    free(filename);
    arg->got_match = 1;

    return retval;
}
Ejemplo n.º 26
0
LIST * property_set_create( FRAME * frame, int flags )
{
    LIST * properties = lol_get( frame->args, 0 );
    LIST * sorted = list_sort( properties );
    LIST * unique = list_unique( sorted );
    struct ps_map_entry * pos = ps_map_insert( &all_property_sets, unique );
    list_free( sorted );
    if ( pos->value )
    {
        list_free( unique );
        return list_new( object_copy( pos->value ) );
    }
    else
    {
        OBJECT * rulename = object_new( "new" );
        OBJECT * varname = object_new( "self.raw" );
        LIST * val = call_rule( rulename, frame,
            list_new( object_new( "property-set" ) ), 0 );
        LISTITER iter, end;
        object_free( rulename );
        pos->value = list_front( val );
        var_set( bindmodule( pos->value ), varname, unique, VAR_SET );
        object_free( varname );

        for ( iter = list_begin( unique ), end = list_end( unique ); iter != end; ++iter )
        {
            const char * str = object_str( list_item( iter ) );
            if ( str[ 0 ] != '<' || ! strchr( str, '>' ) )
            {
                string message[ 1 ];
                string_new( message );
                string_append( message, "Invalid property: '" );
                string_append( message, str );
                string_append( message, "'" );
                rulename = object_new( "errors.error" );
                call_rule( rulename, frame,
                    list_new( object_new( message->value ) ), 0 );
                /* unreachable */
                string_free( message );
                object_free( rulename );
            }
        }

        return val;
    }
}
Ejemplo n.º 27
0
static void c_accept(char *args) {
  struct ui_tab *tab = ui_tab_cur->data;
  if(args[0])
    ui_m(NULL, 0, "This command does not accept any arguments.");
  else if(tab->type != UIT_HUB)
    ui_m(NULL, 0, "This command can only be used on hub tabs.");
#if TLS_SUPPORT
  else if(!tab->hub->kp)
    ui_m(NULL, 0, "Nothing to accept.");
  else {
    char enc[53] = {};
    base32_encode_dat(tab->hub->kp, enc, 32);
    var_set(tab->hub->id, VAR_hubkp, enc, NULL);
    g_slice_free1(32, tab->hub->kp);
    tab->hub->kp = NULL;
    hub_connect(tab->hub);
  }
#else
  else
Ejemplo n.º 28
0
LIST *
compile_foreach(
	PARSE	*p,
	LOL	*args,
	int	*jmp )
{
	LIST	*nv = (*p->left->func)( p->left, args, jmp );
	LIST	*result = 0;
	LISTITEM *l;

	/* TODO: Efficiency: nv could be split apart and reused during the traversal */

	/* for each value for var */

	for( l = list_first(nv); l && *jmp == JMP_NONE; l = list_next( l ) )
	{
	    /* Reset $(p->string) for each val. */

	    var_set( p->string, list_append( L0, list_value(l), 1 ), VAR_SET );

	    /* Keep only last result. */

	    list_free( result );
	    result = (*p->right->func)( p->right, args, jmp );

	    /* continue loop? */

	    if( *jmp == JMP_CONTINUE )
		*jmp = JMP_NONE;
	}

	/* Here by break/continue? */

	if( *jmp == JMP_BREAK || *jmp == JMP_CONTINUE )
	    *jmp = JMP_NONE;

	list_free( nv );

	/* Returns result of last loop */

	return result;
}
Ejemplo n.º 29
0
int
p_assign(const char *name, struct value *v, int flag)
{
	(void) s_gettok();

	if (p_expr(v, flag) < 0) {
		p_synerror();
		return -1;
	}
	switch (v->v_type) {
	case V_STR:
	case V_NUM:
		if (name && flag && var_set(name, v) == 0) {
			p_memerror();
			val_free(*v);
			return -1;
		}
		break;
	}
	return 0;
}
Ejemplo n.º 30
0
LIST *
compile_foreach(
	PARSE	*p,
	LOL	*args,
	int	*jmp )
{
	LIST	*nv = (*p->left->func)( p->left, args, jmp );
	LIST	*result = 0;
	LIST	*l;

	/* for each value for var */

	for( l = nv; l && *jmp == JMP_NONE; l = list_next( l ) )
	{
	    /* Reset $(p->string) for each val. */

	    var_set( p->string, list_new( L0, l->string, 1 ), VAR_SET );

	    /* Keep only last result. */

	    list_free( result );
	    result = (*p->right->func)( p->right, args, jmp );

	    /* continue loop? */

	    if( *jmp == JMP_CONTINUE )
		*jmp = JMP_NONE;
	}

	/* Here by break/continue? */

	if( *jmp == JMP_BREAK || *jmp == JMP_CONTINUE )
	    *jmp = JMP_NONE;

	list_free( nv );

	/* Returns result of last loop */

	return result;
}