On 2009-07-07 11:06-0400 Hazen Babcock wrote:

> Alan W. Irwin wrote:
>> plLibOpenPdfstrm currently tries a large number of standard locations
>> (including the current directory) to find the file specified.
>
> Any pointers for using this function? When I try:
> fp = (FILE *)plLibOpenPdfstrm(filename);
>
> instead of:
> fp = fopen(filename, "r");
>
> I get a segmentation fault at my first attempt to read from the file:
> fscanf(fp, "%d\n", &number_colors);
>
> My guess was that this was due to the fact that it opens the file in "rb" 
> mode instead of "r" mode, but when I modified it to use "r" mode I still got 
> the same segfault.

Both plsym.c and plmap.c use routines in pdfutils.c to actually read the
file they open with plLibOpenPdfstrm.  So you might want to do the same
(using pdf_rd_header?) or else adapt the file access methods in the
pdfutils.c code for the colour palette reading needs.

An additional format issue I just thought of for these ascii colour palette
files is line endings.  Presumably some of our Windows users will want to
edit these files directly (since they have no access to -dev tk or the
associated colour palette GUI) so the resulting ascii files will have the
Windows line endings (\cr followed by \nl as opposed to the Unix \nl).
Also, assuming that we use the svn native line ending property for these
files, our Windows users will checkout a version of our official palette
files that have the windows line endings. I presume the Windows line endings
means the null-terminated string returned by pdf_rd_header will have a \cr
prepended to that null termination which will require a bit of care
when parsing that string (or a special provision in pdf_rd_header to
remove the \cr if it exists and the platform is windows).

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to