Using Compression/Decompression Plug-ins


char command[200];
sprintf(command,"comp_img > %s 2>&1",Stderr_file_name);
message("\nFixing to execute '%s' to compress an image\n",command);
system(command);    // Call the compressor

                     // Now open the file again, for reading
if( (parm_fp = fopen(Parm_file_name,"r")) == 0 )
  return CompReply(
            error_msg("failed to open the parameter file for reading"),
            0);

static char comp_image_result[100];
if( fgets(comp_image_result,sizeof(comp_image_result)-2,parm_fp) == 0 )
  return CompReply( error_msg("failed to read the parameter file"), 0 );
fclose(parm_fp);

if( does_start_with(comp_image_result,"OK") )
{
  sprintf(comp_image_result,"METX%s %s\n",request.SAT_cat_no,
          request.compr_tag);
  return CompReply(comp_image_result,Comp_image_file_name);
}
else
  return CompReply(
         error_msg("invalid status returned from the comp_img\n%s"
                   "\ntranscipt follows\n",comp_image_result),
         Stderr_file_name);

# Run the compressor
output_file=${HOME}/out$$.slpg
full_out_path=${DOCROOT}/$output_file
stderr_file=/tmp/err$$.txt

rm -f $full_out_path $stderr_file  # Take out trash if any
set -- `times`; time_started=$2
${DOCROOT}/${HOME}/sowlp_encode -s$parm $IMAGE_FILE \
                $full_out_path > $stderr_file 2>&1
return_code=$?
set -- `times`; time_ended=$2

if [ "$return_code" != "0" ]; then
  err=`cat $stderr_file`
  bail_out "Error compressing the file $IMAGE_FILE \
       <i>stderr</i> of the compressor follows<p><pre> $err </pre>"
fi
time_elapsed=`diff_time $time_ended $time_started`



Next