Index: trunk/src_plugins/act_read/act_idpath.c =================================================================== --- trunk/src_plugins/act_read/act_idpath.c (revision 25824) +++ trunk/src_plugins/act_read/act_idpath.c (revision 25825) @@ -1,13 +1,84 @@ /* includeed from act_read.c */ static const char pcb_acts_IDPList[] = - "IDPList(new|free|print)\n" - "IDPList(get|print, idx)\n" - "IDPList(remove, idx)\n" - "IDPList(prepend|append, idpath)" + "IDPList(alloc)\n" + "IDPList(free|clear|print|dup, list)\n" + "IDPList(get|remove, list, idx)\n" + "IDPList(prepend|append, list, idpath)" ; static const char pcb_acth_IDPList[] = "Basic idpath list manipulation."; static fgw_error_t pcb_act_IDPList(fgw_arg_t *res, int argc, fgw_arg_t *argv) { + const char *cmd_; + pcb_idpath_list_t *list; + pcb_idpath_t *idp; + int cmd; + long idx; + + PCB_ACT_CONVARG(1, FGW_STR, IDPList, cmd_ = argv[1].val.str); + + cmd = act_read_keywords_sphash(cmd_); + if (cmd == act_read_keywords_alloc) { + list = calloc(sizeof(pcb_idpath_list_t), 1); + fgw_ptr_reg(&pcb_fgw, res, PCB_PTR_DOMAIN_IDPATH, FGW_PTR, list); + return 0; + } + + PCB_ACT_CONVARG(2, FGW_IDPATH_LIST, IDPList, list = fgw_idpath_list(&argv[2])); + if (!fgw_ptr_in_domain(&pcb_fgw, &argv[2], PCB_PTR_DOMAIN_IDPATH_LIST)) + return FGW_ERR_PTR_DOMAIN; + + switch(cmd) { + case act_read_keywords_clear: + pcb_idpath_list_clear(list); + PCB_ACT_IRES(0); + return 0; + + + case act_read_keywords_free: + fgw_ptr_unreg(&pcb_fgw, &argv[2], PCB_PTR_DOMAIN_IDPATH_LIST); + pcb_idpath_list_clear(list); + free(list); + PCB_ACT_IRES(0); + return 0; + + case act_read_keywords_append: + case act_read_keywords_prepend: + PCB_ACT_CONVARG(3, FGW_IDPATH, IDPList, idp = fgw_idpath(&argv[3])); + if (!fgw_ptr_in_domain(&pcb_fgw, &argv[3], PCB_PTR_DOMAIN_IDPATH)) + return FGW_ERR_PTR_DOMAIN; + if (cmd == act_read_keywords_append) + pcb_idpath_list_append(list, idp); + else + pcb_idpath_list_insert(list, idp); + PCB_ACT_IRES(0); + return 0; + + case act_read_keywords_remove: + PCB_ACT_CONVARG(3, FGW_LONG, IDPList, idx = argv[3].val.nat_long); + idp = pcb_idpath_list_nth(list, idx); + if (idp == NULL) { + PCB_ACT_IRES(-1); + return 0; + } + pcb_idpath_list_remove(idp); + PCB_ACT_IRES(0); + return 0; + + case act_read_keywords_get: + PCB_ACT_CONVARG(3, FGW_LONG, IDPList, idx = argv[3].val.nat_long); + idp = pcb_idpath_list_nth(list, idx); + if (idp == NULL) { + res->type = FGW_PTR; + res->val.ptr_struct = NULL; + return 0; + } + fgw_ptr_reg(&pcb_fgw, res, PCB_PTR_DOMAIN_IDPATH, FGW_PTR, idp); + return 0; + + case act_read_keywords_print: + break; + } + return -1; } Index: trunk/src_plugins/act_read/act_read.c =================================================================== --- trunk/src_plugins/act_read/act_read.c (revision 25824) +++ trunk/src_plugins/act_read/act_read.c (revision 25825) @@ -32,6 +32,7 @@ #include "actions.h" #include "plugins.h" #include "misc_util.h" +#include "idpath.h" #include "keywords_sphash.h" @@ -80,6 +81,7 @@ pcb_action_t act_read_action_list[] = { {"GetValue", pcb_act_GetValue, pcb_acth_GetValue, pcb_acts_GetValue}, + {"IDPList", pcb_act_IDPList, pcb_acth_IDPList, pcb_acts_IDPList} }; static const char *act_read_cookie = "act_read"; Index: trunk/src_plugins/act_read/keywords.sphash =================================================================== --- trunk/src_plugins/act_read/keywords.sphash (revision 25824) +++ trunk/src_plugins/act_read/keywords.sphash (revision 25825) @@ -1,5 +1,7 @@ alloc append +clear +dup free get prepend