Beruflich Dokumente
Kultur Dokumente
***********************
FILE NAME:client_function.c
FILE DESCRIPTION:client function file which contais different fu
nctions used by client
to send user credentials,receive server acknowl
egdment and receive file content
REVISION HISTORY
DATE
NAME
10-MAR-2014
REFERENCE
REASON
NONE
PROJECT
Revision History
Copyright 2014,Aricent Group(Holdings) pvt,ltd
********************************************************************************
*********************/
/*******************************************************************************
********************
HEADER FILE INCLUSION
********************************************************************************
*******************/
#include"./../include/header.h"
/*******************************************************************************
**********************
FUNCTION NAME:input_login_credential
FUNCTION DESCRIPTION:Creates main interface for the user in whic
h username,password
and type of user is taken as arguments and
based on the type of
user and acknowledgment from the server oth
er functions are called
ARGUMENTS:soket descriptor
RETURN TYPE:SUCCESS if user credentials are successfully sent to
server
FAILURE if user credentials are not successfulyy sen
t to server
********************************************************************************
***********************/
int input_login_credential(int sd)
{
char username[MAX],type_user[CHOICE],buf[MAX];
char *password;
{
flag = 0;
chance ++;
printf("\nYou have entered wrong usernam
e and password...Try Again\n");
}
else
{
flag = 1;
ret = receive_from_server(sd);
if(FAILURE == ret)
{
printf("CLIENT:error in receivin
g from server");
}
break;
}
}
break;
default:
printf("\nt\t\t Wrong Choice !!!\n");
system("clear");
}/**end of switch**/
if(1 == flag)
{
break;
}
else if(0 == flag)
{
return ;
}
else
{
;
}
}/**end of while 1**/
return SUCCESS;
}
/*******************************************************************************
*****************
FUNCTION NAME:send_login_credential
FUNCTION DESCRIPTION:Writes user credentials onto the socket
pointer = pointer + n;
if(0 > n)
{
return FAILURE;
}
if('$' == buf[n-1])
{
buf[n-1] = '\0';
ret = write(1,buf,n-1);
if(0 > ret)
{
perror("\nError in writing into Monitor");
printf("%s",strerror(errno));
}
break;
}
ret = write(1,buf,n);
if(-1 == ret)
{
perror("\nError in writing into Monitor");
printf("%s",strerror(errno));
}
memset(buf,0,MAX);
pointer = 0;
}
return(SUCCESS);
}