// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x2cf5(%rip), %rsi      # 0x1711f
movq %r15, %rdi
callq 0x3520
testq %rax, %rax
je 0x1468b
movq %rax, %r14
movq %rax, %rdi
callq 0x3360
testl %eax, %eax
jne 0x145f7
leaq -0x1(%rsp), %r12
movq %rsp, %r15
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x32e0
testq %rax, %rax
je 0x145e7
callq 0x3660
movq (%rax), %rax
movq %r12, %r13
movsbq 0x1(%r13), %rcx
incq %r13
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x1447a
movzbl %cl, %eax
testl %eax, %eax
je 0x145e7
cmpl $0x23, %eax
je 0x145e7
movq %r13, %rdi
movl $0x3d, %esi
callq 0x31d0
testq %rax, %rax
je 0x145e7
movq %rax, %rbp
movl $0xc, %edx
movq %r13, %rdi
leaq 0x3581(%rip), %rsi      # 0x17a46
callq 0x33f0
testl %eax, %eax
je 0x14584
movl $0x9, %edx
movq %r13, %rdi
leaq 0x3572(%rip), %rsi      # 0x17a53
callq 0x33f0
testl %eax, %eax
je 0x14594
movl $0xb, %edx
movq %r13, %rdi
leaq 0x3560(%rip), %rsi      # 0x17a5d
callq 0x33f0
testl %eax, %eax
je 0x145a5
movl $0xd, %edx
movq %r13, %rdi
leaq 0x3550(%rip), %rsi      # 0x17a69
callq 0x33f0
testl %eax, %eax
je 0x145b6
movl $0x8, %edx
movq %r13, %rdi
leaq 0x3543(%rip), %rsi      # 0x17a78
callq 0x33f0
testl %eax, %eax
je 0x145c7
movl $0x9, %edx
movq %r13, %rdi
leaq 0x3530(%rip), %rsi      # 0x17a81
callq 0x33f0
testl %eax, %eax
je 0x145d8
movb $0x0, (%rbp)
movq %r13, %rdi
callq 0x1438a
movq %rax, %r13
incq %rbp
movq %rbp, %rdi
callq 0x1438a
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x142c0
jmp 0x145e7
incq %rbp
movq %rbp, %rdi
callq 0x143e6
movq %rax, (%rbx)
jmp 0x145e7
incq %rbp
movq %rbp, %rdi
callq 0x143e6
movq %rax, 0x8(%rbx)
jmp 0x145e7
incq %rbp
movq %rbp, %rdi
callq 0x143e6
movq %rax, 0x10(%rbx)
jmp 0x145e7
incq %rbp
movq %rbp, %rdi
callq 0x143e6
movq %rax, 0x18(%rbx)
jmp 0x145e7
incq %rbp
movq %rbp, %rdi
callq 0x143e6
movq %rax, 0x20(%rbx)
jmp 0x145e7
incq %rbp
movq %rbp, %rdi
callq 0x143e6
movq %rax, 0x28(%rbx)
movq %r14, %rdi
callq 0x3360
testl %eax, %eax
je 0x14456
movq %r14, %rdi
callq 0x3160
movq 0x20(%rbx), %r14
movq %r14, %rdi
callq 0x3180
testl %eax, %eax
jle 0x14679
leal 0x1(%rax), %r15d
movl %eax, %r12d
cmpb $0x2f, (%r14,%r12)
je 0x1462d
leal -0x1(%r12), %eax
decq %r15
cmpl $0x1, %r12d
jg 0x14613
jmp 0x14679
movq %r15, %rdi
callq 0x33e0
movq %rax, %r13
movq %rax, 0x48(%rbx)
movq %r14, %rdi
callq 0x3180
subq %r12, %rax
leaq 0x1(%rax), %rdi
callq 0x33e0
movq %rax, %rbp
movq %rax, 0x50(%rbx)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x30b0
addq %r15, %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x30e0
movb $0x0, (%r13,%r12)
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x3a61