static GError* _tgengraph_parseTransferVertex(TGenGraph* g, const gchar* idStr, igraph_integer_t vertexIndex) { TGEN_ASSERT(g); const gchar* typeStr = (g->knownAttributes&TGEN_VA_TYPE) ? VAS(g->graph, "type", vertexIndex) : NULL; const gchar* protocolStr = (g->knownAttributes&TGEN_VA_PROTOCOL) ? VAS(g->graph, "protocol", vertexIndex) : NULL; const gchar* sizeStr = (g->knownAttributes&TGEN_VA_SIZE) ? VAS(g->graph, "size", vertexIndex) : NULL; const gchar* peersStr = (g->knownAttributes&TGEN_VA_PEERS) ? VAS(g->graph, "peers", vertexIndex) : NULL; const gchar* timeoutStr = (g->knownAttributes&TGEN_VA_TIMEOUT) ? VAS(g->graph, "timeout", vertexIndex) : NULL; tgen_debug("found vertex %li (%s), type=%s protocol=%s size=%s peers=%s timeout=%s", (glong)vertexIndex, idStr, typeStr, protocolStr, sizeStr, peersStr, timeoutStr); GError* error = NULL; TGenAction* a = tgenaction_newTransferAction(typeStr, protocolStr, sizeStr, peersStr, timeoutStr, &error); if(a) { _tgengraph_storeAction(g, a, vertexIndex); if(!tgenaction_getPeers(a)) { g->transferMissingPeers = TRUE; } } return error; }
int main(int argc, char**argv) { if (argv[1]) file = argv[1]; PValue v = xml_parse_file(file,true); if (value_is_error(v)) { fprintf(stderr,"error reading xml: %s\n",(char*)v); return 1; } //char *s = json_tostring(v); // try this for kicks... char *s = xml_tostring(v,0); printf("%s\n",s); obj_unref_v(v, s); // the same notation used for building up JSON data works fine for XML docs v = VAS("root", VAS("item",VMS("name","age","type","int"),"10"), VAS("item",VMS("name","name","type","string"),"Bonzo") ); s = xml_tostring(v,0); printf("%s\n",s); char *s2 = json_tostring(v); printf("json %s\n",s2); obj_unref_v(v, s, s2); printf("kount %d\n",obj_kount()); return 0; }
void set_error_string( FeriteScript *script, FeriteObject *object, char* str ) { FeriteVariable *estr; estr = ferite_hash_get(script, object->variables->variables, "_errstr"); if( estr == NULL ) return; ferite_str_set( script, VAS(estr), str, 0, FE_CHARSET_DEFAULT ); }
BODY *create_imap_content_object(FeriteScript* script, FeriteVariable* fe_parent) { FeriteVariable *parts_list,*fe_child,*v; BODY *root,*new_body; PART *new_part,*last_part = NULL; int i=0; //Get array of child objects parts_list = ferite_hash_get( script, VAO(fe_parent)->variables->variables, "parts"); //This is true if the top level is not a multipart if( parts_list == NULL ) return( create_imap_content_leaf( script, fe_parent )); root = mail_newbody(); root->type=TYPEMULTIPART; v = ferite_hash_get( script, VAO(fe_parent)->variables->variables, "subtype"); RETURN_IF_NULL(v); if( VAS(v)->data ) root->subtype = cpystr( VAS(v)->data ); //Loop trough child array i=0; while( i < VAUA(parts_list)->size) { new_part = mail_newbody_part(); fe_child = ferite_uarray_get_index( script, VAUA(parts_list) , i ); RETURN_IF_NULL(fe_child); // Is it a multipart or a leaf? if( ferite_hash_get( script, VAO(fe_child)->variables->variables, "parts")) new_body = create_imap_content_object( script , fe_child ); else new_body = create_imap_content_leaf( script, fe_child ); RETURN_IF_NULL(new_body); new_part->body = *new_body; //Fixme, this sucks if( last_part == NULL ) root->nested.part = last_part = new_part; else last_part = last_part->next = new_part; i++; } return root; }
void dump_vertex_attribute_string(const char* name, const igraph_t* g) { long int i, n = igraph_vcount(g); printf("Vertex attribute '%s':", name); for (i = 0; i < n; i++) { printf(" %s", VAS(g, name, i)); } printf("\n"); }
static GError* _tgengraph_parseStartVertex(TGenGraph* g, const gchar* idStr, igraph_integer_t vertexIndex) { TGEN_ASSERT(g); const gchar* timeStr = (g->knownAttributes&TGEN_VA_TIME) ? VAS(g->graph, "time", vertexIndex) : NULL; const gchar* timeoutStr = (g->knownAttributes&TGEN_VA_TIMEOUT) ? VAS(g->graph, "timeout", vertexIndex) : NULL; const gchar* serverPortStr = (g->knownAttributes&TGEN_VA_SERVERPORT) ? VAS(g->graph, "serverport", vertexIndex) : NULL; const gchar* peersStr = (g->knownAttributes&TGEN_VA_PEERS) ? VAS(g->graph, "peers", vertexIndex) : NULL; const gchar* socksProxyStr = (g->knownAttributes&TGEN_VA_SOCKSPROXY) ? VAS(g->graph, "socksproxy", vertexIndex) : NULL; tgen_debug("validating action '%s' at vertex %li, time=%s timeout=%s serverport=%s socksproxy=%s peers=%s", idStr, (glong)vertexIndex, timeStr, timeoutStr, serverPortStr, socksProxyStr, peersStr); if(g->hasStartAction) { return g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "only one start vertex is allowed in the action graph"); } if(_tgengraph_hasSelfLoop(g, vertexIndex)) { return g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "start vertex must not contain a self-loop"); } GError* error = NULL; TGenAction* a = tgenaction_newStartAction(timeStr, timeoutStr, serverPortStr, peersStr, socksProxyStr, &error); if(a) { _tgengraph_storeAction(g, a, vertexIndex); g_assert(!g->hasStartAction); g->startActionVertexIndex = vertexIndex; g->hasStartAction = TRUE; if(tgenaction_getPeers(a)) { g->startHasPeers = TRUE; } } return error; }
/** * @function ferite_raise_script_error * @declaration void ferite_raise_script_error( FeriteScript *script, int err, char *fmt, ... ) * @brief Raise an exception within the ferite engine. * @param FeriteScript *script The running script * @param int err The error code * @param char *fmt The format of the error string * @description Use the same formating codes as printf with this function */ void ferite_raise_script_error( FeriteScript *script, int err, char *fmt, ... ) { FeriteNamespaceBucket *nsb = NULL; FeriteVariable *global_error_object = NULL, *new_error_object = NULL, *backtrace = NULL; FeriteVariable *error_object_str = NULL, *error_object_num = NULL, *error_object_backtrace = NULL; FeriteBuffer *error_buffer = NULL; char *msg; va_list ap; FE_ENTER_FUNCTION; va_start( ap, fmt ); error_buffer = ferite_buffer_new(script, 0); ferite_buffer_vprintf( script, error_buffer, fmt, &ap ); msg = ferite_buffer_get( script, script->error, NULL ); FUD(("ERROR RAISED: %s %d\n", msg, err )); nsb = ferite_namespace_element_exists( script, script->mainns, "err" ); FE_ASSERT( nsb && nsb->type == FENS_VAR ); global_error_object = nsb->data; script->error_state = FE_ERROR_THROWN; if( VAO(global_error_object) == NULL ) { nsb = ferite_namespace_element_exists( script, script->mainns, "Error" ); if( nsb == NULL ) { FE_LEAVE_FUNCTION( NOWT ); exit(1); } new_error_object = ferite_new_object( script, nsb->data, NULL ); VAO(global_error_object) = VAO(new_error_object); FINCREF(VAO(global_error_object)); ferite_variable_destroy( script, new_error_object ); } error_object_str = ferite_object_get_var( script, VAO(global_error_object), "str" ); ferite_str_set( script, VAS(error_object_str), msg, strlen(msg), FE_CHARSET_DEFAULT ); ffree( msg ); error_object_num = ferite_object_get_var( script, VAO(global_error_object), "num" ); VAI(error_object_num) = err; backtrace = ferite_generate_backtrace( script, FE_FALSE ); error_object_backtrace = ferite_object_get_var( script, VAO(global_error_object), "backtrace"); ferite_variable_fast_assign( script, error_object_backtrace, backtrace ); ferite_buffer_delete( script, error_buffer ); FE_LEAVE_FUNCTION( NOWT ); }
/* this use cgraph to read/write dot */ static char * vid2vname_unsafe(char *s, igraph_t *g, unsigned long id) { char *str = NULL; /* try to find a vertex name */ str = (char *)VAS(g,GGEN_VERTEX_NAME_ATTR,id); if(!str) { snprintf(s,GGEN_DEFAULT_NAME_SIZE,"%lu",id); return NULL; } else return str; }
int system_sync_to_FeTm( struct FeTm *Tm, struct tm *tm ) { #if !defined(USING_SOLARIS) && !defined(USING_CYGWIN) && !defined(USING_MINGW) char *zone = (char *)tm->tm_zone; #endif VAI(Tm->tm_sec) = tm->tm_sec; VAI(Tm->tm_min) = tm->tm_min; VAI(Tm->tm_hour) = tm->tm_hour; VAI(Tm->tm_mday) = tm->tm_mday; VAI(Tm->tm_mon) = tm->tm_mon + 1; VAI(Tm->tm_year) = tm->tm_year + 1900; VAI(Tm->tm_wday) = tm->tm_wday; VAI(Tm->tm_yday) = tm->tm_yday; VAI(Tm->tm_isdst) = tm->tm_isdst; #if !defined(USING_SOLARIS) && !defined(USING_CYGWIN) && !defined(USING_MINGW) VAI(Tm->tm_gmtoff) = tm->tm_gmtoff; ferite_str_destroy( FE_NoScript, VAS(Tm->tm_zone) ); VAS(Tm->tm_zone) = ferite_str_new( FE_NoScript, zone, 0, FE_CHARSET_DEFAULT ); #endif return 0; }
void builder_process_variable( FeriteScript *script, FeriteVariable *var, char *parent ) { FE_ENTER_FUNCTION; if( strcmp( parent, "'module-init" ) == 0 || strcmp( parent, "'module-deinit" ) == 0 || strcmp( parent, "'module-header" ) == 0 || strcmp( parent, "'module-register" ) == 0 || strcmp( parent, "'module-unregister" ) == 0 || strcmp( parent, "'module-flags" ) == 0 ) { FE_LEAVE_FUNCTION(NOWT); } ferite_stack_push( FE_NoScript, current_module->name_stack, parent ); if( opt.verbose ) printf( "%s - processing variable\n", builder_generate_current_name(FE_TRUE,FE_TRUE) ); fprintf( current_module->core, " %s( script, %s%s, ", (in_class == 1 ? "ferite_register_class_variable" : "ferite_register_ns_variable" ), builder_generate_current_name(FE_FALSE,FE_TRUE), (in_class == 1 ? "_class" : "_namespace") ); #define DO_STATIC ( in_class == 1 ? ( FE_VAR_IS_STATIC( var ) ? ", 1" : ", 0" ) : "" ) fprintf( current_module->core, "\"%s\", ", parent ); switch( F_VAR_TYPE(var) ) { case F_VAR_LONG: fprintf( current_module->core, "fe_new_lng( \"%s\", %ld )%s );", parent, VAI(var), DO_STATIC ); break; case F_VAR_DOUBLE: fprintf( current_module->core, "fe_new_lng( \"%s\", %f )%s );", parent, VAF(var), DO_STATIC ); break; case F_VAR_STR: fprintf( current_module->core, "fe_new_str( \"%s\", \"%s\" )%s );", parent, VAS(var)->data, DO_STATIC ); break; case F_VAR_OBJ: fprintf( current_module->core, "fe_new_obj( \"%s\" )%s );", parent, DO_STATIC ); break; case F_VAR_UARRAY: fprintf( current_module->core, "fe_new_array( \"%s\", 0 )%s );", parent, DO_STATIC ); break; case F_VAR_VOID: fprintf( current_module->core, "fe_new_void( \"%s\" )%s );", parent, DO_STATIC ); break; } fprintf( current_module->core, "\n" ); ferite_stack_pop( FE_NoScript, current_module->name_stack ); FE_LEAVE_FUNCTION( NOWT ); }
static GError* _tgengraph_parseEndVertex(TGenGraph* g, const gchar* idStr, igraph_integer_t vertexIndex) { TGEN_ASSERT(g); /* the following termination conditions are optional */ const gchar* timeStr = (g->knownAttributes&TGEN_VA_TIME) ? VAS(g->graph, "time", vertexIndex) : NULL; const gchar* countStr = (g->knownAttributes&TGEN_VA_COUNT) ? VAS(g->graph, "count", vertexIndex) : NULL; const gchar* sizeStr = (g->knownAttributes&TGEN_VA_SIZE) ? VAS(g->graph, "size", vertexIndex) : NULL; tgen_debug("found vertex %li (%s), time=%s count=%s size=%s", (glong)vertexIndex, idStr, timeStr, countStr, sizeStr); GError* error = NULL; TGenAction* a = tgenaction_newEndAction(timeStr, countStr, sizeStr, &error); if(a) { _tgengraph_storeAction(g, a, vertexIndex); } return error; }
int system_sync_to_tm( struct FeTm *Tm, struct tm *tm ) { memset( tm, '\0', sizeof(struct tm) ); tm->tm_sec = VAI(Tm->tm_sec); tm->tm_min = VAI(Tm->tm_min); tm->tm_hour = VAI(Tm->tm_hour); tm->tm_mday = VAI(Tm->tm_mday); tm->tm_mon = VAI(Tm->tm_mon) - 1; tm->tm_year = VAI(Tm->tm_year) - 1900; tm->tm_wday = VAI(Tm->tm_wday); tm->tm_yday = VAI(Tm->tm_yday); tm->tm_isdst = VAI(Tm->tm_isdst); #if !defined(USING_SOLARIS) && !defined(USING_CYGWIN) && !defined(USING_MINGW) tm->tm_zone = VAS(Tm->tm_zone)->data; tm->tm_gmtoff = VAI(Tm->tm_gmtoff); #endif return 0; }
static GError* _tgengraph_parsePauseVertex(TGenGraph* g, const gchar* idStr, igraph_integer_t vertexIndex) { TGEN_ASSERT(g); const gchar* timeStr = (g->knownAttributes&TGEN_VA_TIME) ? VAS(g->graph, "time", vertexIndex) : NULL; tgen_debug("found vertex %li (%s), time=%s", (glong)vertexIndex, idStr, timeStr); GError* error = NULL; TGenAction* a = tgenaction_newPauseAction(timeStr, &error); if(a) { _tgengraph_storeAction(g, a, vertexIndex); } return error; }
/** * @function ferite_set_error * @declaration void ferite_set_error( FeriteScript *script, int num, char *fmt, ... ) * @brief Same as ferite_error except this wont raise an exception at runtime */ void ferite_set_error( FeriteScript *script, int num, char *fmt, ... ) { FeriteNamespaceBucket *nsb = NULL; FeriteVariable *global_error_object = NULL, *new_error_object = NULL; FeriteVariable *errstr = NULL, *erno = NULL; va_list ap; char *buf = NULL; FE_ENTER_FUNCTION; if( !script->is_being_deleted && (script->parent == NULL || !script->parent->is_being_deleted) ) { buf = fmalloc( 4096 ); va_start( ap, fmt ); vsprintf( buf, fmt, ap ); nsb = ferite_namespace_element_exists( script, script->mainns, "err" ); FE_ASSERT( nsb && nsb->type == FENS_VAR ); global_error_object = nsb->data; if( VAO(global_error_object) == NULL ) { nsb = ferite_namespace_element_exists( script, script->mainns, "Error" ); new_error_object = ferite_new_object( script, nsb->data, NULL ); VAO(global_error_object) = VAO(new_error_object); FINCREF(VAO(global_error_object)); ferite_variable_destroy( script, new_error_object ); } errstr = ferite_object_get_var( script, VAO(global_error_object), "str" ); ferite_str_set( script, VAS(errstr), buf, strlen(buf), FE_CHARSET_DEFAULT ); erno = ferite_object_get_var( script, VAO(global_error_object), "num" ); VAI(erno) = num; ffree( buf ); va_end( ap ); } FE_LEAVE_FUNCTION( NOWT ); }
ADDRESS *create_imap_address( FeriteScript* script, FeriteVariable* fe_object){ ADDRESS *root=NULL, *newaddr; FeriteVariable *fe_list,*v,*fe_addr; int i; RETURN_IF_NULL(fe_object && VAO(fe_object)); fe_list = ferite_hash_get( script, VAO(fe_object)->variables->variables, "list" ); RETURN_IF_NULL(fe_list); for( i=0; i< VAUA(fe_list)->size; i++ ){ fe_addr = ferite_uarray_get_index( script, VAUA(fe_list) , i ); RETURN_IF_NULL(fe_addr); if(root == NULL) root = newaddr = mail_newaddr(); else newaddr = newaddr->next = mail_newaddr(); v = ferite_hash_get( script, VAO(fe_addr)->variables->variables , "mailbox"); RETURN_IF_NULL(v); if(VAS(v)->data) newaddr->mailbox = cpystr(VAS(v)->data); v = ferite_hash_get( script, VAO(fe_addr)->variables->variables , "host"); RETURN_IF_NULL(v); if(VAS(v)->data) newaddr->host = cpystr(VAS(v)->data); v = ferite_hash_get( script, VAO(fe_addr)->variables->variables , "name"); RETURN_IF_NULL(v); if(VAS(v)->data) newaddr->personal = cpystr(VAS(v)->data); } return root; }
ENVELOPE *create_imap_envelope( FeriteScript *script, FeriteVariable *header ){ ENVELOPE *env = mail_newenvelope(); FeriteVariable *v; ADDRESS *a; int i; v = ferite_hash_get( script, VAO(header)->variables->variables, "to" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find to address"); a = create_imap_address( script, v ); if(a) env->to = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "from" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find from address"); a = create_imap_address( script, v ); if(a) env->from = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "cc" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find cc address"); a = create_imap_address( script, v ); if(a) env->cc = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "bcc" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find bcc address"); a = create_imap_address( script, v ); if(a) env->bcc = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "return_path" ); if(v) { a = create_imap_address( script, v ); if(a) env->return_path = a; } if(env->return_path == NULL) { v = ferite_hash_get( script, VAO(header)->variables->variables, "from" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find create return path"); a = create_imap_address( script, v ); if(a) env->return_path = a; } v = ferite_hash_get( script, VAO(header)->variables->variables, "sender" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find sender"); a = create_imap_address( script, v ); if(a) env->sender = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "subject" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find subject"); env->subject = cpystr( VAS(v)->data ); RETURN_IF_NULL( env->subject ); v = ferite_hash_get( script, VAO(header)->variables->variables, "in_reply_to" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find in reply to header"); env->in_reply_to = cpystr( VAS(v)->data ); RETURN_IF_NULL( env->in_reply_to ); v = ferite_hash_get( script, VAO(header)->variables->variables, "ID" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find proposed message id"); env->message_id = cpystr( VAS(v)->data ); return env; }
BODY* create_imap_content_leaf( FeriteScript *script, FeriteVariable *leaf ){ BODY *body = NULL; FeriteVariable *v = NULL; body = mail_newbody(); // fixme NULL/0 ? v = ferite_hash_get(script,VAO(leaf)->variables->variables,"encoding"); RETURN_IF_NULL(v); body->encoding=VAI(v); v = ferite_hash_get( script, VAO(leaf)->variables->variables, "content"); RETURN_IF_NULL(v); //fixme memcopy? Encode? body->contents.text.data =strdup(VAS(v)->data); body->contents.text.size =strlen(VAS(v)->data); //fixme v = ferite_hash_get( script, VAO(leaf)->variables->variables, "type" ); RETURN_IF_NULL(v); body->type=VAI(v); v = ferite_hash_get(script,VAO(leaf)->variables->variables,"subtype"); RETURN_IF_NULL(v); body->subtype=cpystr( VAS(v)->data ); v = ferite_hash_get(script,VAO(leaf)->variables->variables,"ID"); RETURN_IF_NULL(v); if( VAS(v)->length > 0 ) { body->id = cpystr( VAS(v)->data ); } v = ferite_hash_get(script,VAO(leaf)->variables->variables,"filename"); RETURN_IF_NULL(v); if( strlen(VAS(v)->data)) { PARAMETER *param = mail_newbody_parameter(); param->attribute = cpystr("filename"); param->value=cpystr( VAS(v)->data ); body->disposition.parameter = param; body->disposition.type = cpystr("attachment"); } v = ferite_hash_get( script, VAO(leaf)->variables->variables, "filepath" ); RETURN_IF_NULL(v); if( strlen(VAS(v)->data) ) { off_t size; int fd; char *buf; struct stat statinfo; fd = open(VAS(v)->data,O_RDONLY); if( fd == -1 ) { char buffer[2048]; sprintf(buffer, "Unable to create email content leaf, unable to open file: %s", VAS(v)->data); ERROR_IF_NULL(NULL, script, buffer); } size=lseek(fd,0,SEEK_END); lseek(fd,0,SEEK_SET); buf=malloc(size*sizeof(char)+1); if(buf){ read(fd,buf,size); body->contents.text.data=buf; body->contents.text.size=size; close(fd); } else{ ferite_error(script, 0, "Out of memory\n"); close(fd); return NULL; } } v = ferite_hash_get(script,VAO(leaf)->variables->variables, "charset"); RETURN_IF_NULL(v); if( strlen(VAS(v)->data) ) { PARAMETER *param = mail_newbody_parameter(); if( body->parameter ) param->next = body->parameter; body->parameter=param; body->parameter->attribute=cpystr("CHARSET"); body->parameter->value=cpystr(VAS(v)->data); } return body; }
int main() { igraph_t g, g2; FILE *ifile; igraph_vector_t gtypes, vtypes, etypes; igraph_strvector_t gnames, vnames, enames; long int i; igraph_vector_t y; igraph_strvector_t id; char str[20]; /* turn on attribute handling */ igraph_i_set_attribute_table(&igraph_cattribute_table); ifile=fopen("LINKS.NET", "r"); if (ifile==0) { return 10; } igraph_read_graph_pajek(&g, ifile); fclose(ifile); igraph_vector_init(>ypes, 0); igraph_vector_init(&vtypes, 0); igraph_vector_init(&etypes, 0); igraph_strvector_init(&gnames, 0); igraph_strvector_init(&vnames, 0); igraph_strvector_init(&enames, 0); igraph_cattribute_list(&g, &gnames, >ypes, &vnames, &vtypes, &enames, &etypes); /* List attribute names and types */ printf("Graph attributes: "); for (i=0; i<igraph_strvector_size(&gnames); i++) { printf("%s (%i) ", STR(gnames, i), (int)VECTOR(gtypes)[i]); } printf("\n"); printf("Vertex attributes: "); for (i=0; i<igraph_strvector_size(&vnames); i++) { printf("%s (%i) ", STR(vnames, i), (int)VECTOR(vtypes)[i]); } printf("\n"); printf("Edge attributes: "); for (i=0; i<igraph_strvector_size(&enames); i++) { printf("%s (%i) ", STR(enames, i), (int)VECTOR(etypes)[i]); } printf("\n"); print_attributes(&g); /* Copying a graph */ igraph_copy(&g2, &g); print_attributes(&g2); igraph_destroy(&g2); /* Adding vertices */ igraph_add_vertices(&g, 3, 0); print_attributes(&g); /* Adding edges */ igraph_add_edge(&g, 1, 1); igraph_add_edge(&g, 2, 5); igraph_add_edge(&g, 3, 6); print_attributes(&g); /* Deleting vertices */ igraph_delete_vertices(&g, igraph_vss_1(1)); igraph_delete_vertices(&g, igraph_vss_1(4)); print_attributes(&g); /* Deleting edges */ igraph_delete_edges(&g, igraph_ess_1(igraph_ecount(&g)-1)); igraph_delete_edges(&g, igraph_ess_1(0)); print_attributes(&g); /* Set graph attributes */ SETGAN(&g, "id", 10); if (GAN(&g, "id") != 10) { return 11; } SETGAS(&g, "name", "toy"); if (strcmp(GAS(&g, "name"), "toy")) { return 12; } /* Delete graph attributes */ DELGA(&g, "id"); DELGA(&g, "name"); igraph_cattribute_list(&g, &gnames, 0,0,0,0,0); if (igraph_strvector_size(&gnames) != 0) { return 14; } /* Delete vertex attributes */ DELVA(&g, "x"); DELVA(&g, "shape"); DELVA(&g, "xfact"); DELVA(&g, "yfact"); igraph_cattribute_list(&g, 0,0, &vnames, 0,0,0); if (igraph_strvector_size(&vnames) != 2) { return 15; } /* Delete edge attributes */ igraph_cattribute_list(&g, 0,0,0,0,&enames,0); i=igraph_strvector_size(&enames); DELEA(&g, "hook1"); DELEA(&g, "hook2"); DELEA(&g, "label"); igraph_cattribute_list(&g, 0,0,0,0,&enames,0); if (igraph_strvector_size(&enames) != i-3) { return 16; } /* Set vertex attributes */ SETVAN(&g, "y", 0, -1); SETVAN(&g, "y", 1, 2.1); if (VAN(&g, "y", 0) != -1 || VAN(&g, "y", 1) != 2.1) { return 17; } SETVAS(&g, "id", 0, "foo"); SETVAS(&g, "id", 1, "bar"); if (strcmp(VAS(&g, "id", 0), "foo") || strcmp(VAS(&g, "id", 1), "bar")) { return 18; } /* Set edge attributes */ SETEAN(&g, "weight", 2, 100.0); SETEAN(&g, "weight", 0, -100.1); if (EAN(&g, "weight", 2) != 100.0 || EAN(&g, "weight", 0) != -100.1) { return 19; } SETEAS(&g, "color", 2, "RED"); SETEAS(&g, "color", 0, "Blue"); if (strcmp(EAS(&g, "color", 2), "RED") || strcmp(EAS(&g, "color", 0), "Blue")) { return 20; } /* Set vector attributes as vector */ igraph_vector_init(&y, igraph_vcount(&g)); igraph_vector_fill(&y, 1.23); SETVANV(&g, "y", &y); igraph_vector_destroy(&y); for (i=0; i<igraph_vcount(&g); i++) { if (VAN(&g, "y", i) != 1.23) { return 21; } } igraph_vector_init_seq(&y, 0, igraph_vcount(&g)-1); SETVANV(&g, "foobar", &y); igraph_vector_destroy(&y); for (i=0; i<igraph_vcount(&g); i++) { if (VAN(&g, "foobar", i) != i) { return 22; } } igraph_strvector_init(&id, igraph_vcount(&g)); for (i=0; i<igraph_vcount(&g); i++) { snprintf(str, sizeof(str)-1, "%li", i); igraph_strvector_set(&id, i, str); } SETVASV(&g, "foo", &id); igraph_strvector_destroy(&id); for (i=0; i<igraph_vcount(&g); i++) { printf("%s ", VAS(&g, "foo", i)); } printf("\n"); igraph_strvector_init(&id, igraph_vcount(&g)); for (i=0; i<igraph_vcount(&g); i++) { snprintf(str, sizeof(str)-1, "%li", i); igraph_strvector_set(&id, i, str); } SETVASV(&g, "id", &id); igraph_strvector_destroy(&id); for (i=0; i<igraph_vcount(&g); i++) { printf("%s ", VAS(&g, "id", i)); } printf("\n"); /* Set edge attributes as vector */ igraph_vector_init(&y, igraph_ecount(&g)); igraph_vector_fill(&y, 12.3); SETEANV(&g, "weight", &y); igraph_vector_destroy(&y); for (i=0; i<igraph_ecount(&g); i++) { if (EAN(&g, "weight", i) != 12.3) { return 23; } } igraph_vector_init_seq(&y, 0, igraph_ecount(&g)-1); SETEANV(&g, "foobar", &y); igraph_vector_destroy(&y); for (i=0; i<igraph_ecount(&g); i++) { if (VAN(&g, "foobar", i) != i) { return 24; } } igraph_strvector_init(&id, igraph_ecount(&g)); for (i=0; i<igraph_ecount(&g); i++) { snprintf(str, sizeof(str)-1, "%li", i); igraph_strvector_set(&id, i, str); } SETEASV(&g, "foo", &id); igraph_strvector_destroy(&id); for (i=0; i<igraph_ecount(&g); i++) { printf("%s ", EAS(&g, "foo", i)); } printf("\n"); igraph_strvector_init(&id, igraph_ecount(&g)); for (i=0; i<igraph_ecount(&g); i++) { snprintf(str, sizeof(str)-1, "%li", i); igraph_strvector_set(&id, i, str); } SETEASV(&g, "color", &id); igraph_strvector_destroy(&id); for (i=0; i<igraph_ecount(&g); i++) { printf("%s ", EAS(&g, "color", i)); } printf("\n"); /* Delete all remaining attributes */ DELALL(&g); igraph_cattribute_list(&g, &gnames, >ypes, &vnames, &vtypes, &enames, &etypes); if (igraph_strvector_size(&gnames) != 0 || igraph_strvector_size(&vnames) != 0 || igraph_strvector_size(&enames) != 0) { return 25; } /* Destroy */ igraph_vector_destroy(>ypes); igraph_vector_destroy(&vtypes); igraph_vector_destroy(&etypes); igraph_strvector_destroy(&gnames); igraph_strvector_destroy(&vnames); igraph_strvector_destroy(&enames); igraph_destroy(&g); return 0; }
FeriteVariable *create_ferite_content_object( FeriteScript *script, MAILSTREAM *stream, BODY *body, int msgno, char *sec ) { if( body != NULL ) { FeriteVariable *object = NULL,*v = NULL; FeriteNamespaceBucket *nsb = NULL; char *object_name = NULL; object_name = ( body->type == TYPEMULTIPART ) ? "Mail.MessageMultiPart" : "Mail.MessagePart" ; nsb = ferite_find_namespace( script, script->mainns, object_name , FENS_CLS ); if( nsb == NULL ) return NULL; object = ferite_build_object( script, (FeriteClass *)nsb->data ); if( object == NULL ) return NULL; v = fe_new_lng("type",body->type); ferite_object_set_var(script, VAO(object), "type", v); output_printf(OUTPUT_DEBUG,"module.mail: setting type %d", body->type); if( body->subtype ) { v = fe_new_str( "subtype", body->subtype, 0, FE_CHARSET_DEFAULT ); ferite_object_set_var( script, VAO(object), "subtype", v ); } if( body->type == TYPEMULTIPART ) { PART *part = NULL; int i = 0; char sec2[200]; FeriteVariable *ret = NULL, *parts = NULL; parts = ferite_hash_get(script,VAO(object)->variables->variables,"parts"); part = body->nested.part; while( part ) { i++; if( sec ) { snprintf(sec2,200,"%s.%d",sec,i); } else { snprintf(sec2,200,"%d",i); } ret = create_ferite_content_object( script, stream, &part->body, msgno, sec2 ); ferite_uarray_add( script, VAUA(parts), ret , NULL, FE_ARRAY_ADD_AT_END ); part = part->next; } v = fe_new_lng("nparts", i); ferite_object_set_var(script, VAO(object), "nparts", v ); } else { long len = 0,len2 = 0; unsigned char *buf = NULL, *buf2 = NULL; SIZEDTEXT src, dest; FeriteVariable *v = NULL; PARAMETER *param = NULL; int i = 0; if( sec == NULL ) sec = "1"; buf = mail_fetchbody( stream, msgno, sec, &len ); switch(body->encoding){ case ENCQUOTEDPRINTABLE: if( debug_cmail_module ) output_printf(OUTPUT_DEBUG,"module.mail: Decoding from encoded quotable"); buf2 = rfc822_qprint(buf,len,&len2); break; case ENCBASE64: if( debug_cmail_module ) output_printf(OUTPUT_DEBUG,"module.mail: Decoding from base64"); buf2=rfc822_base64(buf,len,&len2); break; default: buf2=buf; len2=len; } if( debug_cmail_module ) { output_printf(OUTPUT_DEBUG,"module.mail: id: %s, description: %s", body->id, body->description); output_printf(OUTPUT_DEBUG,"module.mail: block type: %d.%s", body->type, body->subtype); } if( body->parameter ) /* Try and get the content type correctly */ { PARAMETER *ptr = body->parameter; while( ptr != NULL ) { if( caseless_compare( ptr->attribute, "charset" ) ) { if( debug_cmail_module ) output_printf(OUTPUT_DEBUG,"module.mail: Found content type for block: %s", ptr->value); v = fe_new_str("charset", ptr->value, 0, FE_CHARSET_DEFAULT); ferite_object_set_var(script, VAO(object), "charset", v); } ptr = ptr->next; } } v = fe_new_bin_str("content", buf2, len2, FE_CHARSET_DEFAULT ); ferite_object_set_var(script, VAO(object), "content", v ); v = fe_new_lng("encoding", body->encoding ); ferite_object_set_var(script, VAO(object), "encoding", v ); if( body->id ) { v = fe_new_str("ID", body->id, strlen(body->id), FE_CHARSET_DEFAULT); ferite_object_set_var(script, VAO(object), "ID", v); } if( body->disposition.type && strcasecmp(body->disposition.type, "attachment") == 0) { param = body->disposition.parameter; while(param){ if( param->attribute && ((strcasecmp(param->attribute,"filename") == 0) || (strcasecmp(param->attribute,"name") == 0) || (strcasecmp(param->attribute,"name*") == 0) || (strcasecmp(param->attribute,"filename*") == 0) )) { v = fe_new_str("filename", param->value, 0, FE_CHARSET_DEFAULT ); ferite_object_set_var(script, VAO(object), "filename", v ); break; } param=param->next; } } /* If filename was not found in Content-Disposition header search for it among the parameters */ if( strcmp(VAS(ferite_object_get_var(script, VAO(object), "filename"))->data, "") == 0 ) { param = body->parameter; while(param){ if( param->attribute && ((strcasecmp(param->attribute,"filename") == 0) || (strcasecmp(param->attribute,"name") == 0))) { v = fe_new_str("filename", param->value, 0, FE_CHARSET_DEFAULT ); ferite_object_set_var(script, VAO(object), "filename", v ); break; } param = param->next; } } } return object; } return NULL; }
int ggen_write_graph(igraph_t *g, FILE *output) { Agraph_t *cg; Agnode_t *f,*t; Agedge_t *edge; igraph_vector_ptr_t vertices; igraph_eit_t eit; int err; unsigned long i,j; unsigned long vcount = igraph_vcount(g); igraph_integer_t from,to; char name[GGEN_DEFAULT_NAME_SIZE]; char *str = NULL; igraph_strvector_t gnames,vnames,enames; igraph_vector_t gtypes,vtypes,etypes; Agsym_t *attr; /* see warning below */ igraph_error_handler_t *error_handler; err = igraph_vector_ptr_init(&vertices,vcount); if(err) return 1; /* WARNING: this should be changed if igraph-0.6 gets * stable. * We need to ignore some igraph_cattribute errors * because we try to retrieve special attributes (ggen specifics). * igraph version 0.6 include a cattribute_has_attr that should be * used instead of ignoring errors. */ error_handler = igraph_set_error_handler(igraph_error_handler_ignore); /* open graph * its name is saved in __ggen_graph_name if it exists */ str =(char *) GAS(g,GGEN_GRAPH_NAME_ATTR); if(!str) cg = agopen(GGEN_DEFAULT_GRAPH_NAME,Agdirected,NULL); else cg = agopen(str,Agdirected,NULL); if(!cg) { err = 1; goto d_v; } /* save a pointer to each vertex */ for(i = 0; i < vcount; i++) { /* find a vertex name */ str = vid2vname_unsafe(name,g,i); if(!str) f = agnode(cg,name,1); else f = agnode(cg,str,1); VECTOR(vertices)[i] = (void *)f; } /* We have finished with dangerous attributes accesses */ igraph_set_error_handler(error_handler); /* now loop through edges in the igraph */ err = igraph_eit_create(g,igraph_ess_all(IGRAPH_EDGEORDER_ID),&eit); if(err) goto c_ag; for(IGRAPH_EIT_RESET(eit); !IGRAPH_EIT_END(eit); IGRAPH_EIT_NEXT(eit)) { err = igraph_edge(g,IGRAPH_EIT_GET(eit),&from,&to); if(err) goto d_eit; f = (Agnode_t *) VECTOR(vertices)[(unsigned long)from]; t = (Agnode_t *) VECTOR(vertices)[(unsigned long)to]; agedge(cg,f,t,NULL,1); } /* find all properties */ igraph_strvector_init(&gnames,1); igraph_strvector_init(&vnames,vcount); igraph_strvector_init(&enames,igraph_ecount(g)); igraph_vector_init(>ypes,1); igraph_vector_init(&vtypes,vcount); igraph_vector_init(&etypes,igraph_ecount(g)); err = igraph_cattribute_list(g,&gnames,>ypes,&vnames,&vtypes,&enames,&etypes); if(err) goto d_eit; /* add graph properties */ for(i = 0; i < igraph_strvector_size(&gnames); i++) { if(strcmp(GGEN_GRAPH_NAME_ATTR,STR(gnames,i))) { if(VECTOR(gtypes)[i]==IGRAPH_ATTRIBUTE_NUMERIC) { snprintf(name,GGEN_DEFAULT_NAME_SIZE,"%f", (double)GAN(g,STR(gnames,i))); agattr(cg,AGRAPH,(char *)STR(gnames,i),name); } else agattr(cg,AGRAPH,(char *)STR(gnames,i), (char *)GAS(g,STR(gnames,i))); } } /* add vertex properties */ for(i = 0; i < igraph_strvector_size(&vnames); i++) { if(strcmp(GGEN_VERTEX_NAME_ATTR,STR(vnames,i))) { /* creates the attribute but we still need to set it for each vertex */ attr = agattr(cg,AGNODE,(char *)STR(vnames,i),GGEN_CGRAPH_DEFAULT_VALUE); for(j = 0; j < vcount; j++) { f = (Agnode_t *) VECTOR(vertices)[j]; if(VECTOR(vtypes)[i]==IGRAPH_ATTRIBUTE_NUMERIC) { snprintf(name,GGEN_DEFAULT_NAME_SIZE,"%f", (double)VAN(g,STR(vnames,i),j)); agxset(f,attr,name); } else agxset(f,attr,(char *)VAS(g,STR(vnames,i),j)); } } } /* add edges properties */ for(i = 0; i < igraph_strvector_size(&enames); i++) { /* creates the attribute but we still need to set it for each edge */ attr = agattr(cg,AGEDGE,(char *)STR(enames,i),GGEN_CGRAPH_DEFAULT_VALUE); for(j = 0; j < igraph_ecount(g); j++) { igraph_edge(g,j,&from,&to); f = (Agnode_t *) VECTOR(vertices)[(unsigned long)from]; t = (Agnode_t *) VECTOR(vertices)[(unsigned long)to]; edge = agedge(cg,f,t,NULL,0); if(VECTOR(etypes)[i]==IGRAPH_ATTRIBUTE_NUMERIC) { snprintf(name,GGEN_DEFAULT_NAME_SIZE,"%f", (double)EAN(g,STR(enames,i),j)); agxset(edge,attr,name); } else agxset(edge,attr,(char *)EAS(g,STR(enames,i),j)); } } /* write the graph */ err = agwrite(cg,(void *)output); d_eit: igraph_eit_destroy(&eit); c_ag: agclose(cg); d_v: igraph_vector_ptr_destroy(&vertices); return err; }
int print_attributes(const igraph_t *g) { igraph_vector_t gtypes, vtypes, etypes; igraph_strvector_t gnames, vnames, enames; long int i; igraph_vector_t vec; igraph_strvector_t svec; long int j; igraph_vector_init(>ypes, 0); igraph_vector_init(&vtypes, 0); igraph_vector_init(&etypes, 0); igraph_strvector_init(&gnames, 0); igraph_strvector_init(&vnames, 0); igraph_strvector_init(&enames, 0); igraph_cattribute_list(g, &gnames, >ypes, &vnames, &vtypes, &enames, &etypes); /* Graph attributes */ for (i=0; i<igraph_strvector_size(&gnames); i++) { printf("%s=", STR(gnames, i)); if (VECTOR(gtypes)[i]==IGRAPH_ATTRIBUTE_NUMERIC) { igraph_real_printf(GAN(g, STR(gnames,i))); putchar(' '); } else { printf("\"%s\" ", GAS(g, STR(gnames,i))); } } printf("\n"); for (i=0; i<igraph_vcount(g); i++) { long int j; printf("Vertex %li: ", i); for (j=0; j<igraph_strvector_size(&vnames); j++) { printf("%s=", STR(vnames, j)); if (VECTOR(vtypes)[j]==IGRAPH_ATTRIBUTE_NUMERIC) { igraph_real_printf(VAN(g, STR(vnames,j), i)); putchar(' '); } else { printf("\"%s\" ", VAS(g, STR(vnames,j), i)); } } printf("\n"); } for (i=0; i<igraph_ecount(g); i++) { long int j; printf("Edge %li (%i-%i): ", i, (int)IGRAPH_FROM(g,i), (int)IGRAPH_TO(g,i)); for (j=0; j<igraph_strvector_size(&enames); j++) { printf("%s=", STR(enames, j)); if (VECTOR(etypes)[j]==IGRAPH_ATTRIBUTE_NUMERIC) { igraph_real_printf(EAN(g, STR(enames, j), i)); putchar(' '); } else { printf("\"%s\" ", EAS(g, STR(enames, j), i)); } } printf("\n"); } /* Check vector-based query functions */ igraph_vector_init(&vec, 0); igraph_strvector_init(&svec, 0); for (j=0; j<igraph_strvector_size(&vnames); j++) { if (VECTOR(vtypes)[j]==IGRAPH_ATTRIBUTE_NUMERIC) { igraph_cattribute_VANV(g, STR(vnames, j), igraph_vss_all(), &vec); for (i=0; i<igraph_vcount(g); i++) { igraph_real_t num=VAN(g, STR(vnames, j), i); if (num != VECTOR(vec)[i] && (!isnan(num) || !isnan(VECTOR(vec)[i]))) { exit(51); } } } else { igraph_cattribute_VASV(g, STR(vnames, j), igraph_vss_all(), &svec); for (i=0; i<igraph_vcount(g); i++) { const char *str=VAS(g, STR(vnames, j), i); if (strcmp(str,STR(svec, i))) { exit(52); } } } } for (j=0; j<igraph_strvector_size(&enames); j++) { if (VECTOR(etypes)[j]==IGRAPH_ATTRIBUTE_NUMERIC) { igraph_cattribute_EANV(g, STR(enames, j), igraph_ess_all(IGRAPH_EDGEORDER_ID), &vec); for (i=0; i<igraph_ecount(g); i++) { igraph_real_t num=EAN(g, STR(enames, j), i); if (num != VECTOR(vec)[i] && (!isnan(num) || !isnan(VECTOR(vec)[i]))) { exit(53); } } } else { igraph_cattribute_EASV(g, STR(enames, j), igraph_ess_all(IGRAPH_EDGEORDER_ID), &svec); for (i=0; i<igraph_ecount(g); i++) { const char *str=EAS(g, STR(enames, j), i); if (strcmp(str,STR(svec, i))) { exit(54); } } } } igraph_strvector_destroy(&svec); igraph_vector_destroy(&vec); igraph_strvector_destroy(&enames); igraph_strvector_destroy(&vnames); igraph_strvector_destroy(&gnames); igraph_vector_destroy(&etypes); igraph_vector_destroy(&vtypes); igraph_vector_destroy(>ypes); return 0; }
static GError* _tgengraph_parseGraphEdges(TGenGraph* g) { TGEN_ASSERT(g); tgen_debug("checking graph edges..."); /* we will iterate through the edges */ igraph_eit_t edgeIterator; gint result = igraph_eit_create(g->graph, igraph_ess_all(IGRAPH_EDGEORDER_ID), &edgeIterator); if(result != IGRAPH_SUCCESS) { return g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "igraph_eit_create return non-success code %i", result); } /* count the edges as we iterate */ igraph_integer_t edgeCount = 0; GError* error = NULL; while (!IGRAPH_EIT_END(edgeIterator)) { igraph_integer_t edgeIndex = IGRAPH_EIT_GET(edgeIterator); igraph_integer_t fromVertexIndex, toVertexIndex; gint result = igraph_edge(g->graph, edgeIndex, &fromVertexIndex, &toVertexIndex); if(result != IGRAPH_SUCCESS) { error = g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "igraph_edge return non-success code %i", result); break; } const gchar* fromIDStr = (g->knownAttributes&TGEN_VA_ID) ? VAS(g->graph, "id", fromVertexIndex) : NULL; if(!fromIDStr) { error = g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_MISSING_ATTRIBUTE, "found vertex %li with missing 'id' attribute", (glong)fromVertexIndex); break; } const gchar* toIDStr = (g->knownAttributes&TGEN_VA_ID) ? VAS(g->graph, "id", toVertexIndex) : NULL; if(!toIDStr) { error = g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_MISSING_ATTRIBUTE, "found vertex %li with missing 'id' attribute", (glong)toVertexIndex); break; } tgen_debug("found edge %li from vertex %li (%s) to vertex %li (%s)", (glong)edgeIndex, (glong)fromVertexIndex, fromIDStr, (glong)toVertexIndex, toIDStr); const gchar* weightStr = (g->knownAttributes&TGEN_EA_WEIGHT) ? EAS(g->graph, "weight", edgeIndex) : NULL; if(weightStr != NULL) { if(g_ascii_strncasecmp(weightStr, "\0", (gsize) 1)) { gdouble weight = g_ascii_strtod(weightStr, NULL); _tgengraph_storeWeight(g, weight, edgeIndex); } } edgeCount++; IGRAPH_EIT_NEXT(edgeIterator); } igraph_eit_destroy(&edgeIterator); if(!error) { g->edgeCount = igraph_ecount(g->graph); if(g->edgeCount != edgeCount) { tgen_warning("igraph_vcount %f does not match iterator count %f", g->edgeCount, edgeCount); } tgen_info("%u graph edges ok", (guint) g->edgeCount); } return error; }
static GError* _tgengraph_parseGraphVertices(TGenGraph* g) { TGEN_ASSERT(g); tgen_debug("checking graph vertices..."); /* we will iterate through the vertices */ igraph_vit_t vertexIterator; gint result = igraph_vit_create(g->graph, igraph_vss_all(), &vertexIterator); if(result != IGRAPH_SUCCESS) { return g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "igraph_vit_create return non-success code %i", result); } /* count the vertices as we iterate */ igraph_integer_t vertexCount = 0; GError* error = NULL; while (!IGRAPH_VIT_END(vertexIterator)) { igraph_integer_t vertexIndex = (igraph_integer_t)IGRAPH_VIT_GET(vertexIterator); /* get vertex attributes: S for string and N for numeric */ const gchar* idStr = (g->knownAttributes&TGEN_VA_ID) ? VAS(g->graph, "id", vertexIndex) : NULL; if(!idStr) { error = g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_MISSING_ATTRIBUTE, "found vertex %li with missing action 'id' attribute", (glong)vertexIndex); break; } if(g_strstr_len(idStr, (gssize)-1, "start")) { error = _tgengraph_parseStartVertex(g, idStr, vertexIndex); } else if(g_strstr_len(idStr, (gssize)-1, "end")) { error = _tgengraph_parseEndVertex(g, idStr, vertexIndex); } else if(g_strstr_len(idStr, (gssize)-1, "pause")) { error = _tgengraph_parsePauseVertex(g, idStr, vertexIndex); } else if(g_strstr_len(idStr, (gssize)-1, "synchronize")) { error = _tgengraph_parseSynchronizeVertex(g, idStr, vertexIndex); } else if(g_strstr_len(idStr, (gssize)-1, "transfer")) { error = _tgengraph_parseTransferVertex(g, idStr, vertexIndex); } else if(g_strstr_len(idStr, (gssize)-1, "choose")) { error = _tgengraph_parseChooseVertex(g, idStr, vertexIndex); } else { error = g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, "found vertex %li (%s) with an unknown action id '%s'", (glong)vertexIndex, idStr, idStr); } if(error) { break; } vertexCount++; IGRAPH_VIT_NEXT(vertexIterator); } /* clean up */ igraph_vit_destroy(&vertexIterator); if(!g->startHasPeers && g->transferMissingPeers) { error = g_error_new(G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "peers required in either the 'start' action, or *every* 'transfer' action"); } if(!error) { g->vertexCount = igraph_vcount(g->graph); if(g->vertexCount != vertexCount) { tgen_warning("igraph_vcount %f does not match iterator count %f", g->vertexCount, vertexCount); } tgen_info("%u graph vertices ok", (guint) g->vertexCount); } return error; }