// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/config.c
// Function: parse_confg
void parse_confg(umConfig *config, char *cfgFile)
{
  FILE * fp ;
  char bufr[MAXCFGLINE];
  char *b_ptr;
  char *indx;

  if( (fp = fopen(cfgFile, "r")) != NULL){
    while(! feof(fp)){
      if (fgets(bufr, MAXCFGLINE, fp) != NULL)
      {
        b_ptr = &bufr[0];
        // Eat leading whitespace
        while(isspace(*b_ptr)) b_ptr++;
        if ( b_ptr[0] != '\0' && b_ptr[0] != '#')
        {
          indx = strchr(b_ptr, '=');  
          if ( indx != NULL) 
          {
            if (strncasecmp (b_ptr, "mqtt_address", 12) == 0) {
              config->mqtt_address = cleanalloc(indx+1);
            } else if (strncasecmp (b_ptr, "mqtt_user", 9) == 0) {
              config->mqtt_user = cleanalloc(indx+1);
            } else if (strncasecmp (b_ptr, "mqtt_passwd", 11) == 0) {
              config->mqtt_passwd = cleanalloc(indx+1);
            } else if (strncasecmp (b_ptr, "mqtt_pub_topic", 13) == 0) {
              config->mqtt_pub_topic = cleanalloc(indx+1);
            } else if (strncasecmp (b_ptr, "log_file", 8) == 0) {
              config->log_file_to_monitor = cleanalloc(indx+1);
            } else if (strncasecmp (b_ptr, "log_regex", 9) == 0) {
              config->regexString = cleanalloc(indx+1);
            } else {
              *indx = 0;
              addMotion(config, cleanwhitespace(b_ptr), cleanwhitespace(indx+1));
            }
          } 
        }
      }
    }
    fclose(fp);
  } else {
    fprintf(stderr, "ERROR reading config file '%s'\n%s\n", cfgFile,strerror (errno));
    exit (EXIT_FAILURE);
  }

  int i;

  for (i=strlen(config->log_file_to_monitor); i > 0; i--) {
    if (config->log_file_to_monitor[i] == '/') {
      config->watchDir = malloc(sizeof(char) * (i+1));
      config->watchFile = malloc(sizeof(char) * ( (strlen(config->log_file_to_monitor)-i)+1 ) );
      strncpy(config->watchDir, config->log_file_to_monitor, i);
      strcpy(config->watchFile, &config->log_file_to_monitor[i+1]);
      config->watchDir[i] = '\0';
      break;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x3689(%rip), %rsi      # 0x21107
callq 0x3560
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x1dd35
jmp 0x1da93
movq -0x18(%rbp), %rdi
callq 0x3390
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1daad
jmp 0x1dd2a
leaq -0x420(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x3310
cmpq $0x0, %rax
je 0x1dd25
leaq -0x420(%rbp), %rax
movq %rax, -0x428(%rbp)
callq 0x36a0
movq (%rax), %rax
movq -0x428(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x1db11
movq -0x428(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x428(%rbp)
jmp 0x1dada
movq -0x428(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x1dd23
movq -0x428(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
je 0x1dd23
movq -0x428(%rbp), %rdi
movl $0x3d, %esi
callq 0x31e0
movq %rax, -0x430(%rbp)
cmpq $0x0, -0x430(%rbp)
je 0x1dd21
movq -0x428(%rbp), %rdi
leaq 0x3ec3(%rip), %rsi      # 0x21a2e
movl $0xc, %edx
callq 0x3430
cmpl $0x0, %eax
jne 0x1db99
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1da10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1dd1f
movq -0x428(%rbp), %rdi
leaq 0x3e94(%rip), %rsi      # 0x21a3b
movl $0x9, %edx
callq 0x3430
cmpl $0x0, %eax
jne 0x1dbd6
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1da10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1dd1d
movq -0x428(%rbp), %rdi
leaq 0x3e61(%rip), %rsi      # 0x21a45
movl $0xb, %edx
callq 0x3430
cmpl $0x0, %eax
jne 0x1dc13
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1da10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1dd1b
movq -0x428(%rbp), %rdi
leaq 0x3e30(%rip), %rsi      # 0x21a51
movl $0xd, %edx
callq 0x3430
cmpl $0x0, %eax
jne 0x1dc50
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1da10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x1dd19
movq -0x428(%rbp), %rdi
leaq 0x3e02(%rip), %rsi      # 0x21a60
movl $0x8, %edx
callq 0x3430
cmpl $0x0, %eax
jne 0x1dc8d
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1da10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x1dd17
movq -0x428(%rbp), %rdi
leaq 0x3dce(%rip), %rsi      # 0x21a69
movl $0x9, %edx
callq 0x3430
cmpl $0x0, %eax
jne 0x1dcc7
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1da10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x1dd15
movq -0x430(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x428(%rbp), %rdi
callq 0x1d930
movq %rax, -0x440(%rbp)
movq -0x430(%rbp), %rdi
addq $0x1, %rdi
callq 0x1d930
movq -0x448(%rbp), %rdi
movq -0x440(%rbp), %rsi
movq %rax, %rdx
callq 0x1d7b0
jmp 0x1dd17
jmp 0x1dd19
jmp 0x1dd1b
jmp 0x1dd1d
jmp 0x1dd1f
jmp 0x1dd21
jmp 0x1dd23
jmp 0x1dd25
jmp 0x1da93
movq -0x18(%rbp), %rdi
callq 0x3160
jmp 0x1dd86
movq 0x92b4(%rip), %rax      # 0x26ff0
movq (%rax), %rax
movq %rax, -0x458(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x450(%rbp)
callq 0x3090
movl (%rax), %edi
callq 0x3650
movq -0x458(%rbp), %rdi
movq -0x450(%rbp), %rdx
movq %rax, %rcx
leaq 0x3cfe(%rip), %rsi      # 0x21a73
movb $0x0, %al
callq 0x3370
movl $0x1, %edi
callq 0x35f0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x3180
movl %eax, -0x434(%rbp)
cmpl $0x0, -0x434(%rbp)
jle 0x1de7e
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x434(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x1de68
movl -0x434(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x3420
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x3180
movq %rax, %rdi
movslq -0x434(%rbp), %rax
subq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x3420
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x434(%rbp), %rdx
callq 0x30a0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl -0x434(%rbp), %eax
addl $0x1, %eax
cltq
addq %rax, %rsi
callq 0x30d0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x434(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x1de7e
jmp 0x1de6a
movl -0x434(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x1dd99
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nopw (%rax,%rax)