/* * \fn: int foreignsector_export_buy() * \brief: foreign sector buys export goods from export firms */ int foreignsector_export_buy() { int amount, id; START_FIRM_FOREIGNSECTOR_AMOUNT_MESSAGE_LOOP amount = firm_foreignsector_amount_message->amount; id = firm_foreignsector_amount_message->id; add_export(&EXPORT_LIST,id,amount); FINISH_FIRM_FOREIGNSECTOR_AMOUNT_MESSAGE_LOOP return 0; /* Returning zero means the agent is not removed */ }
glxlink::glxlink(char *filename) { bool ok = true; globals = NULL; imports = NULL; exports = NULL; objects = NULL; handle = NULL; settag = NULL; init = NULL; sync = NULL; term = NULL; glxflags = 0; valid_to = 0; last_t = 0; FILE *fp = fopen(filename,"rt"); if ( fp==NULL ) throw "file open failed"; output_debug("opened link '%s'", filename); char line[1024]; int linenum=0; while ( fgets(line,sizeof(line),fp)!=NULL ) { linenum++; if ( line[0]=='#' ) continue; char tag[64], data[1024]=""; if ( sscanf(line,"%s %[^\r\n]",tag,data)>0 ) { output_debug("%s(%d): %s %s", filename, linenum, tag,data); if ( settag!=NULL ) { if ( strcmp(tag,"global")==0 ) { add_global(data); } else if ( strcmp(tag,"object")==0 ) { add_object(data); } else if ( strcmp(tag,"export")==0 ) { add_export(data); } else if ( strcmp(tag,"import")==0 ) { add_import(data); } else if ( !(*settag)(this,tag,data) ) output_error("%s(%d): tag '%s' not accepted", filename, linenum, tag); } else if ( strcmp(tag,"target")==0) { if ( !set_target(data) ) { output_error("%s(%d): target '%s' is not valid", filename, linenum, data); ok = false; } } else output_warning("%s(%d): tag '%s' cannot be processed until target module is loaded", filename, linenum, tag); } } fclose(fp); // append to link list next = first; first = this; if ( ok ) output_verbose("link '%s' ok", filename); else throw "cannot establish link"; }