00001 00009 #include <stdio.h> 00010 #include <string.h> 00011 #include <stdarg.h> 00012 #include "vapi.h" 00013 #include "vapiAux.h" 00014 #include "vapiMacroList.h" 00015 #include "vapiMacro.h" 00016 #include "vapiLists.h" 00017 00021 vGroupList * 00022 vapiGroupListNew () 00023 { 00024 return (vGroupList *) v_list_new (); 00025 } 00026 00031 void 00032 vapiGroupListAddItem (vGroupList * GroupList, const char *GroupName) 00033 { 00034 vGroupListItem *Item; 00035 if (vapiGroupListSelectGroup (GroupList, GroupName) != -1) 00036 { 00037 return; 00038 } 00039 Item = malloc (sizeof (vGroupListItem)); 00040 Item->GroupName = vapiReturnStringPointer (GroupName); 00041 00042 v_list_append ((vList *) GroupList, Item); 00043 } 00044 00045 00049 int 00050 vapiGroupListCountElements (vGroupList * GroupList) 00051 { 00052 00053 return v_list_count_elements ((vList *) GroupList); 00054 } 00055 00056 /* 00057 * Seleccionar o elemnto nº X da Macro 00058 */ 00059 00060 char * 00061 vapiGroupListSelectItem (vGroupList * GroupList, int Item) 00062 { 00063 vGroupListItem *item; 00064 item = v_list_get (GroupList, Item); 00065 return (item->GroupName); 00066 } 00067 00068 00069 00070 /* 00071 * Seleccionar o grupo com o nome. 00072 */ 00073 00074 int 00075 vapiGroupListSelectGroup (vGroupList * GroupList, const char *Group) 00076 { 00077 vGroupListItem *Item; 00078 int ListSize, i; 00079 00080 ListSize = vapiGroupListCountElements (GroupList); 00081 00082 for (i = 0; i < ListSize; i++) 00083 { 00084 Item = (vGroupListItem *) v_list_get ((vList *) GroupList, i); 00085 if (!strcmp (Item->GroupName, Group)) 00086 { 00087 return i; 00088 00089 } 00090 } 00091 00092 return -1; 00093 }