// File: /workspace/github_c_makefile_star2_O2/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 0x1626c
testq %rax, %rax
je 0x3560
movq %rax, %rbx
leaq 0x2fd3d(%rip), %rsi     # 0x331d0
movq %rax, %rdi
callq 0x18502
movl $0x5, 0x50(%rbx)
leaq 0x68(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d8c
leaq 0xa0(%rsp), %rax
movq %rax, (%r14)
leaq 0x1eb40(%rip), %rax     # 0x22004
movq %rax, 0x28(%r14)
leaq 0x1eb62(%rip), %rax     # 0x22031
movq %rax, 0x30(%r14)
movq %r14, 0xbf30(%rbx)
leaq 0x28(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd8e1
leaq 0x200fd(%rip), %r12     # 0x235ee
movq %r12, (%r14)
leaq 0x40(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd76d
movq %r14, 0x8(%r15)
movq %r12, (%r15)
leaq 0x1eb5b(%rip), %rsi     # 0x2206d
movq %rsp, %r8
movq %rbx, %rdi
xorl %edx, %edx
movq %r15, %rcx
callq 0xefb8
movl 0x1f274(%rbx), %ebp
testl %ebp, %ebp
je 0x3568
movq %rbx, %rdi
callq 0x3fd1
movq (%rax), %r14
movq %rbx, %rdi
callq 0x404d
movq (%rax), %rcx
leaq 0x1eb4d(%rip), %rdi     # 0x22096
movl %ebp, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3140
movl 0x1f274(%rbx), %ebp
jmp 0x366b
pushq $-0x1
popq %rbp
jmp 0x368d
leaq 0x1ec41(%rip), %rdi     # 0x221b0
callq 0x3090
movq 0xbf30(%rbx), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x3598
leaq 0x1eb24(%rip), %rdi     # 0x220ae
xorl %eax, %eax
callq 0x3140
movq 0xbf30(%rbx), %rax
movq 0x28(%rax), %rsi
testq %rsi, %rsi
je 0x35b6
leaq 0x1eb19(%rip), %rdi     # 0x220c1
xorl %eax, %eax
callq 0x3140
movq 0xbf30(%rbx), %rax
movq 0x30(%rax), %rsi
testq %rsi, %rsi
je 0x35cd
leaq 0x1eb0e(%rip), %rdi     # 0x220d4
xorl %eax, %eax
callq 0x3140
leaq 0x1ebdc(%rip), %r14     # 0x221b0
movq %r14, %rdi
callq 0x3090
movl (%rsp), %esi
leaq 0x1eb01(%rip), %rdi     # 0x220e7
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x1eb17(%rip), %rdi     # 0x22115
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rsi
leaq 0x1eb1f(%rip), %rdi     # 0x22134
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rsi
leaq 0x1eb27(%rip), %rdi     # 0x22153
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movl 0x58(%rax), %esi
leaq 0x1eb30(%rip), %rdi     # 0x22172
xorl %eax, %eax
callq 0x3140
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rsi
leaq 0x1eb35(%rip), %rdi     # 0x22191
xorl %eax, %eax
callq 0x3140
movq %r14, %rdi
callq 0x3090
movq %rbx, %rdi
xorl %esi, %esi
callq 0x17147
movq %rbx, %rdi
callq 0x18d1c
movq %rbx, %rdi
callq 0x16296
movq %rbx, %rdi
callq 0x13e09
movl %ebp, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop