Commit 80827058 authored by SHAILESH KUMAR's avatar SHAILESH KUMAR

validation

parent 817896ef
makeserver: server.o client.o
gcc -o exec server.o client.o
server.o: server.c toxml.h jobs.h
gcc -c server.o server.c toxml.h jobs.h
client.o: client.c toxml.h jobs.h
gcc -c client.o client.c toxml.h jobs.h
No preview for this file type
...@@ -55,9 +55,29 @@ void sendXML(int sockfd,char *msg){ ...@@ -55,9 +55,29 @@ void sendXML(int sockfd,char *msg){
//printf("%s",key); //printf("%s",key);
} }
else{ else{
printf("error in command\n"); printf("ERROR: Unknown operation.\n");
return;
}
if(strlen(key)>256){
printf("ERROR: Key cannot exceed 256B\n");
return;
}
if(strlen(key)==0){
printf("ERROR: Key cannot be NULL\n");
return;
}
if(!strcmp(cmd,"PUT") && strlen(value)==0){
printf("ERROR: Value cannot be NULL\n");
return;
}
if(!strcmp(cmd,"PUT") && strlen(value)>(256*1024)){
printf("ERROR: Value cannot exceed 256KB\n");
return;
} }
toXML(encodedXML,key,value,msgtype,""); toXML(encodedXML,key,value,msgtype,"");
write(sockfd,strcat(encodedXML,delim),strlen(encodedXML)); write(sockfd,strcat(encodedXML,delim),strlen(encodedXML));
...@@ -113,6 +133,7 @@ int main(int argc, char *argv[]) ...@@ -113,6 +133,7 @@ int main(int argc, char *argv[])
//write(sockfd,line,read); //write(sockfd,line,read);
no_of_requests++; no_of_requests++;
sendXML(sockfd,line); sendXML(sockfd,line);
sleep(1);
} }
fclose(fp); fclose(fp);
......
...@@ -55,9 +55,29 @@ void sendXML(int sockfd,char *msg){ ...@@ -55,9 +55,29 @@ void sendXML(int sockfd,char *msg){
//printf("%s",key); //printf("%s",key);
} }
else{ else{
printf("error in command\n"); printf("ERROR: Unknown operation.\n");
return;
}
if(strlen(key)>256){
printf("ERROR: Key cannot exceed 256B");
return;
}
if(strlen(key)==0){
printf("ERROR: Key cannot be NULL");
return;
}
if(!strcmp(cmd,"PUT") && strlen(value)==0){
printf("ERROR: Value cannot be NULL");
return;
}
if(!strcmp(cmd,"PUT") && strlen(value)>(256*1024)){
printf("ERROR: Value cannot exceed 256KB");
return;
} }
toXML(encodedXML,key,value,msgtype,""); toXML(encodedXML,key,value,msgtype,"");
write(sockfd,strcat(encodedXML,delim),strlen(encodedXML)); write(sockfd,strcat(encodedXML,delim),strlen(encodedXML));
...@@ -113,6 +133,7 @@ int main(int argc, char *argv[]) ...@@ -113,6 +133,7 @@ int main(int argc, char *argv[])
//write(sockfd,line,read); //write(sockfd,line,read);
no_of_requests++; no_of_requests++;
sendXML(sockfd,line); sendXML(sockfd,line);
sleep(1);
} }
fclose(fp); fclose(fp);
......
...@@ -2,3 +2,6 @@ PUT hello world ...@@ -2,3 +2,6 @@ PUT hello world
GET hello GET hello
DEL hello DEL hello
GET hello GET hello
GET
PUT aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaapaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bjjbj
...@@ -2,3 +2,5 @@ PUT hello world ...@@ -2,3 +2,5 @@ PUT hello world
GET hello GET hello
DEL hello DEL hello
GET hello GET hello
GET
PUT aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bjjbj
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment