Example #1
0
void
brush_restore (void)
{
  reselect (brush_list, pcvals.selected_brush);
  gtk_adjustment_set_value (brush_gamma_adjust, pcvals.brushgamma);
  gtk_adjustment_set_value (brush_relief_adjust, pcvals.brush_relief);
  gtk_adjustment_set_value (brush_aspect_adjust, pcvals.brush_aspect);
}
Example #2
0
void
paper_restore (void)
{
  reselect (paper_list, pcvals.selected_paper);
  gtk_adjustment_set_value (paper_relief_adjust, pcvals.paper_relief);
  gtk_adjustment_set_value (paper_scale_adjust, pcvals.paper_scale);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (paper_invert), pcvals.paper_invert);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (paper_overlay), pcvals.paper_overlay);
}
    void showModule (const String& moduleID)
    {
        if (ConfigTreeItemTypes::ConfigTreeItemBase* mods = getModulesItem())
        {
            mods->setOpen (true);

            for (int i = mods->getNumSubItems(); --i >= 0;)
                if (ConfigTreeItemTypes::ModuleItem* m = dynamic_cast<ConfigTreeItemTypes::ModuleItem*> (mods->getSubItem (i)))
                    if (m->moduleID == moduleID)
                        reselect (*m);
        }
    }
Example #4
0
extern          dbms_error_t
dbms_comms(
	   dbms * me,
	   int token,
	   int *retval,
	   DBT * v1,
	   DBT * v2,
	   DBT * r1,
	   DBT * r2
)
{
	int             errs = 5;
	int             err = 0;

	struct sigaction act, oact;
#ifdef TPS
	gettimeofday(&tstart, NULL);
#endif

	if (logfile) {
		char           *p1 = NULL;
		char           *p2 = NULL;
		if (v1)
			p1 = _hex(me, v1->size, v1->data);
		if (v2)
			p2 = _hex(me, v2->size, v2->data);

		_tlog("%s@%s:%d %s(%02d) >>> %s %s",
		      me->name, me->host,me->port, _token2name(token), token,
		      p1 ? p1 : "<null>",
		      p2 ? p2 : "<null>");
		if (p1) (*me->free)(p1);
		if (p2) (*me->free)(p2);
	}
	/*
	 * for now, SA_RESTART any interupted function calls
	 */
	act.sa_handler = SIG_IGN;
	sigemptyset(&act.sa_mask);
	act.sa_flags = SA_RESTART;

	sigaction(SIGPIPE, &act, &oact);
	if (retval)
		*retval = -1;

	/*
	 * now obviously this is wrong; we do _not_ want to continue during
	 * certain errors.. ah well..
	 */
	for (errs = 0; errs < 10; errs++) {
		if ((me->sockfd >= 0) &&
		  ((err = i_comms(me, token, retval, v1, v2, r1, r2)) == 0))
			break;

		/*
		 * we could of course exit on certain errors, but which ? we
		 * call recv, et.al.
		 */
		if (err == EAGAIN || err == EINTR)
			continue;

		/*
		 * If the DB on the other end reported an error - then it
		 * obviously is not a comms problem - so retrying makes no
		 * sense
		 */
		if (err == E_ERROR)
			break;

		sleep(errs * 2);
		shutdown(me->sockfd, 2);
		close(me->sockfd);

		me->sockfd = -1;/* mark that we have an issue */
		if (((err = reconnect(me)) == 0) &&
		    ((err = reselect(me)) == 0)) {
			if (errs)
				(*(me->callback)) (DBMS_EVENT_RECONNECT, errs);
		} else if (errs)
			(*(me->callback)) (DBMS_EVENT_WAITING, errs);
	};

#ifdef TPS
	gettimeofday(&tnow, NULL);
	ttps++;
	ttime +=
		(tnow.tv_sec - tstart.tv_sec) * 1000000 +
		(tnow.tv_usec - tstart.tv_usec) * 1;
#endif
	/*
	 * restore whatever it was before
	 */
	sigaction(SIGPIPE, &oact, &act);
	if (logfile) {
		char           *q1 = NULL;
		char           *q2 = NULL;
		if (r1)
			q1 = _hex(me, r1->size, r1->data);
		if (r2)
			q2 = _hex(me, r2->size, r2->data);

		_tlog("%s@%s:%d %s(%02d) <<< %s %s",
		      me->name, me->host,me->port, _token2name(token), token,
		      q1 ? q1 : "<null>",
		      q2 ? q2 : "<null>");
		if (q1) (*me->free)(q1);
		if (q2) (*me->free)(q2);
	}
	return err;
};
Example #5
0
extern dbms    *
dbms_connect(
	     char *name, char *host, int port,
	     dbms_xsmode_t mode,
	     void *(*_my_malloc) (size_t s),
	     void (*_my_free) (void *adr),
	     void (*_my_report) (dbms_cause_t event, int count),
	     void (*_my_error) (char *err, int erx),
	     int bt_compare_fcn_type
)
{
	dbms           *me;
	int             err = 0;

	if ((name == NULL) || (*name == '\0'))
		return NULL;

	if ((host == NULL) || (*host == '\0'))
		host = DBMS_HOST;

	if (port == 0)
		port = DBMS_PORT;


	if (_my_malloc == NULL)
		_my_malloc = &malloc;

	if (_my_free == NULL)
		_my_free = &free;

	if (_my_report == NULL)
		_my_report = &_warning;

	me = (dbms *) (*_my_malloc) (sizeof(dbms));
	if (me == NULL)
		return NULL;	/* rely on errno */

	me->bt_compare_fcn_type = bt_compare_fcn_type;

	me->malloc = _my_malloc;
	me->free = _my_free;
	me->callback = _my_report;
	me->error = _my_error;
	bzero(me->err, sizeof(me->err));

	switch (mode) {
	case DBMS_XSMODE_DEFAULT:
		mode = DBMS_MODE;	/* default */
		break;
		;;
	case DBMS_XSMODE_RDONLY:
		break;
		;;
	case DBMS_XSMODE_RDWR:
		break;
		;;
	case DBMS_XSMODE_CREAT:
		break;
		;;
	case DBMS_XSMODE_DROP:
		break;
		;;
	default:
		{
			char            _buff[1024];
			snprintf(_buff, sizeof(_buff), "Unknown DBMS Access type (%d)", (int) mode);
			set_dbms_error(me, _buff, 0);
		}
		(*(me->free)) (me);
		return NULL;
		break;
	}

	me->sockfd = -1;
	me->mode = (u_long) mode;
	me->port = port;
	me->name = (char *) (*me->malloc)( strlen(name)+1 );
	if( me->name == NULL ) {
		(*(me->free)) (me);
		return NULL;
		};
	strcpy( me->name, name );
	me->host = (char *) (*me->malloc)( strlen(host)+1 );
	if( me->host == NULL ) {
		(*(me->free)) (me->name);
		(*(me->free)) (me);
		return NULL;
		};
	strcpy( me->host, host );

	/*
	 * quick and dirty hack to check for IP vs FQHN and fall through when
	 * in doubt to resolving.
	 */
	me->addr = INADDR_NONE;
	{
		int             i = 0;
		for (; me->host[i] != '\0'; i++)
			if (!isdigit((int) (me->host[i])) && me->host[i] != '.')
				break;

		if (me->host[i] == '\0')
			me->addr = inet_addr(host);
	}

	if (me->addr == INADDR_NONE) {
		struct hostent *hp;
		if ((hp = gethostbyname(me->host)) == NULL) {
			set_dbms_error(me, "Hostname lookup failed", errno);
			(*(me->free)) (me->name);
			(*(me->free)) (me->host);
			(*(me->free)) (me);
			return NULL;
		};
		/*
		 * copy the address, rather than the pointer as we need it
		 * later. It is an unsigned long.
		 */
		me->addr = *(u_long *) hp->h_addr;
	};

	if ((err = reconnect(me))) {
		set_dbms_error(me, "Connection failed", err);
		(*(me->free)) (me->name);
		(*(me->free)) (me->host);
		(*(me->free)) (me);
		return NULL;
	};

	if ((err = reselect(me))) {
		set_dbms_error(me, "Selection failed", err);
		(*(me->free)) (me->name);
		(*(me->free)) (me->host);
		(*(me->free)) (me);
		return NULL;
	};

	{
		char * file = getenv("DBMS_LOG");
		cnt++;
		if (file && (logfile == NULL)) {
			if ((logfile = fopen(file, "a"))) {
				fprintf(stderr, "Logging to %s\n", file);
			} else {
				fprintf(stderr,"Failure to log to %s: %s\n",file,strerror(errno));
			};
		}
		if (logfile)
			_tlog("start %d %s",cnt,name);
	}
	return me;
}
Example #6
0
void
ExecutionEnv::undo (void) {
    DocumentUndo::cancel(_doc->doc());
    reselect();
    return;
}
 void showModules()
 {
     if (ConfigTreeItemTypes::ConfigTreeItemBase* mods = getModulesItem())
         reselect (*mods);
 }
 void showProjectSettings()
 {
     if (ConfigTreeItemTypes::ConfigTreeItemBase* root = dynamic_cast<ConfigTreeItemTypes::ConfigTreeItemBase*> (rootItem.get()))
         if (root->isProjectSettings())
             reselect (*root);
 }
Example #9
0
static void
save_preset (void)
{
  const gchar *preset_name;

  gchar *fname, *presets_dir_path;
  FILE  *f;
  GList *thispath;
  gchar  buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar  vbuf[6][G_ASCII_DTOSTR_BUF_SIZE];
  guchar color[3];
  gint   i;
  gchar *desc_escaped, *preset_name_escaped;

  preset_name = gtk_entry_get_text (GTK_ENTRY (presetnameentry));
  thispath = parsepath ();
  store_values ();

  if (!thispath)
    {
      g_printerr ("Internal error: (save_preset) thispath == NULL\n");
      return;
    }

  /* Create the ~/.gimp-$VER/gimpressionist/Presets directory if
   * it doesn't already exists.
   *
   */
  presets_dir_path = g_build_filename ((const gchar *) thispath->data,
                                       "Presets",
                                       NULL);

  if (! g_file_test (presets_dir_path, G_FILE_TEST_IS_DIR))
    {
      if (g_mkdir (presets_dir_path,
                   S_IRUSR | S_IWUSR | S_IXUSR |
                   S_IRGRP | S_IXGRP |
                   S_IROTH | S_IXOTH) == -1)
        {
          g_printerr ("Error creating folder \"%s\"!\n",
                      gimp_filename_to_utf8 (presets_dir_path));
          g_free (presets_dir_path);
          return;
        }
    }

  /* Check if the user-friendly name has changed. If so, then save it
   * under a new file. If not - use the same file name.
   */
  if (selected_preset_orig_name &&
      strcmp (preset_name, selected_preset_orig_name) == 0)
    {
      fname = g_build_filename (presets_dir_path,
                                selected_preset_filename,
                                NULL);
    }
  else
    {
      fname = preset_create_filename (preset_name, presets_dir_path);
    }

  g_free (presets_dir_path);

  if (!fname)
    {
      g_printerr ("Error building a filename for preset \"%s\"!\n",
                  preset_name);
      return;
    }

  f = g_fopen (fname, "wt");
  if (!f)
    {
      g_printerr ("Error opening file \"%s\" for writing!\n",
                  gimp_filename_to_utf8 (fname));
      g_free (fname);
      return;
    }

  fprintf (f, "%s\n", PRESETMAGIC);
  desc_escaped = g_strescape (presetdesc, NULL);
  fprintf (f, "desc=%s\n", desc_escaped);
  g_free (desc_escaped);
  preset_name_escaped = g_strescape (preset_name, NULL);
  fprintf (f, "name=%s\n", preset_name_escaped);
  g_free (preset_name_escaped);
  fprintf (f, "orientnum=%d\n", pcvals.orient_num);
  fprintf (f, "orientfirst=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_first));
  fprintf (f, "orientlast=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_last));
  fprintf (f, "orienttype=%d\n", pcvals.orient_type);

  fprintf (f, "sizenum=%d\n", pcvals.size_num);
  fprintf (f, "sizefirst=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_first));
  fprintf (f, "sizelast=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_last));
  fprintf (f, "sizetype=%d\n", pcvals.size_type);

  fprintf (f, "brushrelief=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brush_relief));
  fprintf (f, "brushdensity=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brush_density));
  fprintf (f, "brushgamma=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brushgamma));
  fprintf (f, "brushaspect=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brush_aspect));

  fprintf (f, "generalbgtype=%d\n", pcvals.general_background_type);
  fprintf (f, "generaldarkedge=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.general_dark_edge));
  fprintf (f, "generalpaintedges=%d\n", pcvals.general_paint_edges);
  fprintf (f, "generaltileable=%d\n", pcvals.general_tileable);
  fprintf (f, "generaldropshadow=%d\n", pcvals.general_drop_shadow);
  fprintf (f, "generalshadowdarkness=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.general_shadow_darkness));
  fprintf (f, "generalshadowdepth=%d\n", pcvals.general_shadow_depth);
  fprintf (f, "generalshadowblur=%d\n", pcvals.general_shadow_blur);
  fprintf (f, "devthresh=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.devthresh));

  fprintf (f, "paperrelief=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.paper_relief));
  fprintf (f, "paperscale=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.paper_scale));
  fprintf (f, "paperinvert=%d\n", pcvals.paper_invert);
  fprintf (f, "paperoverlay=%d\n", pcvals.paper_overlay);

  fprintf (f, "selectedbrush=%s\n", pcvals.selected_brush);
  fprintf (f, "selectedpaper=%s\n", pcvals.selected_paper);

  gimp_rgb_get_uchar (&pcvals.color, &color[0], &color[1], &color[2]);
  fprintf (f, "color=%02x%02x%02x\n", color[0], color[1], color[2]);

  fprintf (f, "placetype=%d\n", pcvals.place_type);
  fprintf (f, "placecenter=%d\n", pcvals.placement_center);

  fprintf (f, "numorientvector=%d\n", pcvals.num_orient_vectors);
  for (i = 0; i < pcvals.num_orient_vectors; i++)
    {
      g_ascii_formatd (vbuf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_vectors[i].x);
      g_ascii_formatd (vbuf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_vectors[i].y);
      g_ascii_formatd (vbuf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_vectors[i].dir);
      g_ascii_formatd (vbuf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_vectors[i].dx);
      g_ascii_formatd (vbuf[4], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_vectors[i].dy);
      g_ascii_formatd (vbuf[5], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orient_vectors[i].str);

      fprintf (f, "orientvector=%d,%s,%s,%s,%s,%s,%s,%d\n", i,
               vbuf[0], vbuf[1], vbuf[2], vbuf[3], vbuf[4], vbuf[5],
               pcvals.orient_vectors[i].type);
    }

  fprintf (f, "orientangoff=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
                            pcvals.orient_angle_offset));
  fprintf (f, "orientstrexp=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
                            pcvals.orient_strength_exponent));
  fprintf (f, "orientvoronoi=%d\n", pcvals.orient_voronoi);

  fprintf (f, "numsizevector=%d\n", pcvals.num_size_vectors);
  for (i = 0; i < pcvals.num_size_vectors; i++)
    {
      g_ascii_formatd (vbuf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_vectors[i].x);
      g_ascii_formatd (vbuf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_vectors[i].y);
      g_ascii_formatd (vbuf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_vectors[i].siz);
      g_ascii_formatd (vbuf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_vectors[i].str);
      fprintf (f, "sizevector=%d,%s,%s,%s,%s\n", i,
               vbuf[0], vbuf[1], vbuf[2], vbuf[3]);
    }
  fprintf (f, "sizestrexp=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.size_strength_exponent));
  fprintf (f, "sizevoronoi=%d\n", pcvals.size_voronoi);

  fprintf (f, "colortype=%d\n", pcvals.color_type);
  fprintf (f, "colornoise=%s\n",
           g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.color_noise));

  fclose (f);
  preset_refresh_presets ();
  reselect (presetlist, fname);

  g_free (fname);
}
/*
 * The body of the driver.
 */
static void
scsi_main(struct ncr_softc *sc)
{
	SC_REQ	*req, *prev;
	int	itype;
	int	sps;

	/*
	 * While running in the driver SCSI-interrupts are disabled.
	 */
	scsi_idisable();
	ENABLE_NCR5380(sc);

	PID("scsi_main1");
	for (;;) {
	    sps = splbio();
	    if (!connected) {
		/*
		 * Check if it is fair keep any exclusive access to DMA
		 * claimed. If not, stop queueing new jobs so the discon_q
		 * will be eventually drained and DMA can be given up.
		 */
		if (!fair_to_keep_dma())
			goto main_exit;

		/*
		 * Search through the issue-queue for a command
		 * destined for a target that isn't busy.
		 */
		prev = NULL;
		for (req=issue_q; req != NULL; prev = req, req = req->next) {
			if (!(busy & (1 << req->targ_id))) {
				/*
				 * Found one, remove it from the issue queue
				 */
				if (prev == NULL) 
					issue_q = req->next;
				else prev->next = req->next;
				req->next = NULL;
				break;
			}
		}

		/*
		 * When a request has just ended, we get here before an other
		 * device detects that the bus is free and that it can
		 * reconnect. The problem is that when this happens, we always
		 * baffle the device because our (initiator) id is higher. This
		 * can cause a sort of starvation on slow devices. So we check
		 * for a pending reselection here.
		 * Note that 'connected' will be non-null if the reselection
		 * succeeds.
		 */
		if ((GET_5380_REG(NCR5380_IDSTAT) & (SC_S_SEL|SC_S_IO))
						== (SC_S_SEL|SC_S_IO)){
			if (req != NULL) {
				req->next = issue_q; 
				issue_q = req;
			}
			splx(sps);

			reselect(sc);
			scsi_clr_ipend();
			goto connected;
		}

		/*
		 * The host is not connected and there is no request
		 * pending, exit.
		 */
		if (req == NULL) {
			PID("scsi_main2");
			goto main_exit;
		}

		/*
		 * Re-enable interrupts before handling the request.
		 */
		splx(sps);

#ifdef DBG_REQ
		if (dbg_target_mask & (1 << req->targ_id))
			show_request(req, "TARGET");
#endif
		/*
		 * We found a request. Try to connect to the target. If the
		 * initiator fails arbitration, the command is put back in the
		 * issue queue.
		 */
		if (scsi_select(req, 0)) {
			sps = splbio();
			req->next = issue_q; 
			issue_q = req;
			splx(sps);
#ifdef DBG_REQ
			if (dbg_target_mask & (1 << req->targ_id))
				ncr_tprint(req, "Select failed\n");
#endif
		}
	    }
	    else splx(sps);
connected:
	    if (connected) {
		/*
		 * If the host is currently connected but a 'real-DMA' transfer
		 * is in progress, the 'end-of-DMA' interrupt restarts main.
		 * So quit.
		 */
		sps = splbio();
		if (connected && (connected->dr_flag & DRIVER_IN_DMA)) {
			PID("scsi_main3");
			goto main_exit;
		}
		splx(sps);

		/*
		 * Let the target guide us through the bus-phases
		 */
		while (information_transfer(sc) == -1)
			;
	    }
	}
	/* NEVER TO REACH HERE */
	panic("ncr5380-SCSI: not designed to come here");

main_exit:
	/*
	 * We enter here with interrupts disabled. We are about to exit main
	 * so interrupts should be re-enabled. Because interrupts are edge
	 * triggered, we could already have missed the interrupt. Therefore
	 * we check the IRQ-line here and re-enter when we really missed a
	 * valid interrupt.
	 */
	PID("scsi_main4");
	scsi_ienable();

	/*
	 * If we're not currently connected, enable reselection
	 * interrupts.
	 */
	if (!connected)
		SET_5380_REG(NCR5380_IDSTAT, SC_HOST_ID);

	if (scsi_ipending()) {
		if ((itype = check_intr(sc)) != INTR_SPURIOUS) {
			scsi_idisable();
			splx(sps);

			if (itype == INTR_RESEL)
				reselect(sc);
#ifdef REAL_DMA
			else dma_ready();
#else
			else {
				if (pdma_ready())
					goto connected;
				panic("Got DMA interrupt without DMA");
			}
#endif
			scsi_clr_ipend();
			goto connected;
		}