
#include<stdio.h>
#include<unistd.h>
#include<sys/socket.h>
#include<netinet/in_systm.h>
#include<netinet/in.h>
#include<netinet/ip.h>
#include<arpa/inet.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>

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



/*
int chack_lockfile(char *);
*/



char * chack_lockfile(char * user, char * info, char * lock_filename, char * lock_path, int * stat)
{
FILE * fp;

*stat = 0;

lock_filename = filename_create(lock_filename, lock_path, "_lock", user);

if((fp = fopen(lock_filename, "r"))==NULL){
   if((fp = fopen(lock_filename, "w+"))!=NULL){
      fprintf(fp,"user = %s:info = %s:pid = %d\n", user, info, (int)getpid());
      fclose(fp);
      fprintf(stderr,"chack_lockfile(): Lock file create. %s\n", lock_filename);
      *stat = 1;
      }
   else{
      fprintf(stderr,"chack_lockfile(): The Lock file cannot be made. %s\n", lock_filename);
      *stat = 0;
      }
   }
else{
   fprintf(stderr,"chack_lockfile(): The Lock file exists. %s\n", lock_filename);
   fclose(fp);
   *stat = 0;
   }
return lock_filename;
}





