void RendererCreator::generateBuildFile()
{
    QString widgetName( iUi.widgetName().toLower() );

    replaceData("data/renderingplugin/group/bld.inf",
                 widgetName + "/renderingplugin/group/bld.inf");
}
void RendererCreator::generateSource()
{
    QString widgetName( iUi.widgetName().toLower() );
    QString rendererName( iUi.rendererName().toLower() );

    replaceData("data/renderingplugin/src/renderer.cpp",
                widgetName + "/renderingplugin/src/" + rendererName +  "renderer.cpp");
}
void RendererCreator::generateHeader()
{
    QString widgetName( iUi.widgetName().toLower() );
    QString rendererName( iUi.rendererName().toLower() );

    replaceData("data/renderingplugin/inc/renderer.h",
                 widgetName + "/renderingplugin/inc/" + rendererName +  "renderer.h");
}
void RendererCreator::generateMMP()
{
    QString widgetName( iUi.widgetName().toLower() );
    QString rendererName( iUi.rendererName().toLower() );

    replaceData("data/renderingplugin/group/renderer.mmp",
                widgetName + "/renderingplugin/group/" + rendererName +  "renderer.mmp");
}
Ejemplo n.º 5
0
static int lreplace( gdcm::Tag const &t, const char *value, gdcm::VL const & vl, gdcm::DataSet &ds ) {
    if ( t.GetGroup() < 0x0008 ) return 0;

    if ( t.IsPrivate() && vl == 0 && ds.FindDataElement( t ) ) {
	gdcm::DataElement de ( ds.GetDataElement( t ) );
	if ( de.GetVR() != gdcm::VR::INVALID ) {
	    if ( de.GetVR() == gdcm::VR::SQ && *value == 0 )
		{ return emptyData( t, ds ); } // Only allowed operation for a Private Tag
	    else { return 0; } //Trying to replace value of a Private Tag
	}
	de.SetByteValue( "", 0 );
	ds.Insert( de );
	return 1;
    } else {
	const gdcm::DictEntry &entry = dicts.GetDictEntry( t );

	if ( entry.GetVR() == gdcm::VR::INVALID || entry.GetVR() == gdcm::VR::UN )
	    { return 0; }

	if ( entry.GetVR() == gdcm::VR::SQ && vl == 0 && value && *value == 0 )
	    { return emptyData( t, ds ); }

	else if ( entry.GetVR() && gdcm::VR::VRBINARY && vl == 0 )
		{ return replaceData( t, ds, entry, "", 0 ); }

	else { // ASCII
	    if ( value ) {
		std::string padded( value, vl);
		if ( vl.IsOdd() && (entry.GetVR() != gdcm::VR::UI) ) { padded += " "; }
		return replaceData( t, ds, entry, padded.c_str(), (gdcm::VL::Type)padded.size() );
	    }
	}
    }

    return 0;
}
Ejemplo n.º 6
0
void KReplaceDialog::slotButtonClicked( int button )
{
    if( button != KDialog::Ok )
        KAbstractFindDialog::slotButtonClicked( button );
    else
    {
        hide();

        rememberCurrentSettings();

        mTool->setSearchData( data() );
        mTool->setReplaceData( replaceData() );
        mTool->setCaseSensitivity( caseSensitivity() );
        mTool->setDoPrompt( prompt() );

        mTool->replace( direction(), fromCursor(), inSelection() );
    }
}
Ejemplo n.º 7
0
int main(int argc, char * argv[])
{
  FILE * fd;
  unsigned long   clen;
  char * data;
  struct stat sbuf;

  char * ptest;

  unsigned long   i;

  int    status;

  unsigned long   len  = 0;
  unsigned long   have = 0;

  /* For compression.
   */
  lzo_byte * inbuf;
  lzo_byte * outbuf;
  int        r;
  lzo_uint   in_len;
  lzo_uint   out_len;

  UINT32 len_raw;
  UINT32 len_cmp;


  astate[0] = EXEPACK_STATE_0;
  astate[1] = EXEPACK_STATE_1;
  astate[2] = EXEPACK_STATE_2;


  if (argc < 4)
    {
      fprintf(stderr, 
	      "Usage: exepack_fill <container_file> <infile> <outfile>\n");
      exit (EXIT_FAILURE);
    }

  if (0 != stat (argv[1], &sbuf))
    {
      fprintf(stderr, "exepack_fill: could not access file %s\n", argv[1]); 
      return (-1);
    }
  clen = sbuf.st_size;


  data = (char *) malloc (clen * sizeof(char));
  if (data == NULL)
    return (-1);

  fd = fopen (argv[1], "r");
  if (fd == NULL)
    return (-1);

  if (clen != fread  (data, 1, clen, fd))
    return (-1);
  fclose (fd);


  /*******************
   *
   * THE DATA
   *
   *******************/



  if (stat (argv[2], &sbuf) < 0)
    {
      perror ("exepack_fill");
      exit (EXIT_FAILURE);
    }
      
  len = (unsigned long) sbuf.st_size;

  /* Because the input block may be incompressible,
   * we must provide a little more output space in case that compression
   * is not possible.
   */
  inbuf  = (lzo_byte *) malloc (sizeof(lzo_byte) * len);
  outbuf = (lzo_byte *) malloc (sizeof(lzo_byte) * (len + len / 64 + 16 + 3));
  in_len = len;

  if (NULL == inbuf || NULL == outbuf)
    {
      fprintf(stderr, "exepack_fill: Out of memory.");
      exit (EXIT_FAILURE);
    }

  if (NULL == (fd = fopen(argv[2], "r")))
    {
      perror ("exepack_fill");
      exit (EXIT_FAILURE);
    }

  have = fread  (inbuf, 1, len, fd);
  fclose (fd);

  if (have != len)
    {
      fprintf (stderr, "exepack_mkdata: Error reading %s", argv[2]);
      exit (EXIT_FAILURE);
    }

  /*
   * Step 1: initialize the LZO library
   */
  if (lzo_init() != LZO_E_OK)
    {
      fprintf(stderr, "exepack_fill: lzo_init() failed\n");
      return 3;
    }

  /*
   * Step 3: compress from `in' to `out' with LZO1X-1
   */
  r = lzo1x_1_compress(inbuf, in_len, outbuf, &out_len, wrkmem);

  if (r == LZO_E_OK)
    printf("exepack_fill: compressed %lu bytes into %lu bytes\n",
	   (long) in_len, (long) out_len);
  else
    {
      /* this should NEVER happen */
      printf("exepack_fill: internal error - compression failed: %d\n", r);
      return 2;
    }

  /* check for an incompressible block 
   */
  if (out_len >= in_len)
    {
      printf("exepack_fill: Incompressible data.\n");
    }
  
  taus_set_from_state (cstate, astate);
  for (i = 0; i < out_len; ++i)
    {
      outbuf[i] ^= (taus_get_long (cstate) & 0xff);
    }

  len_raw = in_len;
  len_cmp = out_len;

  if ( (unsigned long) len_cmp > (unsigned long) clen)
    {
      printf("exepack_fill: Compressed length (%ld) exceeds container length (%ld).\n", (long) len_cmp, (long) clen);
      return (8);
    }
      

  /***********
   *
   * Fill program
   *
   **********/

  status = replaceData (data, clen, "LLLL", (char *) &len_raw, sizeof(UINT32));
  if (status < 0)
    {
      printf("exepack_fill: Could not write raw lenght %d.\n", len_raw);
      return (8);
    }
  status = replaceData (data, clen, "CCCC", (char *) &len_cmp, sizeof(UINT32));
  if (status < 0)
    {
      printf("exepack_fill: Could not write compressed lenght %d.\n", 
	     len_cmp);
      return (8);
    }
  status = replaceData (data, clen, "CONTAINER", (char *) outbuf, out_len);
  if (status < 0)
    {
      printf("exepack_fill: Could not write program data.\n");
      return (8);
    }

  /***********
   *
   * Write program
   *
   **********/

  if ( NULL == (fd = fopen(argv[3], "w" )))
    {
      perror ("exepack_fill");
      exit (EXIT_FAILURE);
    }

  fwrite  (data, 1, clen, fd);

  fclose (fd);

  ptest = my_locate("LLLL", data, clen);
  if (ptest != NULL)
    {
      printf("exepack_fill: ERROR:  program length not updated.\n");
      return (8);
    }
  ptest = my_locate("CCCC", data, clen);
  if (ptest != NULL)
    {
      printf("exepack_fill: ERROR:  compressed program length not updated.\n");
      return (8);
    }
  ptest = my_locate("CONTAINER", data, clen);
  if (ptest != NULL)
    {
      printf("exepack_fill: ERROR:  program data not updated.\n");
      return (8);
    }

  return 0;
}