void process_input(char *recvbuf, int recv_buf_cnt, int* csock) 
{

	char replybuf[1024]={'\0'};
	printf("%s",recvbuf);
	//printf("mahendar Reddy\n");
	int Arr_decode[200];
	int length = DecodeBuffer(recvbuf, Arr_decode);
	loadtoMazeValues(Arr_decode, length);
	printf("m=%d\tn=%d\n", m, n);
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			printf("%d\t", Arr[i][j]);
		}
		printf("\n");
	}
	printf("a1=%d\tb1=%d\ta2=%d\tb2=%d\n", a1, b1, a2, b2);
	int flag = ispathexist(a1, b1, a2, b2);
	char buffer[256];
	if (flag == 1)
	{
		converStringtoresultBuffer(buffer);
	}
	else{
		addnumber(0, buffer);
	}
	printf("%s", buffer);
	replyto_client(buffer, csock);
	replybuf[0] = '\0';
}
Exemplo n.º 2
0
void getappointment(FILE *fp, int cid, int pid, char *user, int d, int m, int y, int *csock){
	printf("\n in get appointments");

	fseek(fp, 0, SEEK_END);
	struct appointment a;
	a.flag = 3;
	a.category_id = cid;
	a.person_id = pid;
	strcpy(a.username, user);
	a.d = d;
	a.m = m;
	a.y = y;
	if (isvalid_date(fp, d, m, y)){
		fwrite(&a, sizeof(a), 1, fp);
		replyto_client("appointment creation successfull...", csock);
	}
	else{
		replyto_client("invalid/alreday booked date provided try again with another date :)", csock);
	}
}
Exemplo n.º 3
0
void createperson(FILE *fp, int cid, int pid, char *p_name, char *p_spec, int *csock){

	fseek(fp, 0, SEEK_END);
	struct person p;
	p.flag = 2;
	p.category_id = cid;
	p.person_id = pid;
	strcpy(p.name, p_name);
	strcpy(p.specialization, p_spec);
	fwrite(&p, sizeof(p), 1, fp);
	replyto_client("person creation successfull...", csock);
}
Exemplo n.º 4
0
void createcategory(FILE *fp, char *spec, int *csock){
	long f;
	fseek(fp, 0, SEEK_END);
	f = ftell(fp);
	struct category c;
	c.flag = 1;
	if (f == 0)
		c.id = 1;
	else
		c.id = get_id(fp);
	printf("\ncid = %d\n", c.id);
	strcpy(c.spec, spec);
	fwrite(&c, sizeof(c), 1, fp);
	replyto_client("category creation successfull...", csock);
}
Exemplo n.º 5
0
void process_input(char *recvbuf, int recv_buf_cnt, int* csock) 
{
	
	char replybuf[1024]={'\0'};
	char buffer[1024];
	memset(&buffer, 0, 1024);
	int k=ProcessInputBuffer(recvbuf);
	if (k == 0)
	{
		WriteToTheFile(recvbuf);
	}
	else if (k == 1)
	{
		printf("Client Opened");
		memset(recvbuf, '\0', sizeof(recvbuf));
		char sendbuffer[256] = "@1\n\n\t1.Blob Store\n\n$1$1$#";
		strcpy(recvbuf, sendbuffer);
	}
	else if (k == 3)
	{
		ManageUsersData(recvbuf);
	}
	else if (k == 4)
	{
		ProcessMainFunction(recvbuf);
	}
	else if (k == 5)
	{
		ProcessFileNameInformation(recvbuf);
	}
	else if (k == 6)
	{
		printf("end block is called");
		strcpy(recvbuf, "$File Read Successfully#");
	}
	else if (k == 7)
	{
		DoFileProcessingInDatabase(recvbuf);
	}
	else if (k == 8)
	{
		SendBlock(recvbuf);
	}
	replyto_client(recvbuf, csock);
	replybuf[0] = '\0';
}
Exemplo n.º 6
0
void display_categories(FILE *fp, int *csock){

	char *data = (char *)malloc(sizeof(char) * 40);
	memset(data, '\0', 40);

	fseek(fp, 0, SEEK_SET);
	strcpy(data, "\n");
	struct category c;
	while (!feof(fp)){
		memset(&c, '\0', sizeof(c));
		fread(&c, sizeof(c), 1, fp);
		if (c.flag == 1){
			strcat(data, c.spec);
			strcat(data, "\n");
			printf("\n%d. %s", c.id, c.spec);
		}
	}
	
	replyto_client(data, csock);
}
Exemplo n.º 7
0
void display_persons(FILE *fp, int cid, int *csock){

	char *data = (char *)malloc(sizeof(char) * 40);
	memset(data, '\0', 40);
	strcpy(data, "\n");
	fseek(fp, 0, SEEK_SET);
	struct person p;
	while (!feof(fp)){
		memset(&p, '\0', sizeof(p));
		fread(&p, sizeof(p), 1, fp);
		if (p.flag == 2){
			if (p.category_id == cid){
				strcat(data, p.name);
				strcat(data, p.specialization);
				strcat(data, "\n");
				printf("\n%d. %s - %s", p.person_id, p.name, p.specialization);
			}
		}
	}
	replyto_client(data, csock);
}