× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Scott,

Sorry for the delay in response. 

Right you are - they are IBM's utilities - my bad, but you made them 
understandable to us mere IT mortals.  Very nice articles - Thanks!

Yes, it's a PGP encrypted file.  I just want to read the first few bytes, 
so I can tell if it's encrypted or not.  Then I can branch to the decrypt 
routines if it's a PGP file and leave it alone if it's not.

Hex from debug...
> EVAL data:x 
     00000     2D2D2D2D 2D424547 494E2050 4750204D   - .....âáåñ+.&å&.( 
     00010     45535341 47452D2D 2D2D2D40 40404040   - áëë åá..... 
     00020     40404040 40404040 40404040 40404040   - 
     00030     4040.... ........ ........ ........   -   .............. 

(once again - LPEX editor looks like ...   "-----BEGIN" )


On the code page 437  - the file attributes say that it's a codepage of 
437.

I'm still working on trying to get the value of errno.

Thanks again!


Jeff Stevens
Mize, Houser & Co. P.A.
913 451 1882
JStevens@xxxxxxxxxxxxxx





Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
06/30/2005 12:38 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
cc

Subject
Re: IFS STMF file read - Codepage problem?







> I'm using Scott's utility for reading a text IFS file.  The file has a
> heading,

These are IBM APIs, not my utilities! :)

> The top of the file looks like this...
> -----BEGIN

PEM encoded digital certificate?


> My code looks like this...
>
>    H DFTACTGRP(*NO)
>
>      /copy QSRC,ifsio_h
>
>     D fd              s             10I 0
>     D data            s             50A
>     D wait            s              1A
>
>      /free
>
>        fd = open('/testfile.asc': O_RDONLY );
>        if (fd < 0);
>            dsply ('Something went wrong, open() failed.') '' wait;
>           return;
>        endif;
>

>        if read(fd: %addr(data): 10) < 10;
>            dsply ('The file does not have 10 bytes to read!') '' wait;
>            return;
>        endif;

This isn't the problem, but... you should have a "callp close(fd)" prior 
to the RETURN statement here.  Otherwise, if the file doesn't have 10 
characters, your program will end without ever closing it.


> However, when I look at the field Data in DEBUG - it looks like this?
> DATA = 'âáåñ+&å&(áëë åá                       '

Can you (in debug, at the same statement) type the following:

    eval data:x

This will give us a view of the data in hex, which might be helpful. You 
should do this WITHOUT specifying O_TEXTDATA so that we know what the 
actual hex values of the bytes in the file are.

> Code page on the file is 437.
> I've tried "O_TEXTDATA", but when I try that - it returns fd of "-1".

Can you tell us what the value of errno is when you receive the -1? More 
info about errno can be found on my Web site at the following link:
http://www.scottklement.com/rpg/ifs_ebook/errors.html

O_TEXTDATA should definitely be used when you're reading a file that's in 
ASCII -- I suspect that this is the problem, but without knowing what 
"errno" is, I have no idea why open() is returning a -1.

When you say the codepage is 437, do you mean that the data in the file is 

in codepage 437, or that the file's attributes are set to 437, or both? In 

other words, do the hex values of the data in the file (obtained by 
calling debug with :x) make sense for the codepage that you've assigned to 

the file?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.