// File: /workspace/github_c_makefile_star2_O3/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 0x27a5(%rip), %rsi      # 0x1713d
movq %r15, %rdi
callq 0x3520
testq %rax, %rax
je 0x14bf9
movq %rax, %r14
movq %rax, %rdi
callq 0x3360
testl %eax, %eax
jne 0x14b65
leaq -0x1(%rsp), %r12
movq %rsp, %r15
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x32e0
testq %rax, %rax
je 0x14b55
callq 0x3660
movq (%rax), %rax
movq %r12, %r13
movsbq 0x1(%r13), %rcx
incq %r13
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x149e8
movzbl %cl, %eax
testl %eax, %eax
je 0x14b55
cmpl $0x23, %eax
je 0x14b55
movq %r13, %rdi
movl $0x3d, %esi
callq 0x31d0
testq %rax, %rax
je 0x14b55
movq %rax, %rbp
movl $0xc, %edx
movq %r13, %rdi
leaq 0x3031(%rip), %rsi      # 0x17a64
callq 0x33f0
testl %eax, %eax
je 0x14af2
movl $0x9, %edx
movq %r13, %rdi
leaq 0x3022(%rip), %rsi      # 0x17a71
callq 0x33f0
testl %eax, %eax
je 0x14b02
movl $0xb, %edx
movq %r13, %rdi
leaq 0x3010(%rip), %rsi      # 0x17a7b
callq 0x33f0
testl %eax, %eax
je 0x14b13
movl $0xd, %edx
movq %r13, %rdi
leaq 0x3000(%rip), %rsi      # 0x17a87
callq 0x33f0
testl %eax, %eax
je 0x14b24
movl $0x8, %edx
movq %r13, %rdi
leaq 0x2ff3(%rip), %rsi      # 0x17a96
callq 0x33f0
testl %eax, %eax
je 0x14b35
movl $0x9, %edx
movq %r13, %rdi
leaq 0x2fe0(%rip), %rsi      # 0x17a9f
callq 0x33f0
testl %eax, %eax
je 0x14b46
movb $0x0, (%rbp)
movq %r13, %rdi
callq 0x148f8
movq %rax, %r13
incq %rbp
movq %rbp, %rdi
callq 0x148f8
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x147ec
jmp 0x14b55
incq %rbp
movq %rbp, %rdi
callq 0x14954
movq %rax, (%rbx)
jmp 0x14b55
incq %rbp
movq %rbp, %rdi
callq 0x14954
movq %rax, 0x8(%rbx)
jmp 0x14b55
incq %rbp
movq %rbp, %rdi
callq 0x14954
movq %rax, 0x10(%rbx)
jmp 0x14b55
incq %rbp
movq %rbp, %rdi
callq 0x14954
movq %rax, 0x18(%rbx)
jmp 0x14b55
incq %rbp
movq %rbp, %rdi
callq 0x14954
movq %rax, 0x20(%rbx)
jmp 0x14b55
incq %rbp
movq %rbp, %rdi
callq 0x14954
movq %rax, 0x28(%rbx)
movq %r14, %rdi
callq 0x3360
testl %eax, %eax
je 0x149c4
movq %r14, %rdi
callq 0x3160
movq 0x20(%rbx), %r14
movq %r14, %rdi
callq 0x3180
testl %eax, %eax
jle 0x14be7
leal 0x1(%rax), %r15d
movl %eax, %r12d
cmpb $0x2f, (%r14,%r12)
je 0x14b9b
leal -0x1(%r12), %eax
decq %r15
cmpl $0x1, %r12d
jg 0x14b81
jmp 0x14be7
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 0x3a22