gunzip and base64 decode a string


 
Thread Tools Search this Thread
Top Forums Programming gunzip and base64 decode a string
# 1  
Old 10-20-2004
gunzip and base64 decode a string

I am writing a C program to get messages from a JMS queue into a string variable and then write them to a database.

The messages are compressed (gzip) and encoded (base64), so I need to be able to perform gunzip and base64 decode inside the C. I don't want to write any of the messages to file so i need to work on the string.

Is this possible?
# 2  
Old 10-23-2004
CPU & Memory

if it is base 64 i would guess to declare the string a variable you would use a double precision float and use the ascii code to convert the number to characters.. and use system() to gunzip the string. it sounds easy it should be simple to define a max number of characters for the string and memalloc the string into a buffer. then transfer it to the database using strncat.. i think you are just making matters a little complex with your script which is easy to do in C.. just keep it simple..
moxxx68
hope that answers your question..
# 3  
Old 10-23-2004
Re: gunzip and base64 decode a string

Quote:
Originally posted by handak9
I am writing a C program to get messages from a JMS queue into a string variable and then write them to a database.

The messages are compressed (gzip) and encoded (base64), so I need to be able to perform gunzip and base64 decode inside the C. I don't want to write any of the messages to file so i need to work on the string.

Is this possible?
You don't need to write to a file to use an external utility. You can use a pipe to make the utility process the data incrementally. See popen(3). If using gzip(1), be you gotta be careful about deadlocks here (check with select(2) if gzip needs to input or output or else the 2 processes might end up waiting on each other). If the thing is that you do not want to fork()+exec() because there are A LOT of JMS messages and that would be too slow, then AFAIK zlib(3) can be used to decompress gzip output and you can find tons of base64 C code on the web.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Base64 conversion in awk overlaps

hi, problem: output is not consistent as expected using external command in AWK description: I'm trying to convert $2 into a base64 string for later decoding, and for this when I use awk , I'm getting overlapped results , or say it results are not 100% correct. my code is: gawk... (9 Replies)
Discussion started by: busyboy
9 Replies

2. UNIX for Beginners Questions & Answers

Ldapsearch returning base64 encoded results

So my ldapsearch works great, except for some results I found today. My search is: /usr/lib64/mozldap/ldapsearch -T -h 10.1.1.1 -p 3891 -D "uid=datapower,ou=People,dc=blah,dc=com" -w xxxxxx -b "ou=Certs,dc=blah,dc=com"... (0 Replies)
Discussion started by: primerib
0 Replies

3. Shell Programming and Scripting

Rearrange a file (2000 base64 strings in 1 row into 1 string by rows)

I have 1 row which contains abouts 20000 base64 string. e.g: /p4bdllBS8qcvW/69GUYej8nEv6gwt7UAYl0g==WZdjwTUQX9UEKsT/zWaZdQ==uI would like rearrange this file by base64 strings. So the output should be this ( 1 string in 1 row): 69GUYej8nEv6gwt7UAYl0g== WZdjwTUQX9UEKsT/zWaZdQ==How could I do... (4 Replies)
Discussion started by: freeroute
4 Replies

4. UNIX for Dummies Questions & Answers

Why are there LFs in my base64?

And is there a good way of taking them out? I've been playing around a bit with using b64 to embed images in HTML (and trying to stay within the spec). I've noticed that with openssl's base64 encoder, the output files have newline characters @ every 65th column or so. This renders them useless,... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

5. UNIX for Dummies Questions & Answers

mailx saved messages are unreadable (base64)

I am trying to parse emails sent from a blackberry. I am using fetchmail to download email through IMAP from my exchange server and then forward to local Linux mail. (This part works fine.) When viewing and saving messages sent as plain text from Outlook, everything works fine. However, when... (1 Reply)
Discussion started by: Squeakygoose
1 Replies

6. UNIX for Dummies Questions & Answers

not able to run base64 exe

Hi, I have copied base64.exe under base64-1.3 folder and i am trying to run base64.exe from another folder called Request. But i am getting the following error message. mga.ksh: base64: not found Please let me know how to execute the base64.exe from a directory where it is not installed. ... (0 Replies)
Discussion started by: lotus123
0 Replies

7. UNIX for Dummies Questions & Answers

I'm looking for someone who have Base64 binary

I need to install the base64 encryption method on a UNIX machine under AIX5.2. I've received a tar file but it is only C source , can you help me please. (sending me a binary base64 or to compile my source) Thanks by advance (3 Replies)
Discussion started by: Bruno_LAMOUR
3 Replies
Login or Register to Ask a Question