Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
key-value-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SHAILESH KUMAR
key-value-server
Commits
e0264b51
Commit
e0264b51
authored
Oct 03, 2019
by
SHAILESH KUMAR
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toxml.c updated
parent
d8d388a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
0 deletions
+148
-0
client.c
client.c
+0
-0
server.c
server.c
+0
-0
toxml.h
toxml.h
+148
-0
toxml.h.gch
toxml.h.gch
+0
-0
No files found.
client.c
0 → 100644
View file @
e0264b51
server.c
0 → 100644
View file @
e0264b51
toxml.h
0 → 100644
View file @
e0264b51
#include<stdio.h>
#include<string.h>
void
fromXML
(
char
*
key
,
char
*
value
,
char
*
messagetype
,
char
*
message
,
char
*
xml
){
strcpy
(
key
,
""
);
strcpy
(
value
,
""
);
strcpy
(
message
,
""
);
strcpy
(
messagetype
,
""
);
int
i
;
char
tag
[
50
];
char
data
[
300000
];
strcpy
(
data
,
""
);
for
(
i
=
0
;
i
<
strlen
(
xml
);
i
++
){
if
(
xml
[
i
]
==
'<'
){
strcpy
(
tag
,
""
);
}
else
if
(
xml
[
i
]
==
'>'
){
if
(
tag
[
0
]
!=
'/'
){
//do nothing
}
}
else
{
char
a
[
2
];
a
[
0
]
=
xml
[
i
];
a
[
1
]
=
'\0'
;
if
(
!
strcmp
(
tag
,
"Key"
)){
strcat
(
key
,
a
);
}
else
if
(
!
strcmp
(
tag
,
"Value"
)){
strcat
(
value
,
a
);
}
else
if
(
!
strcmp
(
tag
,
"Message"
)){
strcat
(
message
,
a
);
}
else
if
(
!
strcmp
(
tag
,
"type"
)){
if
(
strcmp
(
a
,
"
\"
"
)
&&
strcmp
(
a
,
"="
)
)
strcat
(
messagetype
,
a
);
}
else
{
if
(
xml
[
i
]
==
' '
){
strcpy
(
tag
,
""
);
}
else
{
strcat
(
tag
,
a
);
}
}
}
}
}
void
toXML
(
char
*
resp
,
char
key
[],
char
value
[],
char
messagetype
[],
char
message
[]){
strcpy
(
resp
,
""
);
char
temp
[
300000
]
=
""
;
char
*
tempo
=
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?><KVMessage type=
\"
"
;
strcat
(
temp
,
tempo
);
strcat
(
temp
,
messagetype
);
strcat
(
temp
,
"
\"
>"
);
if
(
strcmp
(
key
,
""
)){
strcat
(
temp
,
"<Key>"
);
strcat
(
temp
,
key
);
strcat
(
temp
,
"</Key>"
);
if
(
strcmp
(
value
,
""
)){
strcat
(
temp
,
"<Value>"
);
strcat
(
temp
,
value
);
strcat
(
temp
,
"</Value>"
);
}
}
else
{
strcat
(
temp
,
"<Message>"
);
strcat
(
temp
,
message
);
strcat
(
temp
,
"</Message>"
);
}
strcat
(
temp
,
"</KVMessage>"
);
strcat
(
resp
,
temp
);
}
/*
int main() {
//code
char x[]="hello";
char y[]="world";
char resp[300000];
toXML(resp,x,"","getreq","success");
//printf("%s\n",resp);
strcpy(resp,"");
toXML(resp,x,y,"putreq","success");
char ix[300];
char iy[300000];
char msg[10];
fromXML(ix,iy,msg,resp);
if(strcmp(ix,"")){
printf("key=%s\n",ix);
}
if(strcmp(iy,"")){
printf("value=%s\n",iy);
}
if(strcmp(msg,"")){
printf("msg=%s\n",msg);
}
/*toXML(x,"","delreq","success");
toXML(x,y,"resp","success");
toXML("",y,"resp","success");
toXML("",y,"resp","failure");
toXML(resp,"","","resp","success");
fromXML(ix,iy,msg,resp);
if(strcmp(ix,"")){
printf("key=%s\n",ix);
}
if(strcmp(iy,"")){
printf("value=%s\n",iy);
}
if(strcmp(msg,"")){
printf("msg=%s\n",msg);
}
toXML(resp,"","","resp","success");
fromXML(ix,iy,msg,resp);
if(strcmp(ix,"")){
printf("key=%s\n",ix);
}
if(strcmp(iy,"")){
printf("value=%s\n",iy);
}
if(strcmp(msg,"")){
printf("msg=%s\n",msg);
}
return 0;
}*/
toxml.h.gch
0 → 100644
View file @
e0264b51
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment