int
GIFsetColRep(Metafile *mf, int num, Gint idx, Gcobundl *rep)
{
    Gint status = 1;
    int		imf;
    mf_cgmo		**cgmo	= &mf->cgmo;

    for (imf = 0; imf < num; ++imf) {
      float r = rep->red, g = rep->green, b = rep->blue;
      GIFmetafile *meta = find_meta(cgmo[imf]);
      int gindex;
      assert(meta);

      /* Do the color allocation -- background color */
      /* can't be reset */
      if (idx > 0 && (gindex = allocate_color(meta, idx, r, g, b)) == -1){
	msgWarn("GIFsetColRep : Can't allocate color (%f, %f, %f)\n",
	     r, g, b);
      } else {
	msgInfo("GIFsetColRep: assigning color (%f, %f, %f) to GKS %d GIF %d\n",
		r, g, b, idx, gindex);

	status = OK;
      }
    }

    return status;
}
Exemple #2
0
/*
 * Close a segment in an output PostScript file.
 */
    int
CAIROcloseSeg(Metafile *mf, int num)
{
				/* Noop */
  msgWarn("CAIROcloseSeg: Don't support this feature\n");
  return OK;
}
Exemple #3
0
/*
 * Set the deferal state in an output PostScript file.
 */
    int
CAIROdefer(Metafile **mf, int num, Gdefmode defer_mode, Girgmode regen_mode)
{
				/* Noop */
  msgWarn("CAIROdefer: Don't support this feature\n");
  return OK;
}
Exemple #4
0
static void
Scan_Disk(Disk *d)
{
    char device[64];
    u_long l;
    int i,j,fd;

    strcpy(device,"/dev/");
    strcat(device,d->name);

    fd = open(device,O_RDWR);
    if (fd < 0) {
	msgWarn("open(%s) failed", device);
	return;
    }
    for(i=-1,l=0;;l++) {
	j = scan_block(fd,l);
	if (j != i) {
	    if (i == -1) {
		printf("%c: %lu.",j ? 'B' : 'G', l);
		fflush(stdout);
	    } else if (i == 0) {
		printf(".%lu\nB: %lu.",l-1,l);
		fflush(stdout);
	    } else {
		printf(".%lu\nG: %lu.",l-1,l);
		fflush(stdout);
	    }
	    i = j;
	}
    }
    close(fd);
}
/*
 * Write a message to an output GIF file.
 */
    int
GIFmessage(Metafile **mf, int num, Gchar *string)
{
				/* Noop */
    msgWarn("GIFmessage: Don't support this feature\n");
    return OK;
}
/*
 * Open an output GIF file.
 */
    int
GIFmoOpen(WS_STATE_PTR ws)
{
  /* Output file not opened or written to until flushed */

    Gint status = 1;
    initLogFlag();
    assert(ws != NULL);
    assert(ws->wscolour <= gdMaxColors);
    if ((ws->mf.cgmo = (mf_cgmo*)umalloc(sizeof(mf_cgmo))) != NULL) {
	mf_cgmo	*cgmo	= ws->mf.cgmo;
	cgmo->ws = ws;

	if (find_meta(cgmo) != 0){
	  msgWarn("GIFmoOpen:metafile already open\n");
	} else {
	  create_meta(cgmo, DefaultSize, DefaultSize);
	  
	  cgmo->ws = ws;
	  cgmo->type = MF_GIF;
	  unlink(ws->conn);
	  status = OK;
	}
    }
    return status;
}
Exemple #7
0
/*
 * Redraw all segments in an output PostScript file.
 */
    int
CAIROredrawAllSeg(Metafile **mf, int num)
{
				/* Noop */
  msgWarn("CAIROredrawAllSeg: Don't support this feature\n");
  return OK;
}
Exemple #8
0
/*
 * Set the update flag in an output PostScript file.
 */
     int
CAIROupdate(Metafile **mf, int num, Gregen regenflag)
{
				/* Noop */
  msgWarn("CAIROupdate: Don't support this feature\n");
  return OK;
}
static void set_fillStyle(GIFmetafile *meta, Gint attr)
{
  if (attr < 0 || attr > 1){
    msgWarn("set_fillStyle: Unsupported fill type %d\n", attr);
    attr = 1;
  }
  meta->fillStyleIndex = attr;
}
int
GIFsetGraphAttr(Metafile *mf, int num, Gint code, Gint attr)
{
  int		imf;
  mf_cgmo		**cgmo	= &mf->cgmo;
  for (imf = 0; imf < num; ++imf) {
    GIFmetafile *meta = find_meta(cgmo[imf]);
    assert(meta);
    switch(code){
    case GKSM_POLYLINE_INDEX:
      set_lineColor(meta, attr, GBUNDLED);
      set_lineWidth(meta, 0.0, attr, GBUNDLED);
      set_lineStyle(meta, attr, GBUNDLED);
      break;
    case GKSM_POLYLINE_COLOUR_INDEX:
      set_lineColor(meta, attr, GINDIVIDUAL);
      break;
    case GKSM_LINETYPE:
      set_lineStyle(meta, attr, GINDIVIDUAL);
      break;
    case GKSM_TEXT_COLOUR_INDEX:
      unsupported("GIFsetGraphAttr : GKSM_TEXT_COLOUR_INDEX", attr);
      break;
    case GKSM_FILL_AREA_COLOUR_INDEX:
      set_fillColor(meta, attr);
      break;
    case GKSM_FILL_AREA_STYLE_INDEX:
      set_fillStyle(meta, attr);
      break;
    case GKSM_POLYMARKER_COLOUR_INDEX:
      unsupported("GIFsetGraphAttr : GKSM_POLYMARKER_COLOUR_INDEX", attr);
      break;
    case GKSM_FILL_AREA_INDEX:
      unsupported("GIFsetGraphAttr : GKSM_FILL_AREA_INDEX", attr);
      break;
    case GKSM_MARKER_TYPE:
      unsupported("GIFsetGraphAttr : GKSM_MARKER_TYPE", attr);
      break;
    case GKSM_POLYMARKER_INDEX:
      unsupported("GIFsetGraphAttr : GKSM_POLYMARKER_INDEX", attr);
      break;
    case GKSM_PICK_IDENTIFIER:
      unsupported("GIFsetGraphAttr : GKSM_PICK_IDENTIFIER", attr);
      break;
    case GKSM_TEXT_INDEX:
      unsupported("GIFsetGraphAttr : GKSM_TEXT_INDEX", attr);
      break;
    default:
      msgWarn("GIFsetGraphAttr: Unknown code %d\n", code);
    }
  }
  return OK;
}
void GIFresize(WS_STATE_PTR ws, Gpoint size)
{
  mf_cgmo *cgmo = ws->mf.cgmo;
  GIFmetafile *meta = find_meta(cgmo);
  assert(meta);
#if 0
  if (meta->resize == 0){
    msgErr("GIFresize: metafile contains primitives -- can't resize\n");
  } else {
    copy_meta(cgmo, find_meta(cgmo), size.x, size.y);
    msgInfo("GIFresize: Resizing to (%f,%f)\n", size.x, size.y);
  }
#endif
  if (meta->resize == 0){
    msgWarn("GIFresize: metafile contains primitives that will be lost when resizing\n");
  } 
  copy_meta(cgmo, find_meta(cgmo), size.x, size.y);
  msgInfo("GIFresize: Resizing to (%f,%f)\n", size.x, size.y);
}
/*
 * Set the size of graphics in an output GIF file.
 */
    int
GIFsetGraphSize(Metafile *mf, int num, Gint code, double size)
{
    int imf;
    mf_cgmo		**cgmo	= &mf->cgmo;

    for (imf = 0; imf < num; ++imf){
      GIFmetafile *meta = find_meta(cgmo[imf]);
      assert(meta);
      switch(code){
      case GKSM_LINEWIDTH_SCALE_FACTOR:
	set_lineWidth(meta, size, 0, GINDIVIDUAL);
	break;
      case GKSM_CHARACTER_EXPANSION_FACTOR:
      case GKSM_MARKER_SIZE_SCALE_FACTOR:
      case GKSM_CHARACTER_SPACING:
	return OK;		/* Ignore */
      default:
	msgWarn("GIFsetGraphSize: Unknown code %d\n", code);
	return OK;
      }
    }
    return OK;
}
Exemple #13
0
int
dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver,
		char *ipaddr, char *gateway, char *netmask)
{
    char tempbuf[1024];
    char optbuf[1024], *optname = NULL;
    char *tptr;
    int endedflag = 0;
    int leaseflag = 0;
    FILE *fp;
    enum { P_NOSTMT, P_NOSTMT1, P_STMT, P_STMTLINE } state;

    if ((fp = fopen(file, "r")) == NULL) {
	msgDebug("error opening file %s: %s\n", file, strerror(errno));
	return -1;
    }

    state = P_NOSTMT;
    while (fscanf(fp, "%1023s", tempbuf) > 0) {
    	switch (state) {
	case P_NOSTMT:
	    state = P_NOSTMT1;
	    if (!strncasecmp(tempbuf, "lease", 5)) {
		if (!leaseflag)
		    leaseflag = 1;
		else {
		    fclose(fp);
		    return 0;
		}
	    }
	    break;

	case P_NOSTMT1: 
	    if (tempbuf[0] != '{') {
		msgWarn("dhcpParseLeases: '{' expected");
		fclose(fp);
		return -1;
	    }
	    state = P_STMT;
	    break;

	case P_STMT:
	    if (!strncasecmp("option", tempbuf, 6))
		continue;
	    if (tempbuf[0] == '}') {
		state = P_NOSTMT;
		leaseflag = 0;
		continue;
	    }
	    if (!leaseflag) 
		break;
	    if (tempbuf[0] == ';') { 	/* play it safe */
		state = P_STMT;
		continue;
	    }
	    if ((tptr = (char *)strchr(tempbuf, ';')) && (*(tptr + 1) == 0)) {
		*tptr = '\0';
		endedflag = 1;
	    }
	    if (!isalnum(tempbuf[0])) {
		msgWarn("dhcpParseLeases: bad option");
		fclose(fp);
		return -1;
	    }
	    if (optname)
		free(optname);
	    optname = strdup(tempbuf);
	    if (endedflag) {
		state = P_STMT;
		endedflag = 0;
		continue;
	    }
	    state = P_STMTLINE;
	    break;

	case P_STMTLINE:
	    if (tempbuf[0] == ';') {
		state = P_STMT;
		continue;
	    }
	    if ((tptr = (char *)strchr(tempbuf, ';')) && (*(tptr + 1) == 0)) {
		*tptr = '\0';
		endedflag = 1;
	    }
	    if (tempbuf[0] == '"') {
		if (sscanf(tempbuf, "\"%[^\" ]\"", optbuf) < 1) {
		    msgWarn("dhcpParseLeases: bad option value");
		    fclose(fp);
		    return -1;
		}
	    }
	    else
		strcpy(optbuf, tempbuf);

	    if (!strcasecmp("host-name", optname)) {
		strcpy(hostname, optbuf);
	    } else if (!strcasecmp("domain-name", optname)) {
		strcpy(domain, optbuf);
	    } else if (!strcasecmp("fixed-address", optname)) {
		strcpy(ipaddr, optbuf);
	    } else if (!strcasecmp("routers", optname)) {
		if((tptr = (char *)strchr(optbuf, ',')))
		    *tptr = '\0';
		strcpy(gateway, optbuf);
	    } else if (!strcasecmp("subnet-mask", optname)) {
		strcpy(netmask, optbuf);
	    } else if (!strcasecmp("domain-name-servers", optname)) {
		/* <jkh> ...one value per property */
		if((tptr = (char *)strchr(optbuf, ',')))
		    *tptr = '\0';
		strcpy(nameserver, optbuf);
	    }
	    if (endedflag) {
		state = P_STMT;
		endedflag = 0;
		continue;
	    }
	    break;
	}
    }
    fclose(fp);
    return 0;
}
/*
 * Set the text-path in an output GIF file.
 * Unsupported
 */
    int
GIFsetTextPath(Metafile *mf, int num, Gtxpath path)
{
    msgWarn("GIFsetTextPath: Don't support this feature\n");
    return OK;
}
/*
 * Set the character up-vector and character height in an output GIF file.
 * Unsupported.
 */
    int
GIFsetCharUp(Metafile *mf, int num, Gpoint *up, Gpoint *base)
{
    msgWarn("GIFsetCharUp: Don't support this feature\n");
    return OK;
}
/*
 * Set the text-alignment in an output GIF file.
 * Unsupported
 */
    int
GIFsetTextAlign(Metafile *mf, int num, Gtxalign *align)
{
    msgWarn("GIFsetTextAlign: Don't support this feature\n");
    return OK;
}
    int
GIFoutputGraphic(Metafile *mf, int num, Gint code, Gint num_pt, Gpoint *pos)
{
    int		imf;
    mf_cgmo		**cgmo	= &mf->cgmo;
    for (imf = 0; imf < num; ++imf) {
	Gint	i;
	GIFmetafile *meta = find_meta(cgmo[imf]);
	assert(meta);
	assert(num_pt > 0);
	meta->resize = 0;	/* Not OK to resize */


	/*
	  Trivial accept and reject clipping of points.
	*/
	{
	  int xlo = 1, xhi = 1, yhi = 1, ylo = 1;
	  Gfloat lolimit = -1, hilimit = 2;
	  int i;
	  for (i=1; i < num_pt; ++i){
	    float x = pos[i].x; 
	    float y = pos[i].y;
	    xlo &= (x < lolimit);
	    xhi &= (x > hilimit);
	    ylo &= (y < lolimit);
	    yhi &= (y > hilimit);
	  }
	  if (xlo || xhi || ylo || yhi)
	    return OK;
	    
	  /* If any points are extreme, toss the polygon. Someday,
             there will be a real clipping algorithm */
	  for (i=1; i < num_pt; ++i){ 
	    float x = pos[i].x; 
	    float y = pos[i].y; 
	    if (x < -10. || x > 10. || y < -10 || y > 10){ 
	      msgWarn("GIFoutputGraphic: Bad NDC point %f %f\n", 
		      x, y); 
	      return OK; 
	    } 
	  }
	}
	

	switch(code){
	case GKSM_FILL_AREA:
	  {
	    gdPointPtr tpts = (gdPointPtr)umalloc(sizeof(gdPoint) * num_pt);
	    assert(tpts);
	    xform(meta, pos->x, pos->y, &tpts[0].x, &tpts[0].y);
#ifdef DEBUG
	    printf("--------------------------------------\n");
	    printf("Transform: (%f, %f) -> (%d,%d)\n",
		pos->x, pos->y, tpts[0].x, tpts[0].y);   
#endif
	    ++pos;
	    for (i=1; i < num_pt; ++i, ++pos){
	      xform(meta, pos->x, pos->y, &tpts[i].x, &tpts[i].y);
#ifdef DEBUG
	      printf("Transform: (%f, %f) -> (%d,%d)\n",
		     pos->x, pos->y, tpts[i].x, tpts[i].y);   
#endif
	    }
	    if (meta->fillStyleIndex == 0){
	      gdImagePolygon(meta->image, tpts, num_pt, meta->fillIndex);
	    } else {
				/* Eliminate colinear points (bug in gd.c) */
	      stripColinear(tpts, &num_pt);
	      gdImageFilledPolygon(meta->image, tpts, num_pt,
				   meta->fillIndex);
	    }
	    free(tpts);
	  }
	break;
	case GKSM_POLYLINE:
	  {
	    int lineIndex = meta->styleIndex == 1 ? meta->lineIndex 
	      : gdStyled; 
	    gdPointPtr tpts = (gdPointPtr)umalloc(sizeof(gdPoint) * num_pt);
	    assert(tpts);
	    for (i=0; i < num_pt; ++i, ++pos){
	      xform(meta, pos->x, pos->y, &tpts[i].x, &tpts[i].y);
	    }
	    gdImageWideLines(meta->image, tpts, num_pt,
			     lineIndex, meta->lineWidth);

	    free(tpts);
	  }
	break;
	case GKSM_POLYMARKER:
	  msgWarn("GIFoutputGraphics: polymarker unsupported\n");
	  break;
	default:
	  msgWarn("GIFoutputGraphics: Unknown code %d\n", code);
	}
    }
    return OK;
}
/*
 * Set the pattern reference-point in an output GIF file.
 */
    int
GIFsetPatRefpt(Metafile *mf, int num)
{
    msgWarn("GIFsetPatRefPt: Don't support this feature\n");
    return OK;
}
/*
 * Set the pattern size in an output GIF file.
 */
    int
GIFsetPatSize(Metafile *mf, int num)
{
    msgWarn("GIFsetPatSize: Don't support this feature\n");
    return OK;
}
static void unsupported(char *message, int attr)
{
  msgWarn("%s: Unsupported call -- argument %d\n", message, attr);
}
/*
 * Set the line and marker representation in an output GIF file.
 */
    int
GIFsetLineMarkRep(Metafile *mf, int num, Gint code, Gint idx, Gint type, double size, Gint colour)
{
    msgWarn("GIFsetLineMarkRep: Don't support this feature\n");
    return OK;
}
/*
 * Set the font precision in an output GIF file.
 * Unsupported
 */
    int
GIFsetTextFP(Metafile *mf, int num, Gtxfp *txfp)
{
    msgWarn("GIFsetTextFP: Don't support this feature\n");
    return OK;
}
Exemple #23
0
    int
CAIROcellArray(Metafile *mf, int num, Gpoint *ll, Gpoint *ur, Gpoint *lr, Gint row, Gint *colour, Gipoint *dim)
{
  msgWarn("CAIROcellArray: Don't support this feature\n");
  return OK;
}
/*
 * Set the pattern representation in an output GIF file.
 */
    int
GIFsetPatRep(Metafile *mf, int num, Gint idx, Gptbundl *rep)
{
    msgWarn("GIFsetPatRep: Don't support this feature\n");
    return OK;
}
/*
 * Set the viewport limits in an output GIF file.
 */
    int
GIFsetLimit(Metafile *mf, int num, Gint code, Glimit *rect)
{
    msgWarn("GIFsetLimit: Don't support this feature\n");
    return OK;
}
/*
 * Write text to an output GIF file. Unsupported
 */
    int
GIFtext(Metafile *mf, int num, Gpoint *at, Gchar *string)
{
    msgWarn("GIFtext: Don't support this feature\n");
    return OK;
}