| 1 | /* FILENAME: hdr_print.c */ |
|---|
| 2 | #include <stdio.h> |
|---|
| 3 | #include <stdlib.h> |
|---|
| 4 | #include "dprints.h" /* for dprints */ |
|---|
| 5 | #include "gribfuncs.h" /* prototypes */ |
|---|
| 6 | |
|---|
| 7 | /* |
|---|
| 8 | * |
|---|
| 9 | ******************************************************************** |
|---|
| 10 | * A. FUNCTION: hdr_print |
|---|
| 11 | * print specified number of bytes from the block provided. |
|---|
| 12 | * does not require Debug flag to be set; |
|---|
| 13 | * |
|---|
| 14 | * INTERFACE: |
|---|
| 15 | * void hdr_print (title, block, bytestoprint) |
|---|
| 16 | * |
|---|
| 17 | * ARGUMENTS (I=input, O=output, I&O=input and output): |
|---|
| 18 | * (I) char *title; Title string to print |
|---|
| 19 | * (I) unsigned char *block; Block whose content to print |
|---|
| 20 | * (I) int bytestoprint; Number of bytes to print |
|---|
| 21 | * |
|---|
| 22 | * RETURN CODE: none; |
|---|
| 23 | ******************************************************************** |
|---|
| 24 | */ |
|---|
| 25 | #if PROTOTYPE_NEEDED |
|---|
| 26 | void hdr_print (char *title, unsigned char *block, int bytestoprint) |
|---|
| 27 | #else |
|---|
| 28 | void hdr_print (title, block, bytestoprint) |
|---|
| 29 | char *title; unsigned char *block; int bytestoprint; |
|---|
| 30 | #endif |
|---|
| 31 | { |
|---|
| 32 | int i=0; |
|---|
| 33 | /* |
|---|
| 34 | * |
|---|
| 35 | * A.1 PRINT title string |
|---|
| 36 | */ |
|---|
| 37 | fprintf(stdout,"hdr_print %d bytes of '%s'=", bytestoprint, title); |
|---|
| 38 | |
|---|
| 39 | /* |
|---|
| 40 | * |
|---|
| 41 | * A.2 WHILE (more bytes to print) DO |
|---|
| 42 | * PRINT byte value |
|---|
| 43 | * ENDDO |
|---|
| 44 | */ |
|---|
| 45 | while (i < bytestoprint) |
|---|
| 46 | { |
|---|
| 47 | if (i % 8 == 0) { |
|---|
| 48 | if (i+7>= bytestoprint-1) |
|---|
| 49 | fprintf(stdout,"\n[%2d-%2d]: ",i+1, bytestoprint); |
|---|
| 50 | else fprintf(stdout,"\n[%2d-%2d]: ",i+1, i+8); |
|---|
| 51 | } |
|---|
| 52 | fprintf(stdout,"%03u ", block[i++]); |
|---|
| 53 | if (i % 4 == 0) fprintf(stdout, "| "); |
|---|
| 54 | } |
|---|
| 55 | fprintf(stdout,"\n"); |
|---|
| 56 | /* |
|---|
| 57 | * |
|---|
| 58 | * A.3 RETURN w/nothing |
|---|
| 59 | */ |
|---|
| 60 | fprintf(stdout,"Exiting hdr_print, no return code\n"); |
|---|
| 61 | /* |
|---|
| 62 | * |
|---|
| 63 | * END OF FUNCTION |
|---|
| 64 | * |
|---|
| 65 | */ |
|---|
| 66 | } |
|---|