Re: [fpc-pascal] TStringStream.DataString returns garbage?
In our previous episode, Jorge Aldo G. de F. Junior said: > I would vote for a new function on all stream types to allow writing > strings in the expected way There is no default way to stream a string. On textfiles you only stream contents, on binary files usually a length field (which can be 1,2,4 bytes depending on format) + contents. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringStream.DataString returns garbage?
On Fri, 3 Feb 2012, Marco van de Voort wrote: In our previous episode, Jorge Aldo G. de F. Junior said: I would vote for a new function on all stream types to allow writing strings in the expected way There is no default way to stream a string. On textfiles you only stream contents, on binary files usually a length field (which can be 1,2,4 bytes depending on format) + contents. The latter exists: http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html We could make an optional parameter "AsText : Boolean = False" which would then write the former. Downside is that the 'read' operation will not be able to read the text form. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringStream.DataString returns garbage?
In our previous episode, michael.vancann...@wisa.be said: > > On textfiles you only stream contents, on binary files usually a length > > field (which can be 1,2,4 bytes depending on format) + contents. > > The latter exists: > > http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html > > We could make an optional parameter "AsText : Boolean = False" which would > then write the former. > > Downside is that the 'read' operation will not be able to read the text form. If necessary I would simply add a separate version "writetext", and not multiplex it on writeansistring. But as said this is all a slippery slope, specially with unicode profileration ahead. We are going writeunicodestring sooner or later :-) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringStream.DataString returns garbage?
On Fri, 3 Feb 2012, Marco van de Voort wrote: In our previous episode, michael.vancann...@wisa.be said: On textfiles you only stream contents, on binary files usually a length field (which can be 1,2,4 bytes depending on format) + contents. The latter exists: http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html We could make an optional parameter "AsText : Boolean = False" which would then write the former. Downside is that the 'read' operation will not be able to read the text form. If necessary I would simply add a separate version "writetext", and not multiplex it on writeansistring. But as said this is all a slippery slope, specially with unicode profileration ahead. We are going writeunicodestring sooner or later :-) Exactly the reason for multiplexing it. It reduces proliferation. But I'm not exactly convinced that this kind of call is needed. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringStream.DataString returns garbage?
On Fri, Feb 3, 2012 at 9:39 AM, wrote: > http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html > We could make an optional parameter "AsText : Boolean = False" which would > then write the former. I think this would be a nice addition. One thing I would suggest is using a more clear wording. "AsText" might be hard to understand what the author ment. Either with the length or without it is still text in a certain way. A more clear wording could be: AWriteTextContentsOnly: Boolean = False or AWriteStringLength: Boolean = True -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] replace one field of a record in a collection...
Am 02.02.2012 21:22, schrieb waldo kitty: On 2/1/2012 17:13, Sven Barth wrote: Are you storing pointers to records in your collection? If so then just replace the field's value. The change will then be immediately visible for every other code part that holds a reference to this record. thanks for your reply, sven... you've been a big help with your responses to my questions... in answer to your question, yes... the collections are storing pointers to the records and the records are also pointers to the data (i think!)... i'm using this line to replace the data in the collection with the new data if they are not already the same... PSCRec(aSatCatColl^.At(idx))^.satname^ := asatname; the data is changing but i'm suspecting that i need to be doing something more because with the above line in place, i'm getting a lot of errors like the following... i suspect the problem is that the data being replaced is a different length that the replacement data?? if i comment out the above line, my program runs with no errors at all... What is satname? A pointer to a ShortString or a pointer to a AnsiString? Did some other part of your code catch (and cache ^^) a reference to that string? Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringStream.DataString returns garbage?
In our previous episode, michael.vancann...@wisa.be said: > > If necessary I would simply add a separate version "writetext", and not > > multiplex it on writeansistring. But as said this is all a slippery slope, > > specially with unicode profileration ahead. We are going writeunicodestring > > sooner or later :-) > > Exactly the reason for multiplexing it. It reduces proliferation. Not really. You try to hide it, and only frustrate smartlinking in the process. I would rather introduce a default parameter for the length size (leaving it at 4, for legacy) and endianess. > But I'm not exactly convinced that this kind of call is needed. I've thought about it several times, but the trouble is that once you start to think of it, the number gets out of hand so fast. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpc 2.6.0 for arm-embedded
Hi, I just had some time to look into this again. I downloaded the latest 2.6.0 sources and mostly followed http://wiki.freepascal.org/TARGET_Embedded to make a crosscompiler. In /usr/lib/fpc/2.6.0 there is a ppcrossarm with a date of today when I run ppcrossarm -i. But when I try fpc -Parm -Tembedded -Wplpc2124 -Cparmv7m I get an error : Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127 Is this expexted ? If yes, then the wiki should be updated. If it matters, I'm using OpesSuse 12.1. Another thing that puzzles me : the wiki says to use SUBARCH=armv7m for cortex-m3. ppcrossarm -i says there are cpu instruction sets for ARMV3 ARMV4 ARMV5 ARMV6 ARMV7 ARMV7M CORTEXM3 Should I use SUBARCH=cortexm3 to compile the compiler to use it with STM32-processors, which are cortex-m3 ? Or should I just compile the applications with -Cpcortexm3 ? Thanks for any info. Regards, Koenraad Lelong. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpc 2.6.0 for arm-embedded
Koenraad Lelong wrote: Hi, I just had some time to look into this again. I downloaded the latest 2.6.0 sources and mostly followed http://wiki.freepascal.org/TARGET_Embedded to make a crosscompiler. In /usr/lib/fpc/2.6.0 there is a ppcrossarm with a date of today when I run ppcrossarm -i. But when I try fpc -Parm -Tembedded -Wplpc2124 -Cparmv7m I get an error : Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127 Is this expexted ? If yes, then the wiki should be updated. If it matters, I'm using OpesSuse 12.1. Since nobody else has responded: what does fpc -h|head give you? That error 127 can be caused by the symlink from (e.g.) /usr/local/bin/ppcarm pointing to a file that doesn't exist. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpc 2.6.0 for arm-embedded
Den 03-02-2012 13:23, Koenraad Lelong skrev: Hi, I just had some time to look into this again. I downloaded the latest 2.6.0 sources and mostly followed http://wiki.freepascal.org/TARGET_Embedded to make a crosscompiler. In /usr/lib/fpc/2.6.0 there is a ppcrossarm with a date of today when I run ppcrossarm -i. But when I try For anything arm-embedded, it would probably be a better idea to use the latest SVN version. Simply because arm-embedded is a much less used and tested branch, the functionality might be slower to get into releases. In SVN trunk the distinction between Cortex-M3 and ARMv7M is removed and everything has been changed to ARMv7M. This is why the wiki page only mentions ARMv7M. fpc -Parm -Tembedded -Wplpc2124 -Cparmv7m I get an error : Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127 Is this expexted ? If yes, then the wiki should be updated. No, fpc should be trying to call ppcrossarm(since you are crosscompiling, I guess. I suppose you don't work on an ARM host). I don't know why it doesn't do that in your case, might be related to the way it was originally built for your platform. If it matters, I'm using OpesSuse 12.1. Another thing that puzzles me : the wiki says to use SUBARCH=armv7m for cortex-m3. ppcrossarm -i says there are cpu instruction sets for ARMV3 ARMV4 ARMV5 ARMV6 ARMV7 ARMV7M CORTEXM3 Should I use SUBARCH=cortexm3 to compile the compiler to use it with STM32-processors, which are cortex-m3 ? Or should I just compile the applications with -Cpcortexm3 ? Thanks for any info. Regards, Koenraad Lelong. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] replace one field of a record in a collection...
On 2/3/2012 05:07, Sven Barth wrote: Am 02.02.2012 21:22, schrieb waldo kitty: PSCRec(aSatCatColl^.At(idx))^.satname^ := asatname; the data is changing but i'm suspecting that i need to be doing something more because with the above line in place, i'm getting a lot of errors like the following... i suspect the problem is that the data being replaced is a different length that the replacement data?? if i comment out the above line, my program runs with no errors at all... What is satname? A pointer to a ShortString or a pointer to a AnsiString? Did some other part of your code catch (and cache ^^) a reference to that string? ummm... the record that contains satname has satname as a type pstring... i did try converting asatname to pstring but then ran into all kinds of stuff that had to be altered and then everything fell apart even worse so i backed out of that... as i've written before, pointer stuff is very alien to me... i'm extremely used to working with the old style 64k limitations and where strings were simply pascal strings :? i can post code if needed but i'm not sure what really need to break down into small bits for posting :? there are times that i truly hate not being "college educated" in this stuff but i've been at it for 30+ years and it would be a hard row to how at this point in time to try to go back and learn it all again... but i am, kinda on that road as it is... one of these days i *will* grok it... hopefully sooner than later ;) should i post (again) the type structures? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : [fpc-pascal] Synapse: SSH client+cryptlib+private key
> > Hi all, > > I've been fiddling with connecting to an SSH server. > > Thanks to Ludo Brands' help I can use username/password with > Synapse (stable)+cryptlib. I'm fiddling and trying to get > private key authentication to work. > > While this compiles and runs, Ethereal shows SSH traffic just > stops.. (on a host that requires private key auth). > > What am I doing wrong (and/or is this even possible - Synapse > docs don't seem to indicate yes or no). > > Thanks, > Reinier > After some "fiddling" I finally got it working. There are some more fields needed for private key authorization: FTelnetSend.Sock.SSL.PrivateKeyFile:='path to pkcs#15 formated key file'; TSSLCryptLib(FTelnetSend.Sock.SSL).PrivateKeyLabel:='the label that identifies the private key in the key file'; FTelnetSend.Sock.SSL.KeyPassword:='the passphrase for the key file'; The first line is the most difficult to sort out. ssh_keygen nor openssl support pkcs#15. The pkcs#15 format is used in crypto cards but almost never in files. A little howto (perhaps there are shorter routes but I haven't found one): -Fire up your linux system -Modify /etc/ssl/openssl.conf and change/add the line "keyusage cRLSign,keyCertSign,nonRepudation,digitalSignature,keyEncipherment". Openssl doesn't use keyusage internally but cryptlib is picky about this. I doubt all of the settings are required for SSH but this works for me. Note that there are several keyusage lines in the conf file. Modify them all if you are lazy (I did) ;) -Create a private key and self signed cert with "openssl req -x509 -days 365 -newkey rsa: -nodes -keyout id_rsa.key -out id_rsa.crt" -If you haven't already installed cryptlib, download cl332.zip, unzip with -a in the dir of your choice and run "make" and "make shared". Copy libcl.a and libcl.so.3.3.2 to your system library dir. Create symlink libcl.so. -Download pemtrans from http://toroid.org/ams/pemtrans. Modify makefile to adapt paths for libraries and header files. "make" -run "pemtrans id_rsa.key id_rsa.crt id_rsa.p15 label p15pass". id_rsa.p15 is the file you assign to PrivateKeyFile, label is the string assigned to PrivateKeyLabel and p15pas is assigned to KeyPassword. Note that KeyPassword (p15pass) has nothing to do with the pass phrase for the private key use. It is a password protection for access to the private key in the p15 file. Here we have created a private key without pass phrase(-nodes). The label is an identification for the private key since p15 files can contain multiple keys. -now we need to transfer the public key to the ssh server. First we need to extract it from our key file: "chmod 600 id_rsa.key" then "ssh-keygen -y -f id_rsa.key > id_rsa.pub". ssh-keygen refuses to use a key-file that has group or world read access, hence the chmod. -transfer to host identified by hostname: "ssh-copy-id -i id_rsa.pub hostname". Enter password for user at hostname when prompted. If local user name and remote user name are different use "ssh-copy-id -i id_rsa.pub remoteuser@hostname" -test your config with "ssh -i id_rsa.key hostname" or "ssh -i id_rsa.key remoteuser@hostname" That's it. Ludo ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal