Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Functions
rle_addhist.c File Reference
#include "rle.h"
#include <stdio.h>
#include <time.h>
Include dependency graph for rle_addhist.c:

Go to the source code of this file.

Functions

void rle_addhist (argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
 

Function Documentation

void rle_addhist ( argv  ,
rle_hdr in_hdr,
rle_hdr out_hdr 
)

Definition at line 54 of file rle_addhist.c.

57 {
58  register int length,i;
59  time_t temp;
60  /* padding must give number of characters in histoire */
61  /* plus one for "=" */
62  static CONST_DECL char *histoire="HISTORY",
63  *padding="\t";
64  char *timedate,*old= NULL;
65  static char *newc;
66 
67  if(getenv("NO_ADD_RLE_HISTORY"))return;
68 
69  length=0;
70  for(i=0;argv[i];i++)
71  length+= strlen(argv[i]) +1; /* length of each arg plus space. */
72 
73  (void)time (&temp);
74  timedate=ctime(&temp);
75  length+= strlen(timedate); /* length of date and time in ASCII. */
76 
77  length+= strlen(padding) + 3 + strlen(histoire) + 1; /* length of padding, "on " and length of history name plus "="*/
78  if(in_hdr) /* if we are interested in the old comments... */
79  old=rle_getcom(histoire,in_hdr); /* get old comment. */
80 
81  if((old) && (*old)) length+= strlen(old); /* add length if there. */
82 
83  length++; /*Cater for the null. */
84 
85  if((newc=(char *)malloc((unsigned int) length)) == NULL)return;
86 
87  (void)strcpy(newc,histoire);(void)strcat(newc,"=");
88  if((old) && (*old)) (void)strcat(newc,old); /* add old string if there. */
89  for(i=0;argv[i];i++)
90  {
91  (void)strcat(newc,argv[i]);(void)strcat(newc," ");
92  }
93  (void)strcat(newc,"on ");(void)strcat(newc,timedate); /* \n supplied by time. */
94  (void)strcat(newc,padding); /* to line up multiple histories.*/
95 
96  (void)rle_putcom(newc,out_hdr);
97 
98 }
char * rle_getcom(const char *name, rle_hdr *the_hdr)
const char * rle_putcom(const char *value, rle_hdr *the_hdr)
static char temp[]
Definition: into.c:45
#define CONST_DECL
Definition: rle_config.h:42
void * malloc()
int i
Definition: rletorla.c:82