Exemple #1
0
/*  main	- main program
 *
 *  Parameters:
 *	argc	- number of command line arguments
 *	argv	- pointer to command line argument array
 *
 *  Returns:
 *	none
 */
void 
main(int argc, char **argv)
{
   DATABASE_S_T	data;		/* main database */


   /*  open dictionary then read it in
    */
   if ( OpenDictionary( DEFAULT_DICTIONARY, &data.dict ) )
   {
      fprintf(stderr, "Error:  opening %s as dictionary\n", DEFAULT_DICTIONARY);
      exit(1);
   }
   else
   {
      ReadDictionary( &data.dict );
   }


   /*  get sentence input
    */
   if (argc EQ 1)
   {
#ifdef DEBUG
      DisplayDictionary( &data.dict );
#endif

      if ( GetSentence( &data.current_sent ) )
      {
         fprintf(stderr, "Error:  getting sentence\n" );
         exit(1);
      }
   }
   else
   {
      fprintf(stderr, "Error:  command line input not supported yet\n" );
      exit(1);
   }


   /*  parse the sentence
    */
   ParseSentence( &data.dict, &data.current_sent );

#ifdef DEBUG
   DisplaySentence( &data.current_sent );
#endif


   /*  display the sentence diagram
    */
   DiagramSentence( &data.current_sent );

   exit(0);
}
Exemple #2
0
void PDF::CloseFile()
   {
   if (file == NULL)
      return;

   page.ClosePage();

   // If the PDF document is empty, add an empty
   // page to ensure well formed document.
   if (page.GetPageNumber() == 0)
      {
      page.OpenPage();
      page.ClosePage();
      }

   info.Write(*this);
   page.WritePageTree();
   font.WriteDictionary();

   int catalogue = GetObject();
   OpenObject(catalogue);
   OpenDictionary();

   WriteName("Type", "Catalog");
   WriteReference("Pages", page.tree_index);

   CloseDictionary();
   CloseObject();

   int trailer_offset = ftell(file);

   fprintf(file, "xref\n");
   fprintf(file, "0 %d\n", objects.Length() );
   fprintf(file, "0000000000 65535 f \n");

   for (int i = 1; i < objects.Length(); i++)
      fprintf(file, "%010d 00000 n \n", objects[i]);

   fprintf(file, "trailer\n");

   fprintf(file, "<<\n");
   fprintf(file, "/Size %d\n", objects.Length());
   fprintf(file, "/Root %d 0 R\n", catalogue);
   fprintf(file, "/Info %d 0 R\n", info.object);
   fprintf(file, ">>\n");

   fprintf(file, "startxref\n");
   fprintf(file, "%d\n", trailer_offset);
   fprintf(file, "%%%%EOF");

   fclose(file);
   file = NULL;
   }