/** * Read input file and put the content into corresponding structure * \param filename Filename of input file */ cipher_cont* read_input(char* filename) { FILE *infile; cipher_cont *t_cipher; int i=0; int j=0; unsigned long plain[MAX_FILE_LINES][2]; unsigned long cipher[MAX_FILE_LINES][2]; char v[255]; if(!(infile=fopen(filename,"r"))) { fprintf(stderr,"ERROR: failed to open intput file: %s\n",filename); exit(0); } fscanf(infile,"%s",v); fscanf(infile,"%s",v); fscanf(infile,"%s",v); fscanf(infile,"%s",v); while(!feof(infile)) { fscanf(infile,"%s",v); plain[i][1]=strtoull(v+8,NULL,16); v[8]='\0'; plain[i][0]=strtoull(v,NULL,16); fscanf(infile,"%s",v); cipher[i][1]=strtoull(v+8,NULL,16); v[8]='\0'; cipher[i][0]=strtoull(v,NULL,16); i++; } t_cipher=NMALLOC(i,cipher_cont); for(j=0;j<i;j++) { t_cipher[j].plain_message[0]=plain[j][0]; t_cipher[j].plain_message[1]=plain[j][1]; t_cipher[j].cipher_message[0]=cipher[j][0]; t_cipher[j].cipher_message[1]=cipher[j][1]; } t_cipher[0].size_array=i; fclose(infile); return t_cipher; }
/* Loads the given named dynamic library file. Retrieves function pointers to the simengine API calls. */ void init_simengine(const char *name) { char *msg; api = NMALLOC(1, simengine_api); mexMakeMemoryPersistent(api); api->driver = dlopen(name, RTLD_NOW); if(!api->driver) { ERROR(Simatra:SIMEX:HELPER:dynamicLoadError, "dlopen() failed to load %s: %s", name, dlerror()); }