tuxedo中间件C程序 找不到错误,编译总语法错误,各位大虾帮找找
程序目的是想通过命令行读取一个文件:hwt 29 18677150924
lht 28 13398813422
csq 25 13234234564
以fml32格式发送到服务器,服务器返回结果会多一列:
hwt 29 18677150924 1
lht 28 13398813422 2
csq 25 13234234564 3
现在程序就是想发送后接收并打印结果。程序有点长,很多函数库可能大家不清楚,不过现在卡在C语言语法上了,编译不通过,而且我找了很久找不到原因,希望有强人能帮看看 谢谢!
程序代码:#include <stdio.h>
#include <string.h>
#include "atmi.h"
#include "fml32.h"
#include "userlog.h"
#include "fmlfile.h"
struct tlr{
char name[10];
long age;
char phone[12];
};
struct tlr2{
char name[10];
long age;
char phone[12];
long no;
};
int main(int argc, char *argv[])
{
if(argc!=2){
(void)fprintf(stderr,"usage:%s filename\n",argv[0]);
(void)exit(1);
}
FBFR32 *pF32,*pF32rec;
long len;
FLDLEN32 len2;
int counter,i,ret;
FILE *fp;
char *str1;
if (tpinit((TPINIT *)NULL) == -1) {
(void)fprintf(stderr, "Failed to join application -- %s\n",
tpstrerror(tperrno));
(void)userlog("Clientfml failed to join application -- %s\n",
tpstrerror(tperrno));
(void)exit(1);
}
if ((pF32 = (FBFR32 *)tpalloc("FML32", NULL, Fneeded32(1,30))) == NULL) {
(void)fprintf(stderr, "Failure to allocate FML32 buffer -- %s\n",
tpstrerror(tperrno));
(void)userlog("Clientfml failed to allocate FML32 buffer -- %s\n",
tpstrerror(tperrno));
(void)tpterm();
(void)exit(1);
}
if ((pF32rec = (FBFR32 *)tpalloc("FML32", NULL, Fneeded32(1,32))) == NULL) {
(void)fprintf(stderr, "Failure to allocate FML32 buffer -- %s\n",
tpstrerror(tperrno));
(void)userlog("Clientfml failed to allocate FML32 buffer -- %s\n",
tpstrerror(tperrno));
(void)tpterm();
(void)exit(1);
}
struct tlr ptlr[3];
struct tlr2 ptlr2[3];
fp=fopen(argv[1],"r");
if(fp==NULL){
(void)fprintf(stderr,"%s: file no found!\n",argv[1]);
(void)exit(1);
}
while(fgets(str1,100,fp)!=NULL){
if((ret=sscanf(str1, "%s %ld %s", ptlr[i].name, &ptlr[i].age, ptlr[i].phone))<3){
(void)fprintf(stderr,"error in calling sscanf():%d\n",ret);
(void)exit(1);
}
}
for(i=0;i<3;i++){
if (Fadd32(pF32,name, (char *)ptlr[i].name, 0) == -1) {
(void)fprintf(stderr, "Failure to change name field -- %s\n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to change name field -- %s\n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
if (Fadd32(pF32,age, (char *)&ptlr[i].age, 0) == -1) {
(void)fprintf(stderr, "Failure to change age field -- %s\n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to change age field -- %s\n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
if (Fadd32(pF32,phone, (char *)ptlr[i].phone, 0) == -1) {
(void)fprintf(stderr, "Failure to change phone field -- %s\n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to change phone field -- %s\n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
}
if (tpcall("FMLTEST", (char *)pF32, 0, (char **)&pF32rec, &len,0) == -1) {
(void)fprintf(stderr, "Failure to call the FMLTEST service -- %s \n",
tpstrerror(tperrno));
(void)userlog("Clientfml failed to call the FMLTEST service -- %s \n",
tpstrerror(tperrno));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
for(i=0;i<3;i++){
len2=10;
if (Fget32(pF32rec, name, i, (char *)ptlr2[i].name, &len2) == -1) {
(void)fprintf(stderr, "Failure to call get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
len2=sizeof(long);
if (Fget32(pF32rec, age, i, (char *)&ptlr2[i].age, &len2) == -1) {
(void)fprintf(stderr, "Failure to call get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
len2=12;
if (Fget32(pF32rec, phone, i, (char *)ptlr2[i].phone, &len2) == -1) {
(void)fprintf(stderr, "Failure to call get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
len2=sizeof(long);
if (Fget32(pF32rec, no, i, (char *)&ptlr2[i].no, &len2) == -1) {
(void)fprintf(stderr, "Failure to call get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)userlog("Clientfml failed to get the result field -- %s \n",
Fstrerror32(Ferror32));
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
(void)exit(1);
}
(void)fprintf(stdout,"%s %ld %s %ld\n",ptlr2[i].name,ptlr2[i].age,
ptlr2[i].phone,ptlr2[i].no);
}
(void)tpfree((char *)pF32);
(void)tpfree((char *)pF32rec);
(void)tpterm();
return(0);
}
[hwt@localhost fml]$ buildclient -o clientfml -f clientfml.c
clientfml.c:9: error: syntax error before numeric constant
clientfml.c:9: warning: no semicolon at end of struct or union
clientfml.c:10: error: syntax error before numeric constant
clientfml.c:11: error: syntax error before numeric constant
clientfml.c:15: error: syntax error before numeric constant
clientfml.c:15: warning: no semicolon at end of struct or union
clientfml.c:16: error: syntax error before numeric constant
clientfml.c:17: error: syntax error before numeric constant
clientfml.c:18: error: syntax error before numeric constant
clientfml.c: In function `main':
clientfml.c:63: error: storage size of 'ptlr' isn't known
clientfml.c:64: error: storage size of 'ptlr2' isn't known
clientfml.c:72: error: syntax error before '(' token
clientfml.c: At top level:
clientfml.c:78: error: syntax error before "for"
clientfml.c:139: warning: data definition has no type or storage class
clientfml.c:140: error: syntax error before "if"
clientfml.c:150: error: redefinition of 'len2'
clientfml.c:139: error: previous definition of 'len2' was here
clientfml.c:150: warning: data definition has no type or storage class
clientfml.c:151: error: syntax error before "if"
clientfml.c:161: error: redefinition of 'len2'
clientfml.c:150: error: previous definition of 'len2' was here
clientfml.c:161: error: redefinition of 'len2'
clientfml.c:150: error: previous definition of 'len2' was here
clientfml.c:161: warning: data definition has no type or storage class
clientfml.c:162: error: syntax error before "if"
CMDTUX_CAT:512: ERROR: Cannot execute C compiler cc -I$TUXDIR/include -o clientfml -L${TUXDIR}/lib clientfml.c -ltux -lbuft -lfml -lfml32 -lengine -ldl -lpthread /usr/lib/libcrypt.a








