Lines Matching refs:header

48 	if ((psf->header.ptr = calloc (1, INITIAL_HEADER_SIZE)) == NULL)
52 psf->header.len = INITIAL_HEADER_SIZE ;
63 newlen = (needed > psf->header.len) ? 2 * SF_MAX (needed, smallest) : 2 * psf->header.len ;
66 { psf_log_printf (psf, "Request for header allocation of %D denied.\n", newlen) ;
70 if ((ptr = realloc (psf->header.ptr, newlen)) == NULL)
71 { psf_log_printf (psf, "realloc (%p, %D) failed\n", psf->header.ptr, newlen) ;
76 /* Always zero-out new header memory to avoid un-initializer memory accesses. */
77 if (newlen > psf->header.len)
78 memset ((char *) ptr + psf->header.len, 0, newlen - psf->header.len) ;
80 psf->header.ptr = ptr ;
81 psf->header.len = newlen ;
395 ** ASCII header printf functions.
411 maxlen = strlen ((char*) psf->header.ptr) ;
412 start = ((char*) psf->header.ptr) + maxlen ;
413 maxlen = psf->header.len - maxlen ;
422 psf->header.indx = strlen ((char*) psf->header.ptr) ;
428 ** Binary header writing functions. Returns number of bytes written.
475 { psf->header.ptr [psf->header.indx++] = x ;
481 { psf->header.ptr [psf->header.indx++] = (x >> 24) ;
482 psf->header.ptr [psf->header.indx++] = (x >> 16) ;
483 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
484 psf->header.ptr [psf->header.indx++] = x ;
490 { psf->header.ptr [psf->header.indx++] = x ;
491 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
492 psf->header.ptr [psf->header.indx++] = (x >> 16) ;
493 psf->header.ptr [psf->header.indx++] = (x >> 24) ;
503 { psf->header.ptr [psf->header.indx++] = (x >> 8) ;
504 psf->header.ptr [psf->header.indx++] = x ;
509 { psf->header.ptr [psf->header.indx++] = x ;
510 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
515 { psf->header.ptr [psf->header.indx++] = (x >> 16) ;
516 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
517 psf->header.ptr [psf->header.indx++] = x ;
522 { psf->header.ptr [psf->header.indx++] = x ;
523 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
524 psf->header.ptr [psf->header.indx++] = (x >> 16) ;
529 { psf->header.ptr [psf->header.indx++] = (x >> 24) ;
530 psf->header.ptr [psf->header.indx++] = (x >> 16) ;
531 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
532 psf->header.ptr [psf->header.indx++] = x ;
537 { psf->header.ptr [psf->header.indx++] = x ;
538 psf->header.ptr [psf->header.indx++] = (x >> 8) ;
539 psf->header.ptr [psf->header.indx++] = (x >> 16) ;
540 psf->header.ptr [psf->header.indx++] = (x >> 24) ;
545 { psf->header.ptr [psf->header.indx++] = (x >> 56) ;
546 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 48) ;
547 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 40) ;
548 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 32) ;
549 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 24) ;
550 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 16) ;
551 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 8) ;
552 psf->header.ptr [psf->header.indx++] = (unsigned char) x ;
557 { psf->header.ptr [psf->header.indx++] = (unsigned char) x ;
558 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 8) ;
559 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 16) ;
560 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 24) ;
561 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 32) ;
562 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 40) ;
563 psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 48) ;
564 psf->header.ptr [psf->header.indx++] = (x >> 56) ;
587 if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
681 float32_be_write (floatdata, psf->header.ptr + psf->header.indx) ;
683 float32_le_write (floatdata, psf->header.ptr + psf->header.indx) ;
684 psf->header.indx += 4 ;
691 double64_be_write (doubledata, psf->header.ptr + psf->header.indx) ;
693 double64_le_write (doubledata, psf->header.ptr + psf->header.indx) ;
694 psf->header.indx += 8 ;
703 if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
710 memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
712 psf->header.indx += size ;
713 psf->header.ptr [psf->header.indx - 1] = 0 ;
724 if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
730 memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ;
732 psf->header.indx += size ;
744 if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
748 memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
749 psf->header.indx += size ;
757 if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
760 memcpy (&(psf->header.ptr [psf->header.indx]), bindata, size) ;
761 psf->header.indx += size ;
768 if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
773 { psf->header.ptr [psf->header.indx] = 0 ;
774 psf->header.indx ++ ;
781 memcpy (&(psf->header.ptr [psf->header.indx]), bindata, 16) ;
782 psf->header.indx += 16 ;
789 if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
792 psf->header.indx += size ;
799 if ((sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, size))
802 psf->header.indx = size ;
817 ** Binary header reading functions. Returns number of bytes read.
819 ** Format specifiers are the same as for header write function above with the following
867 if (psf->header.indx + bytes >= psf->header.len && psf_bump_header_allocation (psf, bytes))
870 if (psf->header.indx + bytes > psf->header.end)
871 { count = psf_fread (psf->header.ptr + psf->header.end, 1, bytes - (psf->header.end - psf->header.indx), psf) ;
872 if (count != bytes - (int) (psf->header.end - psf->header.indx))
876 psf->header.end += count ;
879 memcpy (ptr, psf->header.ptr + psf->header.indx, bytes) ;
880 psf->header.indx += bytes ;
890 if (psf->header.indx + position >= psf->header.len)
892 if (position > psf->header.len)
893 { /* Too much header to cache so just seek instead. */
894 psf->header.indx = psf->header.end = 0 ;
898 if (position > psf->header.end)
899 psf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, position - psf->header.end, psf) ;
900 psf->header.indx = position ;
904 if (psf->header.indx + position >= psf->header.len)
907 if (psf->header.indx + position < 0)
910 if (psf->header.indx >= psf->header.len)
915 if (psf->header.indx + position <= psf->header.end)
916 { psf->header.indx += position ;
920 if (psf->header.indx + position > psf->header.len)
922 position -= (psf->header.end - psf->header.indx) ;
923 psf->header.indx = psf->header.end ;
941 psf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, position - (psf->header.end - psf->header.indx), psf) ;
942 psf->header.indx = psf->header.end ;
958 if (psf->header.indx + bufsize >= psf->header.len && psf_bump_header_allocation (psf, bufsize))
962 { if (psf->header.indx < psf->header.end)
963 { ptr [k] = psf->header.ptr [psf->header.indx] ;
964 psf->header.indx ++ ;
967 { psf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, 1, psf) ;
968 ptr [k] = psf->header.ptr [psf->header.indx] ;
969 psf->header.indx = psf->header.end ;
1001 if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
1111 memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
1112 psf->header.indx += size ;
1128 if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))
1139 { psf->header.ptr [psf->header.indx] = 0 ;
1140 psf->header.indx ++ ;
1159 psf->header.end = psf->header.indx = 0 ;