<commit_before>/*
 * =====================================================================================
 *
 *       Filename:  pasc_cli.c
 *
 *    Description:  pasc client program 
 *
 *        Version:  1.0
 *        Created:  03/25/2015 09:27:51 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  ZhaoKaiqiang
 *   Organization:  
 *
 * =====================================================================================
 */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>

static int verbose_flag;

void usage();
void pasc_connect(char *ipaddr);
void pasc_query(char *name);
void pasc_join(char *name);
void pasc_login(char *name);
void pasc_exit(char *name);
void pasc_update(char *name);

int main ( int argc, char *argv[] )
{
    int c;
	int option_index = 0;
    static struct option long_options[]=
    {
	{"connect",required_argument,0,'c'},
	{"query",required_argument, 0,'q'},
	{"join",required_argument,0,'j'},
	{"login",required_argument,0,'l'},
	{"exit",required_argument,0,'e'},
	{"update",required_argument,0,'u'},
	{"help",no_argument,0,'h'},
	{0,0,0,0}
    };

    while((c = getopt_long(argc,argv,"hc:q:j:l:e:u:",long_options,&option_index)) != -1)
    {
		switch(c)
			{
			case 'c':
			//if(optarg)
			pasc_connect(optarg);
			break;

			case 'q':
			pasc_query(optarg);
			break;

			case 'j':
			pasc_join(optarg);
			break;
			
			case 'l':
			pasc_login(optarg);
			break;

			case 'e':
			pasc_exit(optarg);
			break;
			
			case 'u':
			pasc_update(optarg);
			break;

			case '?':
			case 'h':
			usage();
			break;

			default:
			printf("default\n");
			abort();
		}
    }

/*    if(optind < argc)
	{
		printf("non-option ARGV-elements:");
		while(optind < argc)
		printf("%s",argv[optind++]);
		printf("\n");
	}*/

    return EXIT_SUCCESS;
}
/* ----------  end of function main  ---------- */

void usage()
{
    printf("mampage is ok!\n");
}

void pasc_connect(char *ipaddr)
{
	printf("ok %s\n",ipaddr);
}
void pasc_query(char *name)
{
	printf("ok %s\n",name);
}
void pasc_join(char *name)
{
	printf("ok %s\n",name);
}
void pasc_login(char *name)
{<commit_msg>use getopt parse command-line options instead of getopt_long,means only support short option.please use -h instead of --help for help.<commit_after>/*
 * =====================================================================================
 *
 *       Filename:  pasc_cli.c
 *
 *    Description:  pasc client program 
 *
 *        Version:  1.0
 *        Created:  03/25/2015 09:27:51 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  ZhaoKaiqiang
 *   Organization:  
 *
 * =====================================================================================
 */

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

void usage();
void pasc_connect(char *ipaddr);
void pasc_query(char *name);
void pasc_join(char *name);
void pasc_login(char *name);
void pasc_exit(char *name);
void pasc_update(char *name);

int main ( int argc, char *argv[] )
{

	char opt;
    if (argc <= 1 || argc >= 4)
	{
		usage();
		return 1;
	}
	
    opt = getopt(argc,argv,"hc:q:j:l:e:u:");
	switch(opt)
		{
		case 'c':
		//if(optarg)
			pasc_connect(optarg);
			break;

		case 'q':
			pasc_query(optarg);
			break;

		case 'j':
			pasc_join(optarg);
			break;
		
		case 'l':
			pasc_login(optarg);
			break;

		case 'e':
			pasc_exit(optarg);
			break;
		
		case 'u':
			pasc_update(optarg);
			break;

		case 'h':
		case '?':

		default:
			usage();
			break;
		}	

/* 
    if(optind < argc)
	{
		printf("non-option ARGV-elements:");
		while(optind < argc)
		printf("%s",argv[optind++]);
		printf("\n");
	} */

    return EXIT_SUCCESS;
}
/* ----------  end of function main  ---------- */

void usage()
{
    printf("mampage is ok!\n");
}

void pasc_connect(char *ipaddr)
{
	printf("ok %s\n",ipaddr);
}
void pasc_query(char *name)
{
	printf("ok %s\n",name);
}
void pasc_join(char *name)
{
	printf("ok %s\n",name);
}
void pasc_login(char *name)
{
{'fraction_non_alphanumeric': 0.2545499875342807, 'fraction_numerical': 0.011967090501121914, 'mean_word_length': 3.286324786324786, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3766935', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1470, 'n_words': 300}