Exemplo n.º 1
0
Elf32_Shdr *
elf_find_section_named(char *name)
{
  Elf32_Shdr *section;
  Elf32_Shdr *strtab_section;
  Elf32_Word sectionsize;
  int numsections;
  char *strtab;
  int i = 0;

  section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));

  strtab_section = elf_find_section_num(read_half(elf_header->e_shstrndx));
  
  strtab = (char *)FILE_OFFSET(read_word(strtab_section->sh_offset));
  
  sectionsize = read_half(elf_header->e_shentsize);
  numsections = read_half(elf_header->e_shnum);

  for (i=0;i<numsections;i++) {
    if (strcmp(&strtab[read_word(section->sh_name)], name) == 0) {
      return section;
    }
    section = (Elf32_Shdr *)((char *)section + sectionsize);
  }
  return NULL;
}
Exemplo n.º 2
0
void packet_2(char *buffer,int *offset,int *flag) {
  /* display information contained within packet 2: Write Special Symbol (no value) */
  short length;
  int i;

  printf("Packet 2: Write Special Symbols (No Value) Summary Information\n");

  length=read_half(buffer,offset);
  printf("Length of Data Block (in bytes) = %hd\n",length);
  printf("I Starting Point: %hd\n",read_half(buffer,offset));
  printf("J Starting Point: %hd\n",read_half(buffer,offset));

  length-=4;
  /*printf("length of packet 2 string=%d\n",length);*/
  printf("Message Begins at next line:\n");

  for(i=0;i<length;i++) {
    unsigned char c;

    c=read_byte(buffer,offset);
    printf("%c",c);
    }

  printf("\n");
  printf("Message Complete\n");
  }
Exemplo n.º 3
0
Elf32_Word
vma_to_offset(Elf32_Addr addr)
{
  Elf32_Shdr *section;
  Elf32_Shdr *higher;
  Elf32_Word sectionsize;
  int numsections;
  int i = 0;

  section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));
  sectionsize = read_half(elf_header->e_shentsize);
  numsections = read_half(elf_header->e_shnum);

  higher = NULL;

  for (i=0;i<numsections;i++) {
    if ( (addr >= read_word(section->sh_addr)) &&
	 (addr < read_word(section->sh_addr) + read_word(section->sh_size)) ) {
      return read_word(section->sh_offset) + (addr - read_word(section->sh_addr));
    }
    
    section = (Elf32_Shdr *)((char *)section + sectionsize);
  }

  fprintf(stderr, "Warning, unable to convert address %d (0x%x) to file offset\n",
	 addr, addr);
  return 0;
}
Exemplo n.º 4
0
Elf32_Shdr *
elf_find_next_higher_section(Elf32_Word offset)
{
  Elf32_Shdr *section;
  Elf32_Shdr *higher;
  Elf32_Word sectionsize;
  int numsections;
  int i = 0;

  section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));
  sectionsize = read_half(elf_header->e_shentsize);
  numsections = read_half(elf_header->e_shnum);

  higher = NULL;

  for (i=0;i<numsections;i++) {
    if (read_word(section->sh_offset) >= offset) {
      if (higher == NULL) {
	higher = section;
      } else if (read_word(section->sh_offset) < read_word(higher->sh_offset)) {
	higher = section;
      }
    }
    
    section = (Elf32_Shdr *)((char *)section + sectionsize);
  }
  
  return higher;
}
Exemplo n.º 5
0
void packet_7(char *buffer,int *offset) {
  /* display information contained within packet 7 */
  short length; /* color_level; */
  int i,num_vectors;

  printf("\nPacket 7: Unlinked Vector Packet (No Value)\n");

  length=read_half(buffer,offset);
  printf("Packet 7 Length of Data Block (in bytes) = %hd\n",length);
     
  /*length-=2;  account for the color&length values */
  num_vectors=length/8;
  printf("Number of Vectors to Plot: %d\n",num_vectors);
  for(i=0;i<num_vectors;i++) {
    short begI,begJ,endI,endJ;
    
    begI=read_half(buffer,offset);
    begJ=read_half(buffer,offset);
    endI=read_half(buffer,offset);
    endJ=read_half(buffer,offset);
    
    printf("Vector %04d: BegI %5hd BegJ %5hd EndI %5hd EndJ %5hd\n",
      i+1,begI,begJ,endI,endJ);
    }
       
  printf("Packet 7 Complete\n");
  }
Exemplo n.º 6
0
void
find_segment_addr_min_max(Elf32_Word file_offset,
			  Elf32_Addr *start, Elf32_Addr *end)
{
  Elf32_Phdr *segment;
  Elf32_Word segmentsize;
  int numsegments;
  int i = 0;

  segment = (Elf32_Phdr *)FILE_OFFSET(read_word(elf_header->e_phoff));
  segmentsize = read_half(elf_header->e_phentsize);
  numsegments = read_half(elf_header->e_phnum);

  for (i=0;i<numsegments;i++) {
    if ((file_offset >= read_word(segment->p_offset)) &&
	(file_offset < read_word(segment->p_offset) + read_word(segment->p_filesz)))  {
      *start = read_word(segment->p_vaddr);
      *end = read_word(segment->p_vaddr) + read_word(segment->p_memsz);
      return;
    }

    segment = (Elf32_Phdr *)((char *)segment + segmentsize);
  }
  fprintf(stderr, "Error: Couldn't find segment in find_segment_addr_min_max()\n");
}
Exemplo n.º 7
0
void display_packet_23(int packet,int offset) 
{
    short length;
    int end_offset;
    
    offset += 2;
    length=read_half(sd->icd_product, &offset);

    if(verbose_flag) {
        printf("\nPacket 23: SCIT / MDA Position Data\n");
    printf("Length of Data Block (in bytes) = %hd\n",length);
    }

    end_offset = length+offset;
    /* packet codes 2, 6 or 25 follow */
    while(offset<end_offset) {
      int pcode, len;
      /* grab packet code and length of embedded packet */
      pcode = read_half(sd->icd_product, &offset);
      len = read_half(sd->icd_product, &offset);
      
      /* send off the embedded packet to get displayed and update the offset*/
      /* COULD BE Packet 2, Packet6, or Packet 25 */
      dispatch_packet_type(pcode, offset-4, TRUE);
      offset += len;
      
    } /* end while */
    
    
}
Exemplo n.º 8
0
void packet_20(char *buffer,int *offset) {
    /* display information contained within packet 3 */
    short length,ipos,jpos,type,attribute;
    int i,num=0;

    printf("\nPacket 20: Generic Point Feature\n");

    length=read_half(buffer,offset);
    num=length/8;    
    printf("Packet 20: Length=%4hd  Number Included=%hd\n",
      length,num);
      

    
    /* in this packet there are 4 fields (8 bytes) to be 
    written for each symbol */
    
    for(i=0;i<num;i++) {
      ipos=read_half(buffer,offset);
      jpos=read_half(buffer,offset);
      type=read_half(buffer,offset);
      attribute=read_half(buffer,offset);
      
      printf("  I Pos: %4hd  J Pos: %4hd  Feature Type: %hd  Attribute: %hd\n",
         ipos,jpos,type,attribute);
         
      }
    printf("\n");
   
  }
Exemplo n.º 9
0
void packet_3501(char *buffer,int *offset) {
  /* display information contained within packet 3501 */
  short length;
  short I_start,J_start,I_end,J_end;
  int i,count=1;

  printf("\nPacket 0x3501: Linked Vectors\n");

  length=read_half(buffer,offset);         /* Length of Vectors (multiples of 4)     */
  
  printf("Length of Data Block (in bytes) = %hd or (0x%04x)  Number of Vectors: %d\n",length,
    length,length/8);

  for(i=0;i<=length/8;i++) {
    
    I_start=read_half(buffer,offset);        /* I Coordinate for vector starting point */
    J_start=read_half(buffer,offset);        /* J Coordinate for vector starting point */    
    I_end=read_half(buffer,offset);          /* I Coordinate for vector end point      */
    J_end=read_half(buffer,offset);          /* J Coordinate for vector end point      */

    printf("I Vector %4i   Start: %hd (0x%04x)   End: %hd (0x%04x)\n",count,I_start,I_start,
      I_end,I_end);
    printf("J Vector %4i   Start: %hd (0x%04x)   End: %hd (0x%04x)\n",count,J_start,J_start,
      J_end,J_end);
    
    count++;
    }

  printf("packet 0x3501 complete\n");
  }
Exemplo n.º 10
0
void packet_23(char *buffer,int *offset) {
  /* display information contained within packet 23 */
  short length;
/*  int i,num=0; */

  printf("\nPacket 23: SCIT Past Position Data\n");
  length=read_half(buffer,offset);
  printf("Length of Data Block (in bytes) = %hd\n",length);
  /* packet codes 2, 6 or 25 follow */
  }
Exemplo n.º 11
0
void packet_17(char *buffer,int *offset,int *flag) {
    /* display information contained within packet 17 */
    short spare,boxes,rows,numbytes;
    int i,j;
    int k;
    unsigned char run;
    unsigned char level;

    printf("Packet 17: Digital Precipitation Data Array Packet\n");
    spare=read_half(buffer,offset);
    spare=read_half(buffer,offset);
    boxes=read_half(buffer,offset);
    printf("Number of LFM Boxes in Row = %hd\n",boxes );
    rows=read_half(buffer,offset);
    printf("Number of Rows = %hd\n",rows);

    for(i=0; i<rows; i++) {
        numbytes=read_half(buffer,offset);
        printf("Number of Bytes in Row %d = %hd\n",i+1,numbytes);

        k=0;

        for(j=0; j<numbytes/2; j++) {
            run = (unsigned char) read_byte(buffer,offset);
            level = (unsigned char) read_byte(buffer,offset);
            /*  report pre-build 8 byte swap error */
            if((i==0) && (j==0) && (run==255))
                printf("Linux DPA Error, the Run and Level values are reversed in packet 17.\n");
            printf("Run(%03hd) Level(%03hd)  ", run, level);
            if(k==2) {
                printf("\n");
                k=0;
            } else {
                k++;
            }
        }
        printf("\n");
    }

    printf("\n");
    printf("Message 17 Complete\n");

}
Exemplo n.º 12
0
Elf32_Shdr *
elf_find_section(Elf32_Word sh_type)
{
  Elf32_Shdr *section;
  Elf32_Word sectionsize;
  int numsections;
  int i = 0;

  section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));
  sectionsize = read_half(elf_header->e_shentsize);
  numsections = read_half(elf_header->e_shnum);

  for (i=0;i<numsections;i++) {
    if (read_word(section->sh_type) == sh_type) {
      return section;
    }
    section = (Elf32_Shdr *)((char *)section + sectionsize);
  }
  return NULL;
}
Exemplo n.º 13
0
void packet_13(char *buffer,int *offset) {
  /* display information contained within packet 13 */
  short length;
  int i,num=0;

    printf("\nPacket 13: Hail Positive (Filled)\n");

    length=read_half(buffer,offset);
    printf("Length of Data Block (in bytes) = %hd\n",length);
    num=length/4;
    
    /* in this packet there are 2 fields (4 bytes) to be 
    written for each symbol */
    
    for(i=0;i<num;i++) {
      printf("I Position: %hd\n",read_half(buffer,offset));
      printf("J Position: %hd\n",read_half(buffer,offset));
      }
    printf("\n");
   
  }
Exemplo n.º 14
0
void packet_26(char *buffer,int *offset) {
  /* display information contained within packet 26 */
  short length;
  int i,num=0;

    printf("\nPacket 26: Elevated Tornado Vortex Signature\n");

    length=read_half(buffer,offset);
    printf("Length of Data Block (in bytes) = %hd\n",length);
    num=length/4;
    
    /* in this packet there are 2 fields (4 bytes) to be 
    written for each symbol */
    
    for(i=0;i<num;i++) {
      printf("I Position: %hd\n",read_half(buffer,offset));
      printf("J Position: %hd\n",read_half(buffer,offset));
      }
    printf("\n");
   
  }
Exemplo n.º 15
0
void packet_5(char *buffer,int *offset) {
  /* display information contained within packet 4 */
  short length,icoord,jcoord,arrow_dir,arrow_len,head_len;
  int i, num=0; /* num_vectors; */

  printf("\nPacket 5: Vector Arrow Data Packet\n");

  length=read_half(buffer,offset);
  printf("Packet 5 Length of Data Block (in bytes) = %hd  (%04x hex)\n",
    length,length);
    
  num=length/10;
  printf("Number of Vector Arrows to Print: %d\n",num);
   
  for(i=0;i<num;i++) {
     icoord=read_half(buffer,offset);
     jcoord=read_half(buffer,offset);
     arrow_dir=read_half(buffer,offset);
     arrow_len=read_half(buffer,offset);
     head_len=read_half(buffer,offset);  
     printf("#%04d I Pos: %4hd  J Pos: %4hd  Arrow Dir: %3hd  Len: %hd  Head Len: %3hd\n",
        i+1,icoord,jcoord,arrow_dir,arrow_len,head_len);
    }     
  /* printf("\n"); */
  }
Exemplo n.º 16
0
Elf32_Shdr *
elf_find_section_num(int section_index)
{
  Elf32_Shdr *section;
  Elf32_Word sectionsize;

  section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));
  sectionsize = read_half(elf_header->e_shentsize);

  section = (Elf32_Shdr *)((char *)section + sectionsize*section_index);

  return section;
}
Exemplo n.º 17
0
void packet_15(char *buffer,int *offset,int *flag) {
  /* display information contained within packet 15 */
  short length,ipos,jpos;
  unsigned char a,b;
  int i,num;

  printf("\nPacket 15: Storm ID Data\n");

  length=read_half(buffer,offset);  /* length in bytes */
  /*printf("Length of Data Block (in bytes) = %hd\n",length);*/
  num=length/6 ;
  
  printf("Packet 15: Length=%4hd  Number Included=%hd\n",
      length,num);
  /*printf("Number of Storm ID's to Print: %d\n",num);*/

  for(i=1;i<=num;i++) {

    ipos=read_half(buffer,offset);
    jpos=read_half(buffer,offset);
    a=read_byte(buffer,offset);
    b=read_byte(buffer,offset);
    
    printf("  I Pos: %4hd  J Pos: %4hd  Storm ID: %c%c\n",
      ipos,jpos,a,b);
      /*
    printf("Storm ID %d\n",i);
    printf("I Position: %hd\n",read_half(buffer,offset));
    printf("J Position: %hd\n",read_half(buffer,offset));
    a=read_byte(buffer,offset);
    b=read_byte(buffer,offset);
    printf("Storm ID: %c%c\n",a,b);
    printf("\n");
    */
    }
  /*printf("Message Complete\n");*/
  printf("\n");
  }
Exemplo n.º 18
0
void packet_BA07_skip(char *buffer,int *offset)
{
    /*LINUX changes*/
    short length, num_row, i;
    MISC_short_swap(buffer+*offset,10);/* I think this is right.. */

    *offset+=16;
    num_row = read_half(buffer, offset);
    *offset += 2;  /*skip over packing descriptor*/

    for(i=0; i<num_row; i++) {
        length = read_half_flip(buffer, offset);
        *offset += length;
    }

}
Exemplo n.º 19
0
void packet_AF1F(char *buffer,int *offset,int *flag) {
    /* display Packet AF1F Rdial Data Packet (16 level) information
       flag[7] contains scale data: 1=refl 2=vel 0.5m/s 3=vel 1m/s 4=sw */
    short num_radials=0;
    int i; /* j; */
    short num_rle_halfwords=0;
    short range_bins;
    short start_angle,delta_angle;
    short istart_angle;
    short radial_found=FALSE;
    int start=0,end=0;
    short code=2; /* used for sending rle decoding instructions to the BSCAN module */
    /* CVT 4.3 internal diagnostics */
    /*   enum{NOMOD,RLE,BSCAN};  defined in cvt.h */
    /*    char *truefalse[]={"FALSE","TRUE"}; */
    /*    char *format[]={"NONE","RLE","BSCAN"}; */
    /*    char *scale[]={"NOSCALE","REFL","VEL1","VEL2","SW"}; */

    fprintf(stderr,"\n---------------- Decoding Packet AF1Fx -----------------\n");

    fprintf(stderr,"Index of First Range Bin:\t\t\t%hd\n",read_half(buffer,offset));
    range_bins=read_half(buffer,offset);
    fprintf(stderr,"Number of Range Bins:\t\t\t\t%hd\n",range_bins);
    fprintf(stderr,"I center of sweep:\t\t\t\t%hd\n",read_half(buffer,offset));
    fprintf(stderr,"J center of sweep:\t\t\t\t%hd\n",read_half(buffer,offset));
    fprintf(stderr,"Scale Factor:\t\t\t\t\t%hd\n",read_half(buffer,offset));
    num_radials=read_half(buffer,offset);
    fprintf(stderr,"Number of Radials\t\t\t\t%hd\n",num_radials);
    fprintf(stderr,"\n");

    /* test for format flag etc. */
    if((flag[0]==RADIAL) && (flag[5]==RLE)) {
        fprintf(stderr,"Radials Left in Run-Length Encoded Format\n");
    } else if(flag[0]==RADIAL) {
        fprintf(stderr,"Radials Unpacked to show all Data Values\n");
    }
    if(flag[5]==BSCAN) {
        fprintf(stderr,"BSCAN Format Output Selected\n");
    }

    /*  CVT 4.3  internal diagnostics */
    /*    fprintf(stderr,"Diagnostic Information:\n"); */
    /*    start=flag[1]; */
    /*    fprintf(stderr,"Start Field:\t\t\t\t\t%hd\n",start); */
    /*    end=flag[2]; */
    /*    fprintf(stderr,"End Field:\t\t\t\t\t%hd\n",end); */
    /*    fprintf(stderr,"All Flag:\t\t\t\t\t%s\n",truefalse[flag[3]]); */
    /*    fprintf(stderr,"Degree Flag:\t\t\t\t\t%s\n",truefalse[flag[4]]); */
    /*    fprintf(stderr,"Output Format:\t\t\t\t\t%s\n",format[flag[5]]); */
    /*    fprintf(stderr,"Scale Flag:\t\t\t\t\t%s\n",scale[flag[7]]); */
    /*    fprintf(stderr,"\n"); */


    start=flag[1];
    end=flag[2];

    /* CVT 4.4 */
    if(flag[1]==0 && flag[2]==0) /* assume all radials desired */
        flag[3] = TRUE;


    /* check for 'all' flag & reset start and end flags */
    if(flag[3]==TRUE) {
        if(flag[4]==TRUE) { /* use degree values */
            start=0;
            end=359;

        } else { /* use all values */
            start=1;
            end=num_radials;
        }

    }

    /* quality control input values */
    if(start>num_radials) {
        fprintf(stderr,"Range Error: The Radial Start Value of %d Exceeds the Max Number of Radials (%d)\n",
                start,num_radials);
        return;
    }
    if(end<0) {
        fprintf(stderr,"Range Error: The Radial End Value of %d is out of bounds\n",end);
        return;
    }
    if(flag[4]==TRUE && (start>359 || start<0)) {
        fprintf(stderr,"Range Error: The Radial Start Value of %d must be within 0-359 degrees\n",
                start);
        return;
    }
    if(flag[4]==TRUE && (end >359 || start<0)) {
        fprintf(stderr,"Range Error: The Radial End Value of %d must be within 0-359 degrees\n",
                end);
        return;
    }

    if(flag[5]==BSCAN) {
        /* output data in BSCAN format (bypass all further radial processing */
        generate_BSCAN(num_radials,range_bins,code,buffer,offset,flag);
        return;
    }

    /* process for each radial */
    for(i=1; i<=num_radials; i++) {

        /* read the radial header */
        num_rle_halfwords=read_half(buffer,offset); /* a halfword is 2 bytes */
        start_angle=read_half(buffer,offset);
        istart_angle=(short)(start_angle/10.0);
        delta_angle=read_half(buffer,offset);
        /*fprintf(stderr,"radial %d #rle halfwords %04hd start angle %04hd delta angle %04hd\n",
           i,num_rle_halfwords,start_angle,delta_angle);*/

        if(flag[4]==FALSE) { /* process actual radial values */

            if(end==0) {  /* only one radial is requested */
                if(start!=i) {
                    advance_offset(buffer,offset,2*num_rle_halfwords);
                    continue;
                }

            } /*  end if end==0 */

            if(end!=0) { /* more than one radial is requested */
                /* fprintf(stderr,"radial %d start=%d end=%d\n",i,start,end);*/

                if(start>end) {
                    /* range from 358 to 2 degrees has start val > end */
                    if(i<start && i>end) {
                        advance_offset(buffer,offset,2*num_rle_halfwords);
                        continue;
                    }

                } else {
                    /* normal processing with start val < end val */
                    if(i<start || i>end) {
                        advance_offset(buffer,offset,2*num_rle_halfwords);
                        continue;
                    }

                } /*  end else */

            } /*  end if end!=0 */

        } /* end if flag[4] FALSE*/


        if(flag[4]==TRUE) { /* process degree values */

            if(end==0) {  /* only one radial is requested */
                if(start!=istart_angle) {
                    advance_offset(buffer,offset,2*num_rle_halfwords);
                    continue;
                }
            }

            if(end!=0) { /* more than one radial is requested */
                /* fprintf(stderr,"radial %d start=%d istart_angle=%d end=%d\n",
                                               i,start,istart_angle,end);*/

                if(start>end) {
                    /* range from 358 to 2 degrees has start val > end */
                    if(istart_angle<start && istart_angle>end) {
                        advance_offset(buffer,offset,2*num_rle_halfwords);
                        continue;
                    }
                } else {
                    /* normal processing with start val < end val */
                    if(istart_angle<start || istart_angle>end) {
                        advance_offset(buffer,offset,2*num_rle_halfwords);
                        continue;
                    }

                } /*  end else */

            } /*  end if end!=0 */

        } /* end if flag[4] TRUE */

        radial_found=TRUE;

        if(flag[5]==RLE) {
            /* output radial data in hexidecimal RLE encoded format */
            print_rle("AF1F RLE Output",i,start_angle,delta_angle,buffer,offset,
                      2*num_rle_halfwords);

        } else {
            /* output radial data in decimal non-RLE encoded format */
            decode_rle("AF1F Decimal Output",i,start_angle,delta_angle,buffer,offset,
                       2*num_rle_halfwords, range_bins, flag[7]);
        }

    } /* end of i loop */

    if(radial_found==FALSE) {
        fprintf(stderr,"WARNING: No data was found for radial range start: %hd end: %hd\n",
                start,end);
    }


}
Exemplo n.º 20
0
void display_packet_25(int packet, int offset) 
{
    short length,x,y,rad;

    
    /* previous version did not adjust to center of screen */
    int     center_pixel;
    int     center_scanl;    
    
    int pixel, scanl;
    
    float x_scale, y_scale;

    int *prod_res_ind;    
    float base_res, prod_res;
    Prod_header *hdr;




    offset+=2;
    
    length = read_half(sd->icd_product, &offset);    
    x = read_half(sd->icd_product, &offset);
    y = read_half(sd->icd_product, &offset);
    rad = read_half(sd->icd_product, &offset);    


    
    if(verbose_flag) {
        printf("\nPacket 25: STI Circle\n");
    printf("Packet Length: %hd\n", length);
    printf("I Position: %hd\n", x);
    printf("J Position: %hd\n", y);
    printf("Radius of Circle: %hd\n", rad);
    }


  
    /* This looks kludgy, however the Legacy rescale factor assumed a 0.54 NM*/
    /*   product displayed on a PUP                                          */
    /* In order to be able to display over other product resolutions : */

    /* resolution of the base image displayed */
    base_res = res_index_to_res(sd->resolution);   
    
    /* configured resolution of this product */
    hdr = (Prod_header *)(sd->icd_product);
    prod_res_ind = assoc_access_i(product_res, hdr->g.prod_id);
    prod_res = res_index_to_res(*prod_res_ind);

    
    /* Accoarding to the Class 1 User ICD, the radius of the 
     * circle is stated in pixels not in 1/4 KM.  Therefore the
     * radius should NOT expand with product zoom
     */   

    /* CVG 9.0 - use new function for scale and center calculations */
    geo_scale_and_center(pwidth, pheight, sd->scale_factor, 
                     sd->x_center_offset, sd->y_center_offset, 
                     base_res, prod_res, &x_scale, &y_scale,
                                  &center_pixel, &center_scanl);


    pixel = x * x_scale + center_pixel;
    scanl = y * y_scale + center_scanl;
    

    XSetForeground(display, gc, display_colors[1].pixel);
  
    /* to improve appearance, increase radius by 2 pixels */
    rad += 2;


    XDrawArc(display, sd->pixmap, gc, pixel-rad, scanl-rad, rad*2, rad*2, 0, -(360*64));
    
}
Exemplo n.º 21
0
int get_tab_page(offset,tab_page,tabscreen)
{
  int i,page,numpages,buf_len=0;

  int num_lines =0;  /* used to catch page parsing errors */
    
  /*LINUX change.. made them shorts*/
  short divider, bid=0;
  int  blen=-1; 
  int page_parse_error = FALSE; 
  
  screen_data *tab_sd=NULL;

/* */ /*DEBUG*/
/* fprintf(stderr,"DEBUG - entering get_tab_page offset is %d, desired page is %d\n", */
/*            offset, tab_page); */
  
 
  if(tabscreen==1)
      tab_sd=sd1;
  else if(tabscreen==2)
      tab_sd=sd2; 
  else if(tabscreen==3)
      tab_sd=sd3; 
  
  if(tab_sd->icd_product==NULL) {
    if(tab_msg_type == STANDALONE_TABULAR) {
      fprintf(stderr,"ERROR Reading SATAP, Product Data is NULL\n"); 
    } else {
      fprintf(stderr,"ERROR Reading TAB, Product Data is NULL\n");
    }
    return(FALSE);   
  } 
  
    /* read in block header */
    divider = read_half(tab_sd->icd_product, &offset);
  if(tab_msg_type != STANDALONE_TABULAR) {  
/* */ /*DEBUG*/
/* fprintf(stderr,"DEBUG - get_tab_page - reading ID and Length for TAB\n");      */
    bid = read_half(tab_sd->icd_product, &offset);
    blen = read_word(tab_sd->icd_product, &offset);
  }
  
/* */ /*DEBUG*/
/* fprintf(stderr,"DEBUG - get_tab_page - Message Type is %d\n",tab_msg_type); */
/* fprintf(stderr,"DEBUG - STANDALONE_TABULAR is '2'\n"); */
  
  if(tab_msg_type == STANDALONE_TABULAR) {
      if(verbose_flag) {
        printf("\nStand-Alone Tabular Alphanumeric Product\n");
        printf("Block Divider =   %hd\n", divider);
      }
  } else {  /* else a regular TAB */
      if(verbose_flag) {
        printf("\nTabular Alphanumeric Block\n");
        printf("Block Divider =   %hd\n", divider);
        printf("Block ID =        %hd\n", bid);
        printf("Length of Block = %d bytes\n", blen);
      }
  }
  
  if(tab_msg_type == STANDALONE_TABULAR) {
      if((divider != -1)) {
         printf( "\nSATAP  ERROR   DISPLAY_TAB   SATAP  ERROR\n");
         printf( "ERROR Entering SATAP Block, Either entry offset\n");
         printf( " is incorrect or SATAP divider is Incorrect\n");
         return(FALSE);
      }
  } else { /* else a regular TAB */
      if((divider != -1) || (bid != 3)) {
         printf( "\nTAB  ERROR   DISPLAY_TAB   TAB  ERROR\n");
         printf( "ERROR Entering TAB Block, Either entry offset\n");
         printf( " is incorrect or TAB divider and ID are Incorrect\n");
         return(FALSE);
      }
  }    

  /* advance offset pointer beyond the message header block and the
   * product description block contained in the TAB */
  if(tab_msg_type != STANDALONE_TABULAR)
      offset += 120;

  /* read in TAB header, only read number of pages for a SATAP */
  if(tab_msg_type != STANDALONE_TABULAR) 
      divider = read_half(tab_sd->icd_product, &offset);
  num_tab_pages = numpages = read_half(tab_sd->icd_product, &offset);
  
  if(verbose_flag) {
      printf("new offset = %d\n", offset); 
      printf("Block Divider =   %hd\n", divider);    
      printf("Number of Pages:  %hd  Current Page:  %hd\n", numpages, tab_page);
  }


  /* go through each page to find the one we want to display */
  for(page=1 ;page<=numpages; page++) {
      if(verbose_flag)
      fprintf(stderr, "\nTabular Alphanumeric Block - Page: %d\n",page);

        num_lines=0;
    
      /* loop to read a page's worth of data in */
      for(;;) {
      unsigned char c;
      int num = read_half(tab_sd->icd_product, &offset); /* num of chars in current line */
            if(num > 80) {
              printf( "\nTAB  ERROR   DISPLAY_TAB   TAB  ERROR\n");
              printf( "ERROR PARSING TAB PAGE Number %d\n", page);
              printf( " Number of Characters Exceed 80 on Line %d\n",
                      num_lines+1);
              page_parse_error = TRUE;
              break;
            }

           /* if a max size page we exit after checking for divider */     
            if(num_lines==MAX_NUM_LINES) {
              if(num==-1) 
                break; 
              else {
                printf( "\nTAB  ERROR   DISPLAY_TAB   TAB  ERROR\n");
                printf( "ERROR PARSING TAB PAGE Number %d\n", page);
                printf( " or Number of Lines Exceed Limit of 17\n");
                printf( "Did Not Find End-Of-Page (-1) Divider\n");
                page_parse_error = TRUE;
                break;
              }
            }   

      /* stop if end of page flag is reached */
      if(num == -1) break;  /* catch a short page */

      if(page == tab_page) {
          /* if we've reached the page we want, then read the page in character
           * by character and store it in a buffer for later display
           */
          for(i=0; i<num; i++) {
          c = read_byte(tab_sd->icd_product, &offset);
          tab_buf[buf_len++] = c;
          }
          tab_buf[buf_len++] = '\n';
      } else {   /* otherwise, skip over the page */
          offset += num;
      }
      
        num_lines++;
              
      } /* end for(;;) */
      
      if(page_parse_error==TRUE)
            return(FALSE);      
            
        
      /* if we managed to find the page we were looking for, pop up a window
       * and display the page in it
       */
      if(page == tab_page)
      tab_buf[buf_len++] = '\0';  /* make sure the TAB string is null-terminated */
     
   }
   return(TRUE);
} /*  end get_tab_page */
Exemplo n.º 22
0
void display_packet_10(int packet,int offset) 
{
    short length, i_start, i_end, j_start, j_end;
    int i,num_vectors,count=1, color;
    float   x_scale, y_scale;
    
    /* CVG 9.0 - added for GEOGRAPHIC_PRODUCT support */
    int center_pixel, center_scanl;
    int  *type_ptr, msg_type;
    Prod_header *hdr;
    int *prod_res_ind;    
    float base_res, prod_res;
    
    
    
    
    /* CVG 9.0 - added for GEOGRAPHIC_PRODUCT support */
    /* get the type of product we have here */
    hdr = (Prod_header *)(sd->icd_product);
    type_ptr = assoc_access_i(msg_type_list, hdr->g.prod_id);
    if(type_ptr == NULL) {
        msg_type = NON_GEOGRAPHIC_PRODUCT; /* default */
    } else {
        msg_type = *type_ptr;
    }

    
    
    /* cvg 9.0 - added logic for Geographic Products - used new function */
    if(printing_gab == 1) { /* a GAB display */
        /* x_scale = 1.0; */
        x_scale = 0.86;
        y_scale = 2.0;
        center_pixel = 0; /* not used */
        center_scanl = 0; /* not used */
        
    } else { /*  a non GAB display */
        
        /* CVG 9.0 - added GEOGRAPHIC_PRODUCT support */
        if(msg_type == GEOGRAPHIC_PRODUCT) {
            /* configured resolution of this product */
            prod_res_ind = assoc_access_i(product_res, hdr->g.prod_id);
            prod_res = res_index_to_res(*prod_res_ind);
            /* CVG 9.0 - added for GEOGRAPHIC_PRODUCT support */
            /* resolution of the base image displayed */
            base_res = res_index_to_res(sd->resolution);   
            
            geo_scale_and_center(pwidth, pheight, sd->scale_factor, 
                             sd->x_center_offset, sd->y_center_offset, 
                             base_res, prod_res, &x_scale, &y_scale,
                                          &center_pixel, &center_scanl);
            
        } else { /* a NON_GEOGRAPHIC_PRODUCT */
           /* CVG 9.0 - calculates x_scale, y_scale, center_pixel, center_scanl */
           non_geo_scale_and_center((float)pwidth, (float)pheight, 
                              &x_scale, &y_scale, &center_pixel, &center_scanl);
                                                      
        }
    
    } /*  a non GAB display */
    
    


    offset += 2;
    length = read_half(sd->icd_product, &offset);
    color  = read_half(sd->icd_product, &offset);

    if(verbose_flag) {
        printf("\nPacket 10: Unlinked Vector Packet (uniform value)\n");
    printf("Packet 10 Length of Data Block (in bytes) = %hd\n", length);
    printf("Color Level Value = %hd\n", color);
    }
    
/* DEBUG */
/* fprintf(stderr,"DEBUG display_packet_10: color is %d\n", color); */
    
    length -= 2;
    num_vectors = length/8;

    if(verbose_flag)
        printf("Number of Vectors: %i\n", num_vectors);


    XSetForeground(display, gc, display_colors[color].pixel);
     
    for(i=0; i<num_vectors; i++) {
        /* CVG 9.0 - different logic for GAB amd non GAB use */
        if(printing_gab == 1) { /* a GAB display */
            i_start = read_half(sd->icd_product, &offset) * x_scale;
            j_start = read_half(sd->icd_product, &offset) * y_scale;
            i_end = read_half(sd->icd_product, &offset) * x_scale;
            j_end = read_half(sd->icd_product, &offset) * y_scale;
            
        } else { /* a non GAB display */
            /* CVG 9.0 - added centering factor for non-GAB uses on large screens */ 
            i_start = read_half(sd->icd_product, &offset) * x_scale + center_pixel;
            j_start = read_half(sd->icd_product, &offset) * y_scale + center_scanl;
            i_end = read_half(sd->icd_product, &offset) * x_scale + center_pixel;
            j_end = read_half(sd->icd_product, &offset) * y_scale + center_scanl;
        }

        if(verbose_flag)
            printf("I Starting Point: %hd   J Starting Point: %hd\n", i_start, j_start);
        if(verbose_flag)
            printf("End Vector Number %4d   I=%5hd  J=%5hd\n",count,i_end,j_end);
            
        XDrawLine(display, sd->pixmap, gc, i_start, j_start, i_end, j_end);
        count++;
        
    } /* end for num_vectors */
    
    
} /* end display_packet_10 */
Exemplo n.º 23
0
                   printf("DATA ERROR Packet AF1F, number of unpacked "
                          "bins exceeds number of data elements %d\n"
                          "           HW per radial is is %d, reading RLE HW %d\n",
                          range_bins,num/2,(j+1)/2);
                   return;
               }
        
            } /* end k loop */
            
         } /* end j loop */

      } else {   /*  code == 1, input data is digital data ---------------- */

         int j;
          /* read the radial header 16 */    
         num=read_half(buffer,offset); /* number of bytes in this radial */
         angle[i]=read_half(buffer,offset);
         
         /* CVT 4.4 - previously was only in RLE processing */
         /* when exiting the i loop, start_index set to location of the */
         /* smallest azimuth angle                                      */
         if(angle[i]/10.0<min_az) {
             min_az=angle[i]/10.0;
             start_index=i;
         }
         
         delta_angle=read_half(buffer,offset);
/* DEBUG */
/* printf("DEBUG BSCAN radial %d #bytes %04hd start angle %04hd delta  %04hd\n",*/
/*                                               i,num,angle[i],delta_angle);   */
    
Exemplo n.º 24
0
void generate_BSCAN(short num_radials,short range_bins,short code,char *buffer,
   int *offset,int *flag) {
   /* output data in the OH BSCAN format 
   code=1 for digital data and 2 for RLE data that needs to be decoded.

   flag[7] contains scale data: 1=refl 2=vel 0.5m/s 3=vel 1m/s 4=sw */

   int i,n;
   short num=0;
   short count=0;
   short delta_angle;
   short start_index=0; /* index of the smallest azimuth angle */
   float min_az=999.9;  /* used to find the start_index */
   
/* CVT 4.4 */
/*   short data[400][920]; */
/*   short angle[400];     */
   short data[BASEDATA_MAX_SR_RADIALS][MAX_BASEDATA_REF_SIZE];
   short angle[BASEDATA_MAX_SR_RADIALS];

   /*
   short radial_found=FALSE;
   int start=0,end=0;
    */
/* CVT 4.3 */
/*   enum{NOMOD,RLE,BSCAN};  defined in cvt.h */
/*    char *truefalse[]={"FALSE","TRUE"}; */
/*    char *format[]={"NONE","RLE","BSCAN"}; */


   printf("Begin BSCAN Generator\n");

   /*  PART 1 - FILL THE DATA ARRAYS ==================================== */
   for(i=0;i<num_radials;i++) {

/* CVT 4.4 */
/*      if(i>=400) { */
      if(i>=BASEDATA_MAX_SR_RADIALS) {
         printf("BSCAN ERROR: number of radials exceeded ORPG LIMIT %d\n",
                                                  BASEDATA_MAX_SR_RADIALS);
         break;
      }


      /*  input data is RLE data packet ------------------------------- */
      if(code==2) {
         int j,k;
         int count=0;
   
         /* read the radial header AF1F*/    
         num=read_half(buffer,offset); /*number of rle halfwords (2 bytes) */
         angle[i]=read_half(buffer,offset);
         /* when exiting the i loop, start_index set to location of the */
         /* smallest azimuth angle                                      */
         if(angle[i]/10.0<min_az) {
             min_az=angle[i]/10.0;
             start_index=i;
         }
         
         delta_angle=read_half(buffer,offset);
/* DEBUG */
/* printf("radial %d #rle halfwords %04hd start angle %04hd delta angle %04hd\n",*/
/*                                                   i,num,angle[i],delta_angle);*/
   
         /* decode run length encoded data and stuff into data array */
/* DEBUG */
/*printf("DEBUG BSCAN Angle: %05.1f  Delta: %4.1f\n", */
/*          angle[i]/10.0,delta_angle/10.0);          */

         for(j=0;j<(2*num);j++) {
            char c,run,val;
            c=read_byte(buffer,offset);
              
            run=c>>4;
            val=c & 0x0f;

            for(k=0;k<(int)run;k++) {
                
               data[i][count++] = (short)val;
/* CVT 4.4 */
/*               if(count>=920) {                                               */
/*                   printf("RLE Decode: decode counter exceeded 920 bins per " */
/*                          "radial on radial %hd rle word %hd\n",i,j);         */
               if(count>=range_bins) {
                   printf("DATA ERROR Packet AF1F, number of unpacked "
                          "bins exceeds number of data elements %d\n"
                          "           HW per radial is is %d, reading RLE HW %d\n",
                          range_bins,num/2,(j+1)/2);
                   return;
               }
        
            } /* end k loop */
            
         } /* end j loop */

      } else {   /*  code == 1, input data is digital data ---------------- */
Exemplo n.º 25
0
void display_packet_7(int packet,int offset) 
{
    short length, i_start, i_end, j_start, j_end;
    int i,num_vectors,count=1;
    float   x_scale, y_scale;
    /* CVG 9.0 */
    int center_pixel, center_scanl;

    /* CVG 9.0 - added for GEOGRAPHIC_PRODUCT support */
    int  *type_ptr, msg_type;
    Prod_header *hdr;
    int *prod_res_ind;    
    float base_res, prod_res;




    /* CVG 9.0 - added for GEOGRAPHIC_PRODUCT support */
    /* get the type of product we have here */
    hdr = (Prod_header *)(sd->icd_product);
    type_ptr = assoc_access_i(msg_type_list, hdr->g.prod_id);
    if(type_ptr == NULL) {
        msg_type = NON_GEOGRAPHIC_PRODUCT; /* default */
    } else {
        msg_type = *type_ptr;
    }


    /* CVG 9.0 - added GEOGRAPHIC_PRODUCT support */
    if(msg_type == GEOGRAPHIC_PRODUCT) {
        /* configured resolution of this product */
        prod_res_ind = assoc_access_i(product_res, hdr->g.prod_id);
        prod_res = res_index_to_res(*prod_res_ind);
        /* CVG 9.0 - added for GEOGRAPHIC_PRODUCT support */
        /* resolution of the base image displayed */
        base_res = res_index_to_res(sd->resolution);   
        
        geo_scale_and_center(pwidth, pheight, sd->scale_factor, 
                         sd->x_center_offset, sd->y_center_offset, 
                         base_res, prod_res, &x_scale, &y_scale,
                                      &center_pixel, &center_scanl);
        
    } else { /* a NON_GEOGRAPHIC_PRODUCT */
       /* CVG 9.0 - calculates x_scale, y_scale, center_pixel, center_scanl */
       non_geo_scale_and_center((float)pwidth, (float)pheight, 
                          &x_scale, &y_scale, &center_pixel, &center_scanl);
                                                  
    }



    offset += 2;
    length = read_half(sd->icd_product, &offset);

    if(verbose_flag) {
        printf("\nPacket 7: Unlinked Vector Packet (no value)\n");
        printf("Packet 7 Length of Data Block (in bytes) = %hd\n", length);
    }

    num_vectors=length/8;
    if(verbose_flag)
        printf("Number of Vectors: %i\n", num_vectors);


    XSetForeground(display, gc, display_colors[1].pixel);
     
    for(i=0; i<num_vectors; i++) {
        /* CVG 9.0 - added centering factor for large screens */
        i_start = read_half(sd->icd_product, &offset) * x_scale + center_pixel;
        j_start = read_half(sd->icd_product, &offset) * y_scale + center_scanl;
        if(verbose_flag)
            printf("I Starting Point: %hd   J Starting Point: %hd\n", i_start, j_start);
        /* CVG 9.0 - added centering factor for large screens */
        i_end = read_half(sd->icd_product, &offset) * x_scale + center_pixel;
        j_end = read_half(sd->icd_product, &offset) * y_scale + center_scanl;
        if(verbose_flag)
            printf("End Vector Number %4d   I=%5hd  J=%5hd\n",count,i_end,j_end);
        XDrawLine(display, sd->pixmap, gc, i_start, j_start, i_end, j_end);
        count++;
        
    }  /* end for num_vectors */
    
} /* end display_packet_7 */