📄 orderclt.c
字号:
#include <stdio.h>
#include "atmi.h" /* TUXEDO Header File */
#define MAXXMLDOCSIZE 4096 /* Max XML doc size */
main(int argc, char *argv[])
{
char *sendbuf, *rcvbuf;
long sendlen, rcvlen;
int ret;
FILE *xml_fd;
char xml_file[256];
char *xml_buffer;
int nsize;
if(argc != 2)
{
printf("Usage: %s <XML-doc-file>\n", argv[0]);
exit(1);
}
/* Read the XML document in first */
strcpy(xml_file, argv[1]);
if ((xml_fd = fopen(xml_file, "r")) == NULL)
{
perror("fopen(%s) fail\n", xml_file);
exit(1);
}
if ((xml_buffer = (char *)malloc(sizeof(char) * MAXXMLDOCSIZE)) == NULL)
{
printf("malloc failed for XML doc\n");
exit(1);
}
if ((nsize = fread(xml_buffer, sizeof(char), MAXXMLDOCSIZE, xml_fd)) < 0)
{
perror(fread(%s) fail\n",xml_file);
exit(1);
}
/* Attach to System/T as a Client Process */
if (tpinit((TPINIT *)NULL) == -1)
{
printf(tpinit() fail: %s\n", tpstrerror(tperrno));
exit(1);
}
/* Allocate XML buffers for the request and the reply */
sendlen = strlen(xml_buffer);
if((sendbuf = (char *) tpalloc("XML", NULL, sendlen+1)) == NULL)
{
fprintf(stderr,"Error allocating send buffer, tperrno=%ld\n",tperrno);
tpterm();
exit(1);
}
if((rcvbuf = (char *) tpalloc("XML", NULL, sendlen+1)) == NULL)
{
fprintf(stderr,"Error allocating receive buffer, tperrno=%ld\n",tperrno);
tpfree(sendbuf);
tpterm();
exit(1);
}
(void)strcpy(sendbuf, xml_buffer);
/* Request the service ORDERSVC, waiting for a reply */
ret = tpcall("ORDERSVC", (char *)sendbuf, sendlen, (char **)&rcvbuf, &rcvlen, 0);
if(ret == -1)
{
printf("tpcall(ORDERSVC) fail:%s",tpstrerror(tperrno));
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
exit(1);
}
printf("Returned string is: %s\n", rcvbuf);
/* Free Buffers & Detach from System/T */
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -