コード例 #1
0
void
grg_pref_dialog (GtkWidget * parent)
{
	GtkWidget *prefs, *notebook, *tab1, *tab2, *tab3;
	GtkWidget *frame1, *frame2, *frame3;
	GtkWidget *crypt_box, *hash_box, *comp_box;
	GtkWidget *frame_font;
	GtkWidget *frame_file, *but_file, *box_file, *but_file_clear;
	GtkWidget *frame_save, *box_save;
	GtkWidget *frame_misc, *box_misc;
	GtkWidget *frame_xpire, *box_xpire, *xpire_lbl;
	GtkWidget *frame_passes, *box_passes, *lbl_passes;
	GtkWidget *frame_clip, *box_clip;
	gint response;

	PangoFontDescription *fdesc;

	if (active_flag)
		return;

	prefs = gtk_dialog_new_with_buttons (_("Preferences"),
					     GTK_WINDOW (parent),
					     GTK_DIALOG_DESTROY_WITH_PARENT,
					     GTK_STOCK_OK, GTK_RESPONSE_OK,
					     GTK_STOCK_APPLY,
					     GTK_RESPONSE_APPLY,
					     GTK_STOCK_CANCEL,
					     GTK_RESPONSE_CANCEL, NULL);

	//first page: algorithms
	tab1 = gtk_table_new (3, 2, FALSE);

	frame1 = gtk_frame_new (_("Encryption"));
	gtk_table_attach_defaults (GTK_TABLE (tab1), frame1, 0, 1, 0, 3);

	crypt_box = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame1), crypt_box);

	NEW_RADIO_BUTTON (rij1_but, NULL, modify_crypto, GRG_AES,
			  "AES (Rijndael 128)", crypt_box);
	NEW_RADIO_BUTTON (ser_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_SERPENT, "Serpent", crypt_box);
	NEW_RADIO_BUTTON (twof_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_TWOFISH, "Twofish", crypt_box);
	NEW_RADIO_BUTTON (cast_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_CAST_256, "Cast 256", crypt_box);
	NEW_RADIO_BUTTON (safer_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_SAFERPLUS, "Safer+", crypt_box);
	NEW_RADIO_BUTTON (loki_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_LOKI97, "Loki97", crypt_box);
	NEW_RADIO_BUTTON (tdes_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_3DES, "3-DES", crypt_box);
	NEW_RADIO_BUTTON (rij2_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_RIJNDAEL_256, "Rijndael 256",
			  crypt_box);

	NEW_ROW_SEPARATOR (crypt_box);

	NEW_LABEL (crypto_block_lbl, crypt_box, "");
	NEW_LABEL (crypto_key_lbl, crypt_box, "");

	update_crypto_label ();

	frame2 = gtk_frame_new (_("Hashing"));
	gtk_table_attach_defaults (GTK_TABLE (tab1), frame2, 1, 2, 0, 1);

	hash_box = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame2), hash_box);

	NEW_RADIO_BUTTON (sha_but, NULL, modify_hash, GRG_SHA1, "SHA1",
			  hash_box);
	NEW_RADIO_BUTTON (ripe_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (sha_but)), modify_hash,
			  GRG_RIPEMD_160, "RIPEMD 160", hash_box);

	frame3 = gtk_frame_new (_("Compression"));
	gtk_table_attach_defaults (GTK_TABLE (tab1), frame3, 1, 2, 1, 2);

	comp_box = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame3), comp_box);

	NEW_RADIO_BUTTON (zlib_but, NULL, modify_comp, GRG_ZLIB, "ZLib",
			  comp_box);
	NEW_RADIO_BUTTON (bz_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (zlib_but)),
			  modify_comp, GRG_BZIP, "BZip2", comp_box);

	NEW_ROW_SEPARATOR (comp_box);

	NEW_RADIO_BUTTON (r0_but, NULL, modify_ratio, GRG_LVL_NONE, _("None"),
			  comp_box);
	NEW_RADIO_BUTTON (r3_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (r0_but)), modify_ratio,
			  GRG_LVL_FAST, _("Fast"), comp_box);
	NEW_RADIO_BUTTON (r6_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (r0_but)), modify_ratio,
			  GRG_LVL_GOOD, _("Good"), comp_box);
	NEW_RADIO_BUTTON (r9_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (r0_but)), modify_ratio,
			  GRG_LVL_BEST, _("Best"), comp_box);

	notebook = gtk_notebook_new ();
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab1,
				  gtk_label_new (_("Algorithms")));
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (prefs)->vbox), notebook,
			    TRUE, TRUE, GRG_PAD);

	//second page: General options
	tab2 = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab2,
				  gtk_label_new (_("General options")));

	frame_font = gtk_frame_new (_("Editor font"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_font, FALSE, TRUE, 1);

	but_font =
		gtk_button_new_with_label (_
					   ("Click to change the editor font"));
	gtk_container_add (GTK_CONTAINER (frame_font), but_font);

	fdesc = pango_font_description_from_string (grg_prefs_editor_font);
	gtk_widget_modify_font (but_font, fdesc);
	g_free (fdesc);

	g_signal_connect (G_OBJECT (but_font), "clicked",
			  G_CALLBACK (modify_font), prefs);

	frame_misc = gtk_frame_new (_("Decorations"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_misc, FALSE, TRUE, 1);

	box_misc = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_misc), box_misc);

	NEW_ROW_SEPARATOR (tab2);

	splash_check = gtk_check_button_new_with_label (_("Splash screen"));
	g_signal_connect (G_OBJECT (splash_check), "toggled",
			  G_CALLBACK (modify_splash), NULL);
	gtk_box_pack_start (GTK_BOX (box_misc), splash_check, FALSE, TRUE, 1);

	frame_file = gtk_frame_new (_("File to open at startup"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_file, FALSE, TRUE, 1);

	box_file = gtk_hbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_file), box_file);

	file_entry = gtk_entry_new ();
	gtk_box_pack_start (GTK_BOX (box_file), file_entry, FALSE, TRUE, 1);
	but_file = gtk_button_new_from_stock (GTK_STOCK_OPEN);
	gtk_box_pack_start (GTK_BOX (box_file), but_file, FALSE, TRUE, 1);
	g_signal_connect (G_OBJECT (but_file), "clicked",
			  G_CALLBACK (meta_open_startup_file),
			  (gpointer) prefs);
	but_file_clear = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
	gtk_box_pack_start (GTK_BOX (box_file), but_file_clear, FALSE, TRUE,
			    1);
	g_signal_connect (G_OBJECT (but_file_clear), "clicked",
			  G_CALLBACK (clear_file), NULL);

	frame_save = gtk_frame_new (_("File saving"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_save, FALSE, TRUE, 1);

	box_save = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_save), box_save);

	bak_check =
		gtk_check_button_new_with_label (_("Make backups of files"));
	g_signal_connect (G_OBJECT (bak_check), "toggled",
			  G_CALLBACK (modify_bak), NULL);
	gtk_box_pack_start (GTK_BOX (box_save), bak_check, FALSE, TRUE, 1);
	over_check =
		gtk_check_button_new_with_label (_
						 ("Ask when overwriting files"));
	g_signal_connect (G_OBJECT (over_check), "toggled",
			  G_CALLBACK (modify_over), NULL);
	gtk_box_pack_start (GTK_BOX (box_save), over_check, FALSE, TRUE, 1);

	//third page: Security
	tab3 = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab3,
				  gtk_label_new (_("Security")));

	frame_xpire = gtk_frame_new (_("Password expiration"));
	gtk_box_pack_start (GTK_BOX (tab3), frame_xpire, FALSE, TRUE, 1);

	box_xpire = gtk_hbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_xpire), box_xpire);

	xpire_check =
		gtk_check_button_new_with_label (_("Password expires in"));
	xpire_spin =
		gtk_spin_button_new_with_range (EXP_TIME_MIN, EXP_TIME_MAX,
						1);
	xpire_lbl = gtk_label_new (_("days"));

	g_signal_connect (G_OBJECT (xpire_check), "toggled",
			  G_CALLBACK (modify_xpire), xpire_spin);
	g_signal_connect (G_OBJECT (xpire_spin), "value-changed",
			  G_CALLBACK (modify_xpin), xpire_check);

	gtk_box_pack_start (GTK_BOX (box_xpire), xpire_check, FALSE, TRUE, 1);
	gtk_box_pack_start (GTK_BOX (box_xpire), xpire_spin, FALSE, TRUE, 1);
	gtk_box_pack_start (GTK_BOX (box_xpire), xpire_lbl, FALSE, TRUE, 1);

	//this means "passes in wiping a file", not "wipe the passes" :)
	frame_passes = gtk_frame_new (_("Wipe passes"));
	gtk_box_pack_start (GTK_BOX (tab3), frame_passes, FALSE, TRUE, 1);

	box_passes = gtk_hbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_passes), box_passes);

	lbl_passes = gtk_label_new (_("Number of overwritings with random\n"
				      "data, when wiping a file:"));
	gtk_box_pack_start (GTK_BOX (box_passes), lbl_passes, FALSE, TRUE, 1);

	passes_spin =
		gtk_spin_button_new_with_range (WIPE_PASSES_MIN,
						WIPE_PASSES_MAX, 1);
	gtk_box_pack_start (GTK_BOX (box_passes), passes_spin, FALSE, TRUE,
			    1);

	g_signal_connect (G_OBJECT (passes_spin), "value-changed",
			  G_CALLBACK (modify_passes), NULL);

	frame_clip = gtk_frame_new (_("Clipboard"));
	gtk_box_pack_start (GTK_BOX (tab3), frame_clip, FALSE, TRUE, 1);

	box_clip = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_clip), box_clip);

	cclip_check =
		gtk_check_button_new_with_label (_
						 ("Clear clipboard on closing file"));
	g_signal_connect (G_OBJECT (cclip_check), "toggled",
			  G_CALLBACK (modify_cclip), NULL);
	gtk_box_pack_start (GTK_BOX (box_clip), cclip_check, FALSE, TRUE, 1);

	qclip_check =
		gtk_check_button_new_with_label (_
						 ("Clear clipboard on exit"));
	g_signal_connect (G_OBJECT (qclip_check), "toggled",
			  G_CALLBACK (modify_qclip), NULL);
	gtk_box_pack_start (GTK_BOX (box_clip), qclip_check, FALSE, TRUE, 1);

	//end of last tab
	active_flag = TRUE;
	reset_values (prefs);
	update_buttons ();

	gtk_widget_show_all (prefs);

	while (TRUE)
	{
		gboolean exit = TRUE;
		response = gtk_dialog_run (GTK_DIALOG (prefs));

		switch (response)
		{
		case GTK_RESPONSE_OK:
			apply_values ();
			break;
		case GTK_RESPONSE_APPLY:
			apply_values ();
			exit = FALSE;
			break;
		case GTK_RESPONSE_CANCEL:
		default:
			break;
		}

		if (exit)
		{
			gtk_widget_destroy (prefs);
			active_flag = FALSE;
			break;
		}
	}
}
コード例 #2
0
ファイル: formats.c プロジェクト: sedic/xcircuit-3.8
void loadlgf(int mode)
{
   FILE *ps;
   char inname[150], temp[500], *pdchar;
   char **signals;
   short *signets;
   objectptr *libobj;
   genericptr *iolabel;
   int i, sigs;

   sscanf(_STR, "%149s", inname);

   ps = fopen(inname, "r");
   if (ps == NULL) {
      sprintf(inname, "%s.lgf", _STR);
      ps = fopen(inname, "r");
      if (ps == NULL) {
	 sprintf(inname, "%s.lfo", _STR);
	 ps = fopen(inname, "r");
	 if (ps == NULL) {
	    Wprintf("Can't open LGF file %s", inname);
	    return;
         }
      }
   }

   /* for PostScript file, remove ".lgf" or ".lfo" (to be replaced with ".ps") */

   if ((pdchar = strstr(inname, ".l")) != NULL) *pdchar = '\0';

   Wprintf("Loaded file: %s", inname);

   /* Make sure that LGF object library has been loaded by loading it now. */

   if (NameToLibrary(LGF_LIB) < 0) {
      int ilib;
      strcpy(_STR, LGF_LIB);
      ilib = createlibrary(FALSE);
      loadlibrary(ilib);
   }
   
   /* Read header information */

   if (fgets(temp, 149, ps) == NULL) {
      Wprintf("Error: end of file.");
      return;
   }
   for (pdchar = temp; *pdchar != '-' && *pdchar != '\n'; pdchar++);
   if (*pdchar == '\n') {
      Wprintf("Not an LGF file?");
      return;
   }
   if (*(++pdchar) != '5') {
      Wprintf("Don't know how to read version %c.", *pdchar);
      return;
   }
   if (fgets(temp, 149, ps) == NULL) {
      Wprintf("Error: end of file.");
      return;
   }
   for (pdchar = temp; *pdchar != 'f' && *pdchar != '\n'; pdchar++);
   for (; *pdchar != 's' && *pdchar != '\n'; pdchar++);
   if (*pdchar == '\n') {
      Wprintf("Something wrong with the LGF file?");
      return;
   }

   /* Done with header. . . okay to clear current page now unless importing */

   if (mode == 0) {
      reset(topobject, NORMAL);
      pagereset(areawin->page); 
   }

   /* Set up filename and object (page) name */

   xobjs.pagelist[areawin->page]->filename = (char *) realloc (
      xobjs.pagelist[areawin->page]->filename, (strlen(inname) + 1) * sizeof(char));
   strcpy(xobjs.pagelist[areawin->page]->filename, inname);

   /* If the filename has a path component, use only the root */

   if ((pdchar = strrchr(inname, '/')) != NULL)
      sprintf(topobject->name, "%s", pdchar + 1);
   else
      sprintf(topobject->name, "%s", inname);

   renamepage(areawin->page);
   printname(topobject);

   /* Read objects */

   for(;;) {
      char *lineptr, keyptr, tmpstring[256];
      int dval;
      short pvalx, pvaly, pvalx2, pvaly2;

      if (fgets(temp, 499, ps) == NULL) break;		/* End-Of-File */

      /* ignore whitespace */
      for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
      if (*lineptr == '\n') continue;  /* ignore blank lines */
      switch(keyptr = *lineptr) {

	 case '#':	/* comment */
	    break;

	 case 'n':	/* nodes */
	    sscanf(++lineptr, "%d", &dval); 	    
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in node section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');
	    }
	    break;

	 case 's': 	/* signal names --- save for future reference */

	    sscanf(++lineptr, "%d", &sigs);
	    signals = (char **) malloc(sigs * sizeof(char *));
	    signets = (short *) malloc(sigs * sizeof(short));
	    for (i = 0; i < sigs; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in signal section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');
	       
	       sscanf(lineptr, "%hd %249s", &signets[i], tmpstring);

	       signals[i] = (char *)malloc((strlen(tmpstring) + 1) * sizeof(char));
	       sprintf(signals[i], "%s", tmpstring);
            }
	    break;
	 
	 case 'l': {	/* labels */

	    labelptr *newlabel;
	    char *tstrp;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in signal section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');
	       
	       /* Allocate label, and put node number into X value, to be replaced */
	       /* Flag it using an inappropriate rotation value (= 500) */

	       sscanf(lineptr, "%hd %hd", &pvalx, &pvaly);

	       /* Get rid of newline character, if any */

	       ridnewline(lineptr);

	       /* forward to the label part of the input line */

	       tstrp = lineptr - 1;
	       while (isdigit(*(++tstrp)));
	       while (isspace(*(++tstrp)));
	       while (isdigit(*(++tstrp)));
	       while (isspace(*(++tstrp)));
	       while (isdigit(*(++tstrp)));
	       while (isspace(*(++tstrp)));

	       if (tstrp != NULL) {	/* could be a blank line */
		  stringpart *strptr;

		  NEW_LABEL(newlabel, topobject);

		  labeldefaults(*newlabel, False, xmat(pvalx), ymat(pvaly));
	          (*newlabel)->justify = TOP | NOTBOTTOM;
		  (*newlabel)->color = DEFAULTCOLOR;
		  (*newlabel)->string->data.font = 0;
		  strptr = makesegment(&((*newlabel)->string), NULL);
		  strptr->type = TEXT_STRING;
		  strptr->data.string = (char *)malloc(1 + strlen(tstrp));
		  strcpy(strptr->data.string, tstrp);
		  (*newlabel)->pin = NORMAL;
	       }
            }}
	    break;

	case 'w': {	/* wires, implemented as single-segment polygons */
	    polyptr *newwire;
	    XPoint  *tmppnts;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in wire section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       /* Allocate wire */

	       NEW_POLY(newwire, topobject);

	       sscanf(lineptr, "%hd %hd %hd %hd", &pvalx, &pvaly, &pvalx2, &pvaly2);
	       (*newwire)->number = 2;
	       (*newwire)->points = (XPoint *)malloc(2 * sizeof(XPoint));
	       (*newwire)->width = 1.0;
	       (*newwire)->style = UNCLOSED;
	       (*newwire)->color = DEFAULTCOLOR;
	       (*newwire)->passed = NULL;
	       tmppnts = (*newwire)->points;
	       tmppnts->x = xmat(pvalx);
	       tmppnts->y = ymat(pvaly);
	       (++tmppnts)->x = xmat(pvalx2);
	       tmppnts->y = ymat(pvaly2);

	    }}
	    break;

	case 'p': 	/* solder dot */
	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in solder dot section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       /* Allocate arc */

	       sscanf(lineptr, "%hd %hd", &pvalx, &pvaly);
	       drawdot(xmat(pvalx), ymat(pvaly));
	    }
	    break;

	case 'b': {	/* boxes */
	    polyptr *newpoly;
	    pointlist newpoints;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in box section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       NEW_POLY(newpoly, topobject);

	       (*newpoly)->style = DASHED;
	       (*newpoly)->color = DEFAULTCOLOR;
	       (*newpoly)->width = 1.0;
	       (*newpoly)->number = 4;
               (*newpoly)->points = (pointlist) malloc(4 * sizeof(XPoint));
	       (*newpoly)->passed = NULL;

               newpoints = (*newpoly)->points;
	       sscanf(lineptr, "%hd %hd %hd %hd", &pvalx, &pvaly, &pvalx2, &pvaly2);
	       newpoints->x = xmat(pvalx);
	       newpoints->y = ymat(pvaly);
	       (newpoints + 1)->x = xmat(pvalx2);
	       (newpoints + 2)->y = ymat(pvaly2);

	       (newpoints + 2)->x = (newpoints + 1)->x;
	       (newpoints + 3)->x = newpoints->x;
	       (newpoints + 1)->y = newpoints->y;
	       (newpoints + 3)->y = (newpoints + 2)->y;
	    }}
	    break;

	case 'g': {	/* gates */

	    objinstptr *newinst;
	    labelptr *newlabel;
	    int j, k, hval, flip;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in gates section");
		     return;
	          }
		  for (lineptr = temp; *lineptr != '\n'; lineptr++); *lineptr = '\0';
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\0'; lineptr++);
	       } while (*lineptr == '\0');

	       /* double loop through user libraries */

	       for (j = 0; j < xobjs.numlibs; j++) {
		  for (k = 0; k < xobjs.userlibs[j].number; k++) {
		     libobj = xobjs.userlibs[j].library + k;
	             if (!strcmp(lineptr, (*libobj)->name)) break;
		  }
	          if (k < xobjs.userlibs[j].number) break;
	       }
	       strcpy(tmpstring, lineptr);

	       /* read gate definition */

	       if (fgets(temp, 499, ps) == NULL) {
		  Wprintf("End of file during gate read");
		  return;
	       }
      	       for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);

	       if (j < xobjs.numlibs || k < xobjs.userlibs[xobjs.numlibs - 1].number) {

		  NEW_OBJINST(newinst, topobject);

	          sscanf(lineptr, "%hd %hd %hd %*d %*d %*d %d", &pvalx, &pvaly,
			&pvalx2, &hval); 

		  flip = (pvalx2 >= 4) ? 1 : 0;
		  if (!strcmp(tmpstring, "FROM")) flip = 1 - flip;

		  (*newinst)->position.x = xmat(pvalx);
		  (*newinst)->position.y = ymat(pvaly);
		  (*newinst)->scale = 1.0;
		  (*newinst)->color = DEFAULTCOLOR;
		  (*newinst)->params = NULL;
	          (*newinst)->passed = NULL;

		  if (pvalx2 & 0x01) pvalx2 ^= 0x02;
                  if (pvalx2 >= 4) (*newinst)->rotation = -(((pvalx2 - 4) * 90) + 1);
                  else (*newinst)->rotation = (pvalx2 * 90) + 1;
		  (*newinst)->thisobject = *libobj;
		  (*newinst)->bbox.lowerleft.x = (*libobj)->bbox.lowerleft.x;
		  (*newinst)->bbox.lowerleft.y = (*libobj)->bbox.lowerleft.y;
		  (*newinst)->bbox.width = (*libobj)->bbox.width;
		  (*newinst)->bbox.height = (*libobj)->bbox.height;

	          /* Add label to "TO" and "FROM" */

	          if (!strcmp(tmpstring, "FROM") || !strcmp(tmpstring, "TO")) {
	   	     int nval;

		     hval--;
		     fgets(temp, 499, ps);
		     sscanf(temp, "%d", &nval);

		     for (k = 0; k < sigs; k++)
		        if (signets[k] == nval) {
			   stringpart *strptr;

			   NEW_LABEL(newlabel, topobject);
			   /* reconnect newinst if displaced by realloc() */
			   newinst = (objinstptr *)(topobject->plist
				+ topobject->parts - 2);

			   labeldefaults(*newlabel, False, (*newinst)->position.x,
				(*newinst)->position.y);
			   (*newlabel)->color = DEFAULTCOLOR;
			   (*newlabel)->pin = LOCAL;
			   (*newlabel)->color = LOCALPINCOLOR;
			   if (!strcmp(tmpstring, "TO"))
			      (*newlabel)->position.x += ((flip) ? 48 : -48);
			   else
			      (*newlabel)->position.x += ((flip) ? 54 : -54);

			   (*newlabel)->justify = NOTBOTTOM;
			   if (flip) (*newlabel)->justify |= (RIGHT | NOTLEFT);
			   (*newlabel)->string->data.font = 0;
			   strptr = makesegment(&((*newlabel)->string), NULL);
			   strptr->type = TEXT_STRING;
			   strptr->data.string = (char *)malloc(1 + strlen(signals[k]));
			   strcpy(strptr->data.string, signals[k]);
			   break;
		        }
	          }
	       }

	       /* read through list of attributes */

	       else {
	          sscanf(lineptr, "%*d %*d %*d %*d %*d %*d %d", &hval);
	          Wprintf("No library object %s", tmpstring);
	       }

	       for (j = 0; j < hval + 1; j++) {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("Unexpected end of file");
		     return;
	          }
	       }
	       /* read to next blank line */
	       do {
		  if (fgets(temp, 499, ps) == NULL) break;
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr != '\n');
	    }}
	    break;

	case 'h': {	/* history */
	    int j, hval;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in history section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       /* read through history */

	       sscanf(lineptr, "%*d %d", &hval);
	       for (j = 0; j < hval; j++)
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("Unexpected end of file");
		     return;
	          }
	    }}
	    break;

	case '.':	/* blank, don't use for EOF */
	    break;

	default:
	    Wprintf("Don't understand statement '%c'", *lineptr);
	    break;
      }
   }

   /* check for unattached labels and delete them */

   for (iolabel = topobject->plist; iolabel < topobject->plist +
	   topobject->parts; iolabel++)
      if (IS_LABEL(*iolabel)) {
         if (TOLABEL(iolabel)->rotation == 500) {
	    genericptr *tmplabel;

	    free(TOLABEL(iolabel)->string);
	    free(*iolabel);
            for (tmplabel = iolabel + 1; tmplabel < topobject->plist +
                topobject->parts; tmplabel++) *(tmplabel - 1) = *tmplabel;
            topobject->parts--;
	    iolabel--;
	 }
      }

   calcbbox(areawin->topinstance);
   centerview(areawin->topinstance);

   for (i = 0; i < sigs; i++) free(signals[i]);
   free(signals);
   free(signets);
}