// File: st0ne[P]XReflectorPlus/dxrfd.cpp
// Function: open_blocks(char*)
static int open_blocks(char *filename)
{
   FILE *fp = NULL;
   char inbuf[512];
   char *p = NULL;
   blocks_type::iterator pos;
   short int i;

   char *call_ptr;
   char call[9];
   const char *delim = " \t";

   fp = fopen(filename, "r");
   if (!fp)
   {
      traceit("Failed to open file %s\n", filename);
      return 1;
   }

   blocks.clear();

   traceit("Reading from file: [%s]\n", filename);
   while (fgets(inbuf, 511, fp) != NULL)
   {
      inbuf[511] = '\0';
      p = strchr(inbuf, '\r');
      if (p)
         *p = '\0';
      p = strchr(inbuf, '\n');
      if (p)
         *p = '\0';

      call_ptr = strtok(inbuf, delim);
      if (call_ptr)
      {
         if (strlen(call_ptr) <= 8)
         {
            memset(call, ' ', 9); call[8] = '\0';
            memcpy(call, call_ptr, strlen(call_ptr));

            for (i = 0; i < CALL_SIZE; i++)
            {
               if (call[i] == '_')
                  call[i] = ' ';
            }

            blocks.insert(call);
         }
      }
   }
   fclose(fp);

   traceit("BEGIN listing blocked callsigns...%d calls blocked\n", blocks.size());
   for (pos = blocks.begin(); pos != blocks.end(); pos++)
      traceit("--->[%s]\n", pos->c_str());
   traceit("END listing blocked callsigns\n");

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x228(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x13370
leaq 0x12a68(%rip), %rax     # 0x1743d
movq %rax, -0x258(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x127f9(%rip), %rsi     # 0x171e0
callq 0x3380
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4a15
movq -0x10(%rbp), %rsi
leaq 0x127e0(%rip), %rdi     # 0x171e2
movb $0x0, %al
callq 0x3820
movl $0x1, -0x4(%rbp)
jmp 0x4d2a
leaq 0x1a9c4(%rip), %rdi     # 0x1f3e0
callq 0x13390
movq -0x10(%rbp), %rsi
leaq 0x12a14(%rip), %rdi     # 0x17440
movb $0x0, %al
callq 0x3820
leaq -0x220(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x34b0
cmpq $0x0, %rax
je 0x4c66
movb $0x0, -0x21(%rbp)
leaq -0x220(%rbp), %rdi
movl $0xd, %esi
callq 0x3120
movq %rax, -0x228(%rbp)
cmpq $0x0, -0x228(%rbp)
je 0x4a82
movq -0x228(%rbp), %rax
movb $0x0, (%rax)
leaq -0x220(%rbp), %rdi
movl $0xa, %esi
callq 0x3120
movq %rax, -0x228(%rbp)
cmpq $0x0, -0x228(%rbp)
je 0x4aae
movq -0x228(%rbp), %rax
movb $0x0, (%rax)
leaq -0x220(%rbp), %rdi
movq -0x258(%rbp), %rsi
callq 0x34a0
movq %rax, -0x240(%rbp)
cmpq $0x0, -0x240(%rbp)
je 0x4c61
movq -0x240(%rbp), %rdi
callq 0x3150
cmpq $0x8, %rax
ja 0x4c5f
leaq -0x249(%rbp), %rdi
movl $0x20, %esi
movl $0x9, %edx
callq 0x31a0
movb $0x0, -0x241(%rbp)
leaq -0x249(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x240(%rbp), %rdi
callq 0x3150
movq -0x2c8(%rbp), %rdi
movq -0x2c0(%rbp), %rsi
movq %rax, %rdx
callq 0x3260
movw $0x0, -0x232(%rbp)
movswl -0x232(%rbp), %eax
cmpl $0x8, %eax
jge 0x4b97
movswq -0x232(%rbp), %rax
movsbl -0x249(%rbp,%rax), %eax
cmpl $0x5f, %eax
jne 0x4b81
movswq -0x232(%rbp), %rax
movb $0x20, -0x249(%rbp,%rax)
jmp 0x4b83
movw -0x232(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x232(%rbp)
jmp 0x4b50
leaq -0x279(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x3520
movq -0x2d0(%rbp), %rdx
leaq -0x278(%rbp), %rdi
leaq -0x249(%rbp), %rsi
callq 0x11f00
jmp 0x4bc6
leaq 0x1a813(%rip), %rdi     # 0x1f3e0
leaq -0x278(%rbp), %rsi
callq 0x133b0
movb %dl, -0x2d9(%rbp)
movq %rax, -0x2d8(%rbp)
jmp 0x4be8
movb -0x2d9(%rbp), %al
movq -0x2d8(%rbp), %rcx
movq %rcx, -0x2a0(%rbp)
movb %al, -0x298(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x31e0
leaq -0x279(%rbp), %rdi
callq 0x3330
jmp 0x4c5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x288(%rbp)
movl %eax, -0x28c(%rbp)
jmp 0x4c4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x288(%rbp)
movl %eax, -0x28c(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x31e0
leaq -0x279(%rbp), %rdi
callq 0x3330
jmp 0x4d36
jmp 0x4c61
jmp 0x4a33
movq -0x18(%rbp), %rdi
callq 0x32d0
leaq 0x1a76a(%rip), %rdi     # 0x1f3e0
callq 0x13400
movq %rax, %rsi
leaq 0x1281c(%rip), %rdi     # 0x174a1
movb $0x0, %al
callq 0x3820
leaq 0x1a74d(%rip), %rdi     # 0x1f3e0
callq 0x13420
movq %rax, -0x2a8(%rbp)
movq -0x2a8(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq 0x1a72c(%rip), %rdi     # 0x1f3e0
callq 0x13480
movq %rax, -0x2b0(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x13450
testb $0x1, %al
jne 0x4cd9
jmp 0x4d15
leaq -0x230(%rbp), %rdi
callq 0x134b0
movq %rax, %rdi
callq 0x3140
movq %rax, %rsi
leaq 0x127de(%rip), %rdi     # 0x174d5
movb $0x0, %al
callq 0x3820
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
callq 0x134d0
movq %rax, -0x2b8(%rbp)
jmp 0x4cad
leaq 0x127c3(%rip), %rdi     # 0x174df
movb $0x0, %al
callq 0x3820
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x288(%rbp), %rdi
callq 0x3500
nopw %cs:(%rax,%rax)