// opt.c
// $Id: opt.c,v 1.1.1.1 2007/09/19 05:49:54 sendan Exp $
// masashi shimakura

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


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

extern struct global_data gd;

/*
int optin(int, char *[]);
*/

int opt_version(void); 
int opt_conf(char *);
int opt_neg(char *);
int opt_id(char *);


int optin(int argc, char * argv[])
{
extern char *optarg;
int i;

while((i=getopt(argc,argv,":c:v:n:i:"))!= EOF){
   switch(i){
      case 'c': opt_conf(optarg);    break;
      case 'v': opt_version();       break;
      case 'n': opt_neg(optarg);     break;
      case 'i': opt_id(optarg);      break; 
      default : opt_version();       break;
      }
   }
return 0;
}



/* ------------- sub ------------- */



int opt_version(void)
{
printf("------- zither %s\n", CL_VAR);
#ifdef POSTGRES_IN
printf("------- for postgreSQL\n");
#endif
#ifdef MYSQL_IN
printf("------- for mysql\n");
#endif
printf("     -c /*/   config file name\n");
printf("     -n /*/   nego file name\n");
printf("     -i <UID> user id\n");   
printf("\n"); 
exit(1);
return 0;
}


int opt_conf(char *path) 
{
gd.fp.conf_path = path;
return 0;
}



int opt_neg(char *path) 
{
gd.fp.neg_conf = path;
return 0;
}


int opt_id(char *opt)
{
if(TIME_LEN >strlen(opt)){
   gd.exid.uid = strtol(opt, (char **)NULL, 10); 
   }
return 0;
}





