// File: mh0fm4[P]SCDC/test/units/dataprov_hook/hook_cli.c
// Function: main
int main(int argc, char *argv[])
{
  scdc_dataprov_t dp_hook = SCDC_DATAPROV_NULL;

  scdc_dataset_t dataset = SCDC_DATASET_NULL;

#define OPTARG_MAX  256
  char scheme[OPTARG_MAX] = { '\0' }, authority[OPTARG_MAX] = { '\0' }, open[OPTARG_MAX] = { '\0' }, cmdline[OPTARG_MAX] = { '\0' };


  printf(PREFIX "start hook demo client\n");

#if 0
  strcpy(scheme, "scdc");
  strcpy(authority, "");
#elif 1
  strcpy(scheme, "scdc+uds");
  strcpy(authority, "");
#elif 1
  strcpy(scheme, "scdc+tcp");
  strcpy(authority, "localhost");
#endif
  strcpy(open, "hookdemo/");
  strcpy(cmdline, "ls");

  scdc_init(SCDC_INIT_DEFAULT);

  dp_hook = scdc_dataprov_open("hookdemo", "hook:id", &hook, 0x2501);

  if (strlen(scheme) > 0 || strlen(authority) > 0 || strlen(open) > 0)
  {
    char uri[1024];

    sprintf(uri, "%s://%s/%s", scheme, authority, open);

    printf(PREFIX "uri: '%s'\n", uri);

    dataset = scdc_dataset_open(uri);
  }

  printf(PREFIX "dataset: %p\n", dataset);

  do_dataset_cmd(dataset, cmdline);

  scdc_dataset_close(dataset);

  scdc_dataprov_close(dp_hook);

  scdc_release();

  printf(PREFIX "quit hook demo client\n");

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x820, %rsp            # imm = 0x820
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0xc350
leaq -0x220(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0xc350
leaq -0x320(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0xc350
leaq -0x420(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0xc350
leaq 0x7c5a1(%rip), %rdi     # 0x8a0ad
movb $0x0, %al
callq 0xcd10
leaq -0x120(%rbp), %rdi
leaq 0x7c5ae(%rip), %rsi     # 0x8a0cf
callq 0xc600
leaq -0x220(%rbp), %rdi
leaq 0x7cf6b(%rip), %rsi     # 0x8aa9f
callq 0xc600
leaq -0x320(%rbp), %rdi
leaq 0x7c591(%rip), %rsi     # 0x8a0d8
callq 0xc600
leaq -0x420(%rbp), %rdi
leaq 0x7d4d1(%rip), %rsi     # 0x8b02b
callq 0xc600
leaq 0x7cf39(%rip), %rdi     # 0x8aa9f
movb $0x0, %al
callq 0xe680
leaq 0x7c56e(%rip), %rdi     # 0x8a0e2
leaq 0x7c570(%rip), %rsi     # 0x8a0eb
leaq 0xa3f9e(%rip), %rdx     # 0xb1b20
movl $0x2501, %ecx           # imm = 0x2501
movb $0x0, %al
callq 0xebb0
movq %rax, -0x18(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xc280
cmpq $0x0, %rax
ja 0xdbc8
leaq -0x220(%rbp), %rdi
callq 0xc280
cmpq $0x0, %rax
ja 0xdbc8
leaq -0x320(%rbp), %rdi
callq 0xc280
cmpq $0x0, %rax
jbe 0xdc19
leaq -0x820(%rbp), %rdi
leaq -0x120(%rbp), %rdx
leaq -0x220(%rbp), %rcx
leaq -0x320(%rbp), %r8
leaq 0x7c508(%rip), %rsi     # 0x8a0f3
movb $0x0, %al
callq 0xc0f0
leaq -0x820(%rbp), %rsi
leaq 0x7c4fe(%rip), %rdi     # 0x8a0fe
movb $0x0, %al
callq 0xcd10
leaq -0x820(%rbp), %rdi
movb $0x0, %al
callq 0xf8a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x7c4ef(%rip), %rdi     # 0x8a113
movb $0x0, %al
callq 0xcd10
movq -0x20(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0xd920
movq -0x20(%rbp), %rdi
callq 0xf970
movq -0x18(%rbp), %rdi
callq 0xec80
callq 0xe830
leaq 0x7c4d1(%rip), %rdi     # 0x8a12a
movb $0x0, %al
callq 0xcd10
xorl %eax, %eax
addq $0x820, %rsp            # imm = 0x820
popq %rbp
retq
nopl (%rax,%rax)