
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<errno.h>

#include"sitar.h"
#include<almemsys/almemsys.h>

extern global_data_t gd;
// pthread_mutex_lock(&name_mutex);


int miname_dump(char * file_name)
{
FILE * fp;
int ppp, ret;

ret = 0;

if((fp = fopen(file_name, "w"))!=NULL){
   fprintf(stderr, "miname_dump(): open name list file <%s>\n", file_name);
   for(ppp = 0;  ppp < gd.td.midcount; ppp++){
      if(gd.td.middle_name[ppp][0] != (char)0x00){
         fprintf(fp, "%d,%s\n", gd.td.middle_id[ppp], gd.td.middle_name[ppp]);
         #ifdef MINAME_BUG
         printf("<%d>: [%d]%s\n", ppp, gd.td.middle_id[ppp], gd.td.middle_name[ppp]);
         #endif
         ret++;
         }
      }
   fclose(fp);
   }
else{
   fprintf(stderr, "miname_dump(): <%s>\n", file_name);
   ret = -1;
   }

return ret;
}


