<commit_before>
/*
 * $RCSfile$
 *--------------------------------------------------------------------
 * DESCRIPTION
 *   reads a tag from a PicFile
 *
 * $Log$
 * Revision 1.4  1998/05/06 14:13:15  andre
 * added info->pixel_start_in_file
 *
 * Revision 1.3  1997/10/20  13:35:39  andre
 * *** empty log message ***
 *
 * Revision 1.2  1997/09/15  13:21:14  andre
 * switched to new what string format
 *
 * Revision 1.1.1.1  1997/09/06  19:09:59  andre
 * initial import
 *
 *
 *--------------------------------------------------------------------
 *  COPYRIGHT (c) 1993 by DKFZ (Dept. MBI) Heidelberg, FRG
 */
#ifndef lint
  static char *what = { "@(#)ipPicGetTag\t\tDKFZ (Dept. MBI)\t"__DATE__"\t$Revision$" };
#endif

#include "ipPic.h"

ipPicDescriptor *ipPicGetTags( char *infile_name, ipPicDescriptor *pic )
{
  FILE *infile;

  ipPicTag_t tag_name;
  ipUInt4_t dummy;
  ipUInt4_t len;
  ipUInt4_t dim;
  ipUInt4_t n[_ipPicNDIM];

  ipUInt4_t to_read;

  if( infile_name == NULL )
    infile = stdin;
  else if( strcmp(infile_name, "stdin") == 0 )
    infile = stdin;
  else
    infile = fopen( infile_name, "rb" );

  if( infile == NULL )
    {
      /*ipPrintErr( "ipPicGetTags: sorry, error opening infile\n" );*/
      return( NULL );
    }

  if( pic != NULL )
    pic->info->write_protect = ipFalse;

  /* read infile */
  fread( &(tag_name[0]), 1, 4, infile );

  if( strncmp( ipPicVERSION, tag_name, 4 ) != 0 )
    {
      if( infile != stdin )
        fclose( infile );
      return( pic );
    }

  if( pic == NULL )
    pic = ipPicNew();

  fread( &(tag_name[4]), 1, sizeof(ipPicTag_t)-4, infile );
  /*strncpy( pic->info->version, tag_name, _ipPicTAGLEN );*/

  ipFReadLE( &len, sizeof(ipUInt4_t), 1, infile );

  ipFReadLE( &dummy, sizeof(ipUInt4_t), 1, infile );
  ipFReadLE( &dummy, sizeof(ipUInt4_t), 1, infile );
  ipFReadLE( &dim, sizeof(ipUInt4_t), 1, infile );

  ipFReadLE( n, sizeof(ipUInt4_t), dim, infile );


  to_read = len -        3 * sizeof(ipUInt4_t)
                -      dim * sizeof(ipUInt4_t);

  pic->info->tags_head = _ipPicReadTags( pic->info->tags_head, to_read, infile, ipPicEncryptionType(pic) );<commit_msg>*** empty log message ***<commit_after>
/*
 * $RCSfile$
 *--------------------------------------------------------------------
 * DESCRIPTION
 *   reads a tag from a PicFile
 *
 * $Log$
 * Revision 1.5  1999/11/27 19:32:13  andre
 * *** empty log message ***
 *
 * Revision 1.2.2.2  1998/03/25  15:03:36  andre
 * added info->pixel_start_in_file
 *
 * Revision 1.2.2.1  1997/09/15  13:47:06  andre
 * added encryption
 *
 * Revision 1.2  1997/09/15  13:21:14  andre
 * switched to new what string format
 *
 * Revision 1.1.1.1  1997/09/06  19:09:59  andre
 * initial import
 *
 *
 *--------------------------------------------------------------------
 *  COPYRIGHT (c) 1993 by DKFZ (Dept. MBI) Heidelberg, FRG
 */
#ifndef lint
  static char *what = { "@(#)ipPicGetTag\t\tDKFZ (Dept. MBI)\t"__DATE__"\t$Revision$" };
#endif

#include "ipPic.h"

ipPicDescriptor *ipPicGetTags( char *infile_name, ipPicDescriptor *pic )
{
  ipFile_t infile;

  ipPicTag_t tag_name;
  ipUInt4_t dummy;
  ipUInt4_t len;
  ipUInt4_t dim;
  ipUInt4_t n[_ipPicNDIM];

  ipUInt4_t to_read;

  infile = _ipPicOpenPicFileIn( infile_name );

  if( infile == NULL )
    {
      /*ipPrintErr( "ipPicGetTags: sorry, error opening infile\n" );*/
      return( NULL );
    }

  if( pic != NULL )
    pic->info->write_protect = ipFalse;

  /* read infile */
  ipFRead( &(tag_name[0]), 1, 4, infile );

  if( strncmp( ipPicVERSION, tag_name, 4 ) != 0 )
    {
      if( infile != stdin )
        fclose( infile );
      return( pic );
    }

  if( pic == NULL )
    pic = ipPicNew();

  ipFRead( &(tag_name[4]), 1, sizeof(ipPicTag_t)-4, infile );
  /*strncpy( pic->info->version, tag_name, _ipPicTAGLEN );*/

  ipFReadLE( &len, sizeof(ipUInt4_t), 1, infile );

  ipFReadLE( &dummy, sizeof(ipUInt4_t), 1, infile );
  ipFReadLE( &dummy, sizeof(ipUInt4_t), 1, infile );
  ipFReadLE( &dim, sizeof(ipUInt4_t), 1, infile );

  ipFReadLE( n, sizeof(ipUInt4_t), dim, infile );


  to_read = len -        3 * sizeof(ipUInt4_t)
                -      dim * sizeof(ipUInt4_t);

  pic->info->tags_head = _ipPicReadTags( pic->info->tags_head, to_read, infile, ipPicEncryptionType(pic) );
{'fraction_non_alphanumeric': 0.20651920838183935, 'fraction_numerical': 0.04912689173457509, 'mean_word_length': 2.3720565149136577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2104084', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1645, 'n_words': 371}