// File: jkingan[P]ladyheather/heather.cpp
// Function: config_program(int, char**)
int config_program(int argc, char *argv[])
{
int i;
int j;
int add_path;
int error;
char path[1024+1];

   set_defaults();     // initialize global variables

   add_path = 0;
   j = 0;
   path[j] = 0;

#ifdef WINDOWS
      strcpy(help_path, &argv[0][0]);
#else  // __linux__  __MACH__  __FreeBSD__
   strcpy(path, argv[0]);
   strcpy(help_path, basename(path));
   if(strstr(help_path,"luxor")) {
//    luxor = 2;
   }

   // get program name (help path) and executable path (heather_path)
   #ifdef __MACH__
      char temp[1024+1];
      j = sizeof(temp);
      i = _NSGetExecutablePath(temp, (unsigned int *) &j);
      if(i == 0) {
         realpath(path, temp);
      }
   #else
      i = readlink("/proc/self/exe", path, sizeof(path));
   #endif

   if(i < 0) readlink("/proc/curproc/file", path, sizeof(path));
   if(i < 0) readlink("/proc/self/path/a.out", path, sizeof(path));
   if(i >= 0) {
      strcpy(heather_path, dirname(path));
      strcat(heather_path, "/");
   }
   add_path = 1;
#endif

   // Look for /hd option for setting the home directory
   // We need to do this before looking for all the other files
   // and so we have to do it before other option parsing. We'll
   // call a special routine to do this one thing for us.

    option_handle_hd(argc, argv);

	printf("excecutable path:%s\n", heather_path);  // zork - show_debug_info
	printf("program:%s\n", help_path);

   find_sound_files();

   read_config_file(help_path, 1, add_path);  // process options from default config file
   read_config_file(help_path, 2, add_path);  // process calendar file

   for(i=1; i<argc; i++) {          // process the command line
      if((argv[i][0] == '/') || (argv[i][0] == '-') || (argv[i][0] == '=') || (argv[i][0] == '$')) {
         error = option_switch(argv[i]);
      }
      else error = 1;

      if(error) {
         command_help("on command line: ", argv[i], help_path);
         return 1;
//qqq    exit(10);
      }
   }

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x29f50
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movslq -0x18(%rbp), %rax
movb $0x0, -0x430(%rbp,%rax)
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x9350
leaq -0x430(%rbp), %rdi
callq 0x9680
movq %rax, %rsi
leaq 0x370326(%rip), %rdi    # 0x39d920
callq 0x9350
leaq 0x37031a(%rip), %rdi    # 0x39d920
leaq 0x142741(%rip), %rsi    # 0x16fd4e
callq 0x9090
cmpq $0x0, %rax
je 0x2d61a
jmp 0x2d61a
leaq -0x430(%rbp), %rsi
leaq 0x143eb5(%rip), %rdi    # 0x1714dd
movl $0x401, %edx            # imm = 0x401
callq 0x93b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x2d653
leaq -0x430(%rbp), %rsi
leaq 0x143ea3(%rip), %rdi    # 0x1714ec
movl $0x401, %edx            # imm = 0x401
callq 0x93b0
cmpl $0x0, -0x14(%rbp)
jge 0x2d671
leaq -0x430(%rbp), %rsi
leaq 0x143e98(%rip), %rdi    # 0x1714ff
movl $0x401, %edx            # imm = 0x401
callq 0x93b0
cmpl $0x0, -0x14(%rbp)
jl 0x2d6a5
leaq -0x430(%rbp), %rdi
callq 0x9110
movq %rax, %rsi
leaq 0x1a27e3(%rip), %rdi    # 0x1cfe70
callq 0x9350
leaq 0x1a27d7(%rip), %rdi    # 0x1cfe70
leaq 0x1428c8(%rip), %rsi    # 0x16ff68
callq 0x96a0
movl $0x1, -0x1c(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x2d4a0
leaq 0x143e56(%rip), %rdi    # 0x171515
leaq 0x1a27aa(%rip), %rsi    # 0x1cfe70
movb $0x0, %al
callq 0x9030
leaq 0x143e56(%rip), %rdi    # 0x17152a
leaq 0x370245(%rip), %rsi    # 0x39d920
movb $0x0, %al
callq 0x9030
callq 0x9ba0
movl -0x1c(%rbp), %eax
leaq 0x37022f(%rip), %rdi    # 0x39d920
movl $0x1, %esi
movzbl %al, %edx
callq 0x29920
movl -0x1c(%rbp), %eax
leaq 0x370218(%rip), %rdi    # 0x39d920
movl $0x2, %esi
movzbl %al, %edx
callq 0x29920
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2d7d3
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x2d778
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x2d778
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
je 0x2d778
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x2d78e
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x46ed0
movl %eax, -0x20(%rbp)
jmp 0x2d795
movl $0x1, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x2d7c3
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x143d88(%rip), %rdi    # 0x171536
leaq 0x37016b(%rip), %rdx    # 0x39d920
callq 0x29e30
movl $0x1, -0x4(%rbp)
jmp 0x2d7da
jmp 0x2d7c5
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2d71c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
nopw %cs:(%rax,%rax)