// File: /workspace/github_c_makefile_star2_O1/hkshenSmart[P]ONVIF-discovery_cs/discovery-nvc.c
// Function: main
int main(int argc, char *argv[])
{
    //struct soap discovery_soap; 
    struct soap *soap; 
    int result = 0; 
	struct d__ProbeType req;
	struct d__ProbeMatchesType resp;
	struct d__ScopesType sScope;
	struct SOAP_ENV__Header header;                             //soap header
	int count = 0;
//	struct SOAP_ENV__Header header;
	char guid_string[100];
    //uuid_t uuid;
    
    //soap_init(&discovery_soap); 
    //soap = &discovery_soap; 


    soap = soap_new();                                           //init soap
    if(soap==NULL)
        return -1;

    ////////////////////////////////////////////////////////////////////////////
    // discovery test
	//uuid_generate(uuid);
    //uuid_unparse(uuid, guid_string);

//    soap_omode(soap, SOAP_IO_FLUSH|SOAP_IO_STORE);
    soap_set_namespaces(soap, namespaces); 
	//����5����û�����ݾ��˳�
	soap->recv_timeout = 5;

	soap_default_SOAP_ENV__Header(soap, &header);                            //init soap header
	header.wsa__MessageID = guid_string;
	header.wsa__To = "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
	header.wsa__Action = "http://schemas.xmllocal_soap.org/ws/2005/04/discovery/Probe";
	soap->header = &header;                                                  //bind the soap header for transport                                     

 	soap_default_d__ScopesType(soap, &sScope);
	sScope.__item = "";
	//sScope.__item = "onvif://www.onvif.org";

 	soap_default_d__ProbeType(soap, &req);
	req.Scopes = &sScope;
	req.Types = "";
	//req.Types = "dn:NetworkVideoTransmitter";

	do
	{
		soap_call___dndl__Probe(soap, "soap.udp://239.255.255.250:3702/datagram", NULL, &req, &resp); 

		if (soap->error) { 
			printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); 
			result = soap->error; 
			break;
		} 
		else
		{
			printf("====================================================================\r\n");
				if(soap->header->wsa__MessageID)
					printf("MessageID   : %s\r\n", soap->header->wsa__MessageID);

				//if(soap->header->wsa__RelatesTo && soap->header->wsa__RelatesTo->__item)
					//printf("RelatesTo   : %s\r\n", soap->header->wsa__RelatesTo->__item);

				if(soap->header->wsa__To)
					printf("To          : %s\r\n", soap->header->wsa__To);

				if(soap->header->wsa__Action)
					printf("Action      : %s\r\n", soap->header->wsa__Action);
			printf("====================================================================\r\n");
				
			printf("soap_call___dndl__Probe __sizeProbeMatch=%d\r\n",resp.__sizeProbeMatch);
			printf("Target EP Address       : %s\r\n", resp.ProbeMatch[0].wsa__EndpointReference.Address);
			printf("Target Type             : %s\r\n", resp.ProbeMatch[0].Types);
			printf("Target Service Address  : %s\r\n", resp.ProbeMatch[0].XAddrs);
			printf("Target Metadata Version : %d\r\n", resp.ProbeMatch[0].MetadataVersion);
			printf("Target Scopes Address   : %s\r\n", resp.ProbeMatch[0].Scopes->__item);
			printf("====================================================================\r\n");
		}
	}while(0);

	soap_destroy(soap);                                                // remove deserialized class instances (C++ only)
	soap_end(soap);                                                    // clean up and remove deserialized data
    
    ////////////////////////////////////////////////////////////////////////////
//failed:
	soap_free(soap);                                                   //detach and free runtime context
	soap_done(soap);                                                   // detach context (last use and no longer in scope)

    return result; 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
callq 0x17c92
testq %rax, %rax
je 0x3550
movq %rax, %rbx
leaq 0x30d3d(%rip), %rsi     # 0x341c0
movq %rax, %rdi
callq 0x1a4ce
movl $0x5, 0x50(%rbx)
leaq 0x68(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3dc8
leaq 0xa0(%rsp), %rax
movq %rax, (%r14)
leaq 0x21b50(%rip), %rax     # 0x25004
movq %rax, 0x28(%r14)
leaq 0x21b72(%rip), %rax     # 0x25031
movq %rax, 0x30(%r14)
movq %r14, 0xbf30(%rbx)
leaq 0x28(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe429
leaq 0x2310d(%rip), %r12     # 0x265ee
movq %r12, (%r14)
leaq 0x40(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe2ab
movq %r14, 0x8(%r15)
movq %r12, (%r15)
leaq 0x21b6b(%rip), %rsi     # 0x2506d
movq %rsp, %r8
movq %rbx, %rdi
xorl %edx, %edx
movq %r15, %rcx
callq 0xfc18
movl 0x1f274(%rbx), %ebp
testl %ebp, %ebp
je 0x355a
movq %rbx, %rdi
callq 0x4044
movq (%rax), %r14
movq %rbx, %rdi
callq 0x40c7
movq (%rax), %rcx
leaq 0x21b5d(%rip), %rdi     # 0x25096
movl %ebp, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3140
movl 0x1f274(%rbx), %ebp
jmp 0x365d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x367f
leaq 0x21c4f(%rip), %rdi     # 0x251b0
callq 0x3090
movq 0xbf30(%rbx), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x3583
leaq 0x21b32(%rip), %rdi     # 0x250ae
xorl %eax, %eax
callq 0x3140
movq 0xbf30(%rbx), %rax
movq 0x28(%rax), %rsi
testq %rsi, %rsi
je 0x35a1
leaq 0x21b27(%rip), %rdi     # 0x250c1
xorl %eax, %eax
callq 0x3140
movq 0xbf30(%rbx), %rax
movq 0x30(%rax), %rsi
testq %rsi, %rsi
je 0x35bf
leaq 0x21b1c(%rip), %rdi     # 0x250d4
xorl %eax, %eax
callq 0x3140
leaq 0x21bea(%rip), %r14     # 0x251b0
movq %r14, %rdi
callq 0x3090
movl (%rsp), %esi
leaq 0x21b0f(%rip), %rdi     # 0x250e7
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x21b25(%rip), %rdi     # 0x25115
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rsi
leaq 0x21b2d(%rip), %rdi     # 0x25134
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rsi
leaq 0x21b35(%rip), %rdi     # 0x25153
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movl 0x58(%rax), %esi
leaq 0x21b3e(%rip), %rdi     # 0x25172
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rsi
leaq 0x21b43(%rip), %rdi     # 0x25191
xorl %eax, %eax
callq 0x3140
movq %r14, %rdi
callq 0x3090
movq %rbx, %rdi
xorl %esi, %esi
callq 0x18df1
movq %rbx, %rdi
callq 0x1ad6e
movq %rbx, %rdi
callq 0x17cbc
movq %rbx, %rdi
callq 0x152b6
movl %ebp, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)