⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 symbol2.c

📁 linux下开发的soap协议。建议大家学习学习!
💻 C
📖 第 1 页 / 共 5 页
字号:
voidcopyrightnote(FILE *fd, char *fn){ fprintf(fd, "/* %s\n   Generated by the gSOAP Stub and Skeleton Compiler for C and C++ "VERSION"\n   Copyright (C) 2001-2002 Robert A. van Engelen, Florida State University.\n   All rights reserved.\n*/", fn);}voidcompile(Table *table){	Entry *p;	char *s;	char base[1024];	char soapStub[1024];	char soapH[1024];	char soapC[1024];	char soapClient[1024];	char soapServer[1024];	char soapMsg[1024];    	DBGLOG(fprintf(stderr,"\n IN dumptable."));	typeNO = 0;	s = "";	if (*dirpath && *(s = dirpath+strlen(dirpath)-1) != '/' && *s != '\\')#ifdef WIN32			s = "\\";#else			s = "/";#endif	strcpy(base, dirpath);	strcat(base, s);	strcat(base, prefix);	if (cflag)		s = ".c";	else		s = ".cpp";	strcpy(soapStub, base);	strcat(soapStub, "Stub.h");	strcpy(soapH, base);	strcat(soapH, "H.h");	strcpy(soapC, base);	strcat(soapC, "C");	strcat(soapC, s);	strcpy(soapClient, base);	strcat(soapClient, "Client");	strcat(soapClient, s);	strcpy(soapServer, base);	strcat(soapServer, "Server");	strcat(soapServer, s);	strcpy(soapMsg, base);	strcat(soapMsg, "Msg");	strcat(soapMsg, s);	fprintf(stderr, "Saving %s\n", soapStub);	fheader=fopen(soapStub, "w");	if (!fheader)		execerror("Cannot write to file");	copyrightnote(fheader, soapStub);	fprintf(stderr, "Saving %s\n", soapH);	fhead=fopen(soapH,"w");	if (!fhead)		execerror("Cannot write to file");	copyrightnote(fhead, soapH);	fprintf(stderr, "Saving %s\n", soapC);	fout=fopen(soapC,"w");	if (!fout)		execerror("Cannot write to file");	copyrightnote(fout, soapC);	fprintf(stderr, "Saving %s\n", soapClient);        fclient=fopen(soapClient,"w");	if (!fclient)		execerror("Cannot write to file");	copyrightnote(fclient, soapClient);	fprintf(stderr, "Saving %s\n", soapServer);        fserver=fopen(soapServer,"w");	if (!fserver)		execerror("Cannot write to file");	copyrightnote(fserver, soapServer);	fprintf(fhead,"\n#ifndef %sH_H\n#define %sH_H", prefix, prefix);	fprintf(fhead,"\n#include \"stdsoap2.h\"");	fprintf(fhead,"\n#include \"%sStub.h\"", prefix);	if (cflag)	  fprintf(fhead,"\n#ifdef __cplusplus\nextern \"C\" {\n#endif");	fprintf(fheader,"\n#ifndef %sStub_H\n#define %sStub_H", prefix, prefix);	if (cflag)	  fprintf(fheader,"\n#ifdef __cplusplus\nextern \"C\" {\n#endif");	generate_header(table);	generate_schema(table);	fprintf(fout,"\n#include \"%sH.h\"", prefix);	if (cflag)	  fprintf(fout,"\n#ifdef __cplusplus\nextern \"C\" {\n#endif");        fprintf(fclient,"\n#include \"%sH.h\"", prefix);	if (cflag)	  fprintf(fclient,"\n#ifdef __cplusplus\nextern \"C\" {\n#endif");        fprintf(fserver,"\n#include \"%sH.h\"", prefix);	if (cflag)	  fprintf(fserver,"\n#ifdef __cplusplus\nextern \"C\" {\n#endif");	DBGLOG(fprintf(stderr,"\n Calling function_input_output( )."));        function_input_output(table);	DBGLOG(fprintf(stderr,"\n Completed function_input_output( )."));        if (entry(classtable, lookup("SOAP_ENV__Header"))->info.typ->type == Tstruct)	  fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_serializeheader(struct soap *soap)\n{\n\tsoap_serialize_SOAP_ENV__Header(soap, soap->header);\n}");	else	  fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_serializeheader(struct soap *soap)\n{\n\tif (soap->header)\n\t\tsoap->header->soap_serialize(soap);\n}");	fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_putheader(struct soap *soap)\n{\n\tif (soap->header)\n\t{\tsoap->is_in_header = 1;\n\t\tsoap_out_SOAP_ENV__Header(soap, \"SOAP-ENV:Header\", 0, soap->header, NULL);\n\t\tsoap->is_in_header = 0;\n\t}\n}");	fprintf(fout,"\n\nSOAP_FMAC1 int SOAP_FMAC2 soap_getheader(struct soap *soap)\n{\n\tsoap->is_in_header = 1;\n\tsoap->header = soap_get_SOAP_ENV__Header(soap, NULL, \"SOAP-ENV:Header\", NULL);\n\tsoap->is_in_header = 0;\n\treturn soap->header == NULL;\n}");        if (entry(classtable, lookup("SOAP_ENV__Fault"))->info.typ->type == Tstruct)	{ fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_fault(struct soap *soap)\n{\n\tif (!soap->fault)\n\t{\tsoap->fault = (struct SOAP_ENV__Fault*)soap_malloc(soap, sizeof(struct SOAP_ENV__Fault));\n\t\tsoap_default_SOAP_ENV__Fault(soap, soap->fault);\n\t}\n}");	  fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_serializefault(struct soap *soap)\n{\n\tsoap_serialize_SOAP_ENV__Fault(soap, soap->fault);\n}");	}	else	{ fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_fault(struct soap *soap)\n{\n\tif (!soap->fault)\n\t{\tsoap->fault = soap_new_SOAP_ENV__Fault(soap, -1);\n\t\tsoap->fault->soap_default(soap);\n\t}\n}");	  fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_serializefault(struct soap *soap)\n{\n\tif (soap->fault)\n\t\tsoap->fault->soap_serialize(soap);\n}");	}	fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_putfault(struct soap *soap)\n{\n\tsoap_out_SOAP_ENV__Fault(soap, \"SOAP-ENV:Fault\", 0, soap->fault, NULL);\n}");	fprintf(fout,"\n\nSOAP_FMAC1 int SOAP_FMAC2 soap_getfault(struct soap *soap)\n{\n\treturn (soap->fault = soap_get_SOAP_ENV__Fault(soap, NULL, \"SOAP-ENV:Fault\", NULL)) == NULL;\n}");	fprintf(fout,"\n\nSOAP_FMAC1 const char ** SOAP_FMAC2 soap_faultcode(struct soap *soap)\n{\n\tsoap_fault(soap);\n\treturn (const char**)&soap->fault->faultcode;\n}");	fprintf(fout,"\n\nSOAP_FMAC1 const char ** SOAP_FMAC2 soap_faultstring(struct soap *soap)\n{\n\tsoap_fault(soap);\n\treturn (const char**)&soap->fault->faultstring;\n}");	fprintf(fout,"\n\nSOAP_FMAC1 const char ** SOAP_FMAC2 soap_faultdetail(struct soap *soap)\n{\n\tsoap_fault(soap);\n\treturn (const char**)&soap->fault->detail;\n}");	fprintf(fout,"\n\nSOAP_FMAC1 int SOAP_FMAC2 soap_getindependent(struct soap *soap)\n{");	fprintf(fout,"\n\tfor (;;)");        fprintf(fout,"\n\t{\tif (soap_peek_element(soap) || !*soap->id)\n\t\t\tbreak;");	fprintf(fout,"\n\t\tswitch (soap_lookup_type(soap, soap->id))\n\t\t{");	DBGLOG(fprintf(stderr,"\n Calling in_defs( )."));	in_defs(table);	DBGLOG(fprintf(stderr,"\n Completed in_defs( )."));        fprintf(fout,"\n\t\tdefault:");	in_defs2(table);        fprintf(fout,"\n\t\t}");        fprintf(fout,"\n\t\tif (soap->error)\n\t\t\tbreak;");        fprintf(fout,"\n\t}");        fprintf(fout,"\n\tif (soap->error == SOAP_NO_TAG)");        fprintf(fout,"\n\t\tsoap->error = SOAP_OK;");        fprintf(fout,"\n\treturn soap->error;");        fprintf(fout,"\n}");	fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_putindependent(struct soap *soap)\n{\n\tint i;\n\tstruct soap_plist *pp;");	fprintf(fout,"\n\tif (soap->enable_embedding || soap->disable_href)\n\t\treturn;");	fprintf(fout,"\n\tfor (i = 0; i < SOAP_PTRHASH; i++)");	fprintf(fout,"\n\t\tfor (pp = soap->pht[i]; pp; pp = pp->next)");	fprintf(fout,"\n\t\t\tif (soap->counting ? pp->mark1 == 2 : pp->mark2 == 2)");	fprintf(fout,"\n\t\t\t\tswitch (pp->type & 0x3FF)\n\t\t\t\t{");        out_defs(table);	fprintf(fout,"\n\t\t\t\t}\n\t\t\n\t\n}");	fprintf(fout,"\n\nSOAP_FMAC1 int SOAP_FMAC2 soap_getattachments(struct soap *soap)\n{");	fprintf(fout,"\n\tif (!soap->dime)\n\t\treturn SOAP_OK;");	fprintf(fout,"\n\twhile (soap->dime_flags&SOAP_DIME_CF)\n\t{\tif (soap_getdimehdr(soap))\n\t\t\treturn soap->error;\n\t\tif (soap_move(soap, soap->dime_size))\n\t\t\treturn soap->error = SOAP_EOF;\n\t}");	fprintf(fout,"\n\tif (soap_move(soap, ((soap->dime_size+3)&-4)-soap_tell(soap)))\n\t\treturn soap->error = SOAP_EOF;");	fprintf(fout,"\n\tfor (;;)");        fprintf(fout,"\n\t{\tif (soap_getdime(soap) || !soap->dime_id)\n\t\t\tbreak;");	fprintf(fout,"\n\t\tswitch (soap_lookup_type(soap, soap->dime_id))\n\t\t{");        in_attach(table);        fprintf(fout,"\n\t\tdefault:\n\t\t\tsoap->error = SOAP_DIME_ERROR;");        fprintf(fout,"\n\t\t}");        fprintf(fout,"\n\t\tif (soap->error)\n\t\t\tbreak;");        fprintf(fout,"\n\t}");        fprintf(fout,"\n\tif (soap->error == SOAP_EOD)");        fprintf(fout,"\n\t\tsoap->error = SOAP_OK;");        fprintf(fout,"\n\treturn soap->error;");        fprintf(fout,"\n}");	fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_putattachments(struct soap *soap)\n{\n\tint i;\n\tstruct soap_plist *pp;");	fprintf(fout,"\n\tif (!soap->dime)\n\t\treturn;");	fprintf(fout,"\n\tsoap_send_raw(soap, \"\\0\\0\\0\", -(int)soap->count&3);");	fprintf(fout,"\n\tfor (i = 0; i < SOAP_PTRHASH; i++)");	fprintf(fout,"\n\t\tfor (pp = soap->pht[i]; pp; pp = pp->next)");	fprintf(fout,"\n\t\t\tif (pp->mark2 == 3)");	fprintf(fout,"\n\t\t\t\tswitch (pp->type & 0x3FF)\n\t\t\t\t{");        out_attach(table);	fprintf(fout,"\n\t\t\t\t}\n\t\t\n\t\n}");	fprintf(fout,"\n\nSOAP_FMAC1 void * SOAP_FMAC2 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType)\n{\n\tswitch (t)\n\t{");	if (classtable)	  for (p = classtable->list; p; p = p->next)	    if (p->info.typ->type == Tclass && !is_transient(p->info.typ))	      fprintf(fout,"\n\tcase SOAP_%s:\n\t\treturn (void*)soap_instantiate_%s(soap, -1, type, arrayType);", p->info.typ->id->name, p->info.typ->id->name);	fprintf(fout,"\n\t}\n\treturn NULL;\n}");	fprintf(fout,"\n\nSOAP_FMAC1 void SOAP_FMAC2 soap_delete(struct soap *soap, void *p, int t, int n)\n{\n\tswitch (t)\n\t{");	if (classtable)	  for (p = classtable->list; p; p = p->next)	    if (p->info.typ->type == Tclass && !is_transient(p->info.typ))	    { fprintf(fout,"\n\tcase SOAP_%s:\n\t\tDBGLOG(TEST, SOAP_MESSAGE(fdebug, \"\\nsoap_delete(%s, %%d)\", n));", c_type(p->info.typ), c_type(p->info.typ));	      fprintf(fout,"\n\t\tif (n<0)\n\t\t\tdelete (%s*)p;\n\t\telse\n\t\t\tdelete[] (%s*)p;\n\t\tbreak;", c_ident(p->info.typ), c_type(p->info.typ), c_type(p->info.typ));	    }	fprintf(fout,"\n\t}\n}");	DBGLOG(fprintf(stderr,"\n Calling xml_def_table( )."));        xml_def_table(table,0);	DBGLOG(fprintf(stderr,"\n Completed xml_def_table( )."));	if (cflag)	  fprintf(fout,"\n#ifdef __cplusplus\n}\n#endif");	fprintf(fout, "\n\n/* end of %s */\n", soapC);        fclose(fout);	if (cflag)	  fprintf(fhead,"\n#ifdef __cplusplus\n}\n#endif");	fprintf(fhead, "\n#endif");	fprintf(fhead, "\n\n/* end of %s */\n", soapH);	fclose(fhead);	if (cflag)	  fprintf(fheader,"\n#ifdef __cplusplus\n}\n#endif");	fprintf(fheader, "\n#endif");	fprintf(fheader, "\n\n/* end of %s */\n", soapStub);	fclose(fheader);	if (cflag)	  fprintf(fclient,"\n#ifdef __cplusplus\n}\n#endif");	fprintf(fclient, "\n\n/* end of %s */\n", soapClient);        fclose(fclient);	if (cflag)	  fprintf(fserver,"\n#ifdef __cplusplus\n}\n#endif");	fprintf(fserver, "\n\n/* end of %s */\n", soapServer); 	fclose(fserver);}voidgen_class(FILE *fd, Tnode *typ){ Table *Tptr;  Entry *Eptr;  char *x = xsi_type(typ);  typ->generated = True;  if (is_hexBinary(typ))    fprintf(fheader, "/* hexBinary schema type: */\n");  else if (is_binary(typ))    fprintf(fheader, "/* Base64 schema type: */\n");  else if (is_primclass(typ))    fprintf(fheader, "/* Primitive %s schema type: */\n", x);  else if (is_dynamic_array(typ))    if (has_ns(typ) || is_untyped(typ))      fprintf(fheader, "/* Vector %s schema type: */\n", x);    else      fprintf(fheader, "/* Array of %s schema type: */\n", x);  else if (is_transient(typ) && typ->ref)    fprintf(fheader, "/* transient: */\n");  else if (!strcmp(typ->id->name, "SOAP_ENV__Header"))    fprintf(fheader, "/* SOAP Header: */\n#ifndef WITH_NOHEADER\n#define WITH_NOHEADER\n");  else if (!strcmp(typ->id->name, "SOAP_ENV__Fault"))    fprintf(fheader, "/* SOAP Fault: */\n#ifndef WITH_NOFAULT\n#define WITH_NOFAULT\n");  if (typ->type == Tstruct)  { { DBGLOG(fprintf(stderr,"\nstruct %s\n", typ->id->name));      if (typ->ref)      { fprintf(fd, "struct %s\n{", typ->id->name );        for (Eptr = ((Table*)typ->ref)->list; Eptr; Eptr = Eptr->next)        { fprintf(fd, "\n\t%s", c_storage(Eptr->info.sto));	  if (Eptr->info.typ->type == Tclass && Eptr->info.typ->generated == False || Eptr->info.typ->ref && ((Tnode*)Eptr->info.typ->ref)->type == Tclass && ((Tnode*)Eptr->info.typ->ref)->generated == False)	    fprintf(fd, "class ");          fprintf(fd, "%s;", c_type_id(Eptr->info.typ,Eptr->sym->name));	  if (Eptr->info.sto & Sconst)	    fprintf(fd, "\t/* const field cannot be deserialized */");	  else if (is_transient(Eptr->info.typ))	    fprintf(fd, "\t/* transient */");	  else if (Eptr->info.sto & SmustUnderstand)	    fprintf(fd, "\t/* mustUnderstand */");	  if (!is_dynamic_array(typ) && !is_primclass(typ))	  { if (!strncmp(Eptr->sym->name, "__size", 6))	    { if (!Eptr->next || Eptr->next->info.typ->type != Tpointer)              { sprintf(errbuf, "Field '%s' with leading __ not followed by a pointer field in struct '%s'", Eptr->sym->name, typ->id->name);                semwarn(errbuf);	      }	    }	    else if (!strncmp(Eptr->sym->name, "__", 2))            { sprintf(errbuf, "Field '%s' with leading __ not used in array or binary type struct '%s'", Eptr->sym->name, typ->id->name);              semwarn(errbuf);	    }	  }	}        fprintf(fd, "\n};");      }      else if (strcmp(typ->id->name, "soap"))      { sprintf(errbuf, "struct '%s' is empty", typ->id->name);        semwarn(errbuf);      }    }  }  else  { DBGLOG(fprintf(stderr,"\nclass %s\n", typ->id->name));    if (typ->ref)    { fprintf(fd,"class SOAP_CMAC %s", typ->id->name );      Tptr =  ((Table *)typ->ref);      if(Tptr->prev)        fprintf(fd," : public %s", Tptr->prev->sym->name);        fprintf(fd,"\n{ public:");      for (Eptr = ((Table*)typ->ref)->list; Eptr; Eptr = Eptr->next)      { fprintf(fd,"\n\t%s", c_storage(Eptr->info.sto));	if (Eptr->info.typ->type == Tclass && Eptr->info.typ->generated == False || Eptr->info.typ->ref && ((Tnode*)Eptr->info.typ->ref)->type == Tclass && ((Tnode*)Eptr->info.typ->ref)->generated == False)	  fprintf(fd, "class ");	fprintf(fd,"%s", c_type_id(Eptr->info.typ,Eptr->sym->name));	if (Eptr->info.sto & Sconstobj)	  fprintf(fd, " const;");	if (Eptr->info.sto & Sabstract)	  fprintf(fd, " = 0;");	else	  fprintf(fd, ";");	if (Eptr->info.sto & Sconst)	  fprintf(fd, "\t/* const field cannot be deserialized */");	else if (is_transient(Eptr->info.typ))	  fprintf(fd, "\t/* transient */");	else if (Eptr->info.sto & SmustUnderstand)	  fprintf(fd, "\t/* mustUnderstand */");	if (!is_dynamic_array(typ) && !is_primclass(typ))	{ if (!strncmp(Eptr->sym->name, "__size", 6))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -