// File: jkingan[P]ladyheather/heathgps.cpp
// Function: get_json_field(char*)
char *get_json_field(char *s)
{
int i;
char c;
int quote;

   // gets the next item from a JSON message

   i = 0;
   msg_field[i] = 0;
   quote = 0;
   json_delim = 0;
   if(s == 0) return 0;

  
if(*s == '{') {
   ++s;
   msg_field[0] = 0;
   return s;
}
if(*s == '[') {
   ++s;
   msg_field[0] = 0;
   return s;
}
  

   while(i < (NMEA_MSG_SIZE-2)) {
      c = *s++;
      if(c == 0) return 0;

      if(quote == 0) {
         if(c == ' ') continue;    // ignore white space
         if(c == '\t') continue;
         if(c == 0x0D) continue;
         if(c == 0x0A) continue;
         if(c == '[') {
//if(*s != '{') continue;
//            continue;
         }
         if(c == ']') continue;
         if(c == '{') continue;
         if(c == '}') continue;

         if(c == ':') {
            json_delim = c;
            break;
         }
         else if(c == '}') {
            json_delim = c;
            break;
         }
         else if(c == ',') {
            json_delim = c;
            break;
         }
         else if(c == '[') {
            json_delim = c;
            break;
         }
else if(c == '{') {
   json_delim = c;
   break;
}
         else if(c == ']') {
            json_delim = c;
            break;
         }
      }

      msg_field[i++] = c;  // add char to field
      msg_field[i] = 0;

      if(c == '"') {
         if(quote) {    // end of quoted string
            quote = 0;
         }
         else {         // start of quoted string
            quote = 1;
         }
      }
   }

   if(s) strupr(s);
   return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x2b8fe2(%rip), %rax    # 0x39ac20
movb $0x0, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
movb $0x0, 0x2ef5b8(%rip)    # 0x3d1208
cmpq $0x0, -0x10(%rbp)
jne 0xe1c64
movq $0x0, -0x8(%rbp)
jmp 0xe1e5e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0xe1c93
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
leaq 0x2b8f9d(%rip), %rax    # 0x39ac20
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe1e5e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xe1cc2
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
leaq 0x2b8f6e(%rip), %rax    # 0x39ac20
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe1e5e
jmp 0xe1cc4
cmpl $0x1fe, -0x14(%rbp)     # imm = 0x1FE
jge 0xe1e46
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %al
movb %al, -0x15(%rbp)
movsbl -0x15(%rbp), %eax
cmpl $0x0, %eax
jne 0xe1cfb
movq $0x0, -0x8(%rbp)
jmp 0xe1e5e
cmpl $0x0, -0x1c(%rbp)
jne 0xe1df6
movsbl -0x15(%rbp), %eax
cmpl $0x20, %eax
jne 0xe1d10
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0x9, %eax
jne 0xe1d1b
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0xd, %eax
jne 0xe1d26
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0xa, %eax
jne 0xe1d31
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0x5b, %eax
jne 0xe1d3c
jmp 0xe1d3c
movsbl -0x15(%rbp), %eax
cmpl $0x5d, %eax
jne 0xe1d4a
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0x7b, %eax
jne 0xe1d58
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0x7d, %eax
jne 0xe1d66
jmp 0xe1cc4
movsbl -0x15(%rbp), %eax
cmpl $0x3a, %eax
jne 0xe1d7d
movb -0x15(%rbp), %al
movb %al, 0x2ef490(%rip)     # 0x3d1208
jmp 0xe1e46
movsbl -0x15(%rbp), %eax
cmpl $0x7d, %eax
jne 0xe1d94
movb -0x15(%rbp), %al
movb %al, 0x2ef479(%rip)     # 0x3d1208
jmp 0xe1e46
movsbl -0x15(%rbp), %eax
cmpl $0x2c, %eax
jne 0xe1dab
movb -0x15(%rbp), %al
movb %al, 0x2ef462(%rip)     # 0x3d1208
jmp 0xe1e46
movsbl -0x15(%rbp), %eax
cmpl $0x5b, %eax
jne 0xe1dc2
movb -0x15(%rbp), %al
movb %al, 0x2ef44b(%rip)     # 0x3d1208
jmp 0xe1e46
movsbl -0x15(%rbp), %eax
cmpl $0x7b, %eax
jne 0xe1dd6
movb -0x15(%rbp), %al
movb %al, 0x2ef434(%rip)     # 0x3d1208
jmp 0xe1e46
movsbl -0x15(%rbp), %eax
cmpl $0x5d, %eax
jne 0xe1dea
movb -0x15(%rbp), %al
movb %al, 0x2ef420(%rip)     # 0x3d1208
jmp 0xe1e46
jmp 0xe1dec
jmp 0xe1dee
jmp 0xe1df0
jmp 0xe1df2
jmp 0xe1df4
jmp 0xe1df6
movb -0x15(%rbp), %dl
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %eax, %rcx
leaq 0x2b8e12(%rip), %rax    # 0x39ac20
movb %dl, (%rax,%rcx)
movslq -0x14(%rbp), %rcx
leaq 0x2b8e04(%rip), %rax    # 0x39ac20
movb $0x0, (%rax,%rcx)
movsbl -0x15(%rbp), %eax
cmpl $0x22, %eax
jne 0xe1e41
cmpl $0x0, -0x1c(%rbp)
je 0xe1e38
movl $0x0, -0x1c(%rbp)
jmp 0xe1e3f
movl $0x1, -0x1c(%rbp)
jmp 0xe1e41
jmp 0xe1cc4
cmpq $0x0, -0x10(%rbp)
je 0xe1e56
movq -0x10(%rbp), %rdi
callq 0x9890
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)