473,322 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Bundle text/gif file in the shared object

Hi,

How can I bundle a text/gif file in the shared object. Basically I want
to read the content of this text file but I cannot have it seperately
on the disc.

Any clues. ?

Pankaj

Nov 15 '05 #1
6 1924
pa***************@gmail.com wrote:
Hi,

How can I bundle a text/gif file in the shared object. Basically I want
to read the content of this text file but I cannot have it seperately
on the disc.

Any clues. ?


Yes. You are completely on the wrong track when asking that
around here.

Look for a newsgroup or other forum where this is on-topic.
In your place, I would try looking for how E-Mail attachments
work, for example.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #2
In article <11**********************@f14g2000cwb.googlegroups .com>,
<pa***************@gmail.com> wrote:
:How can I bundle a text/gif file in the shared object. Basically I want
:to read the content of this text file but I cannot have it seperately
:on the disc.

C doesn't know what "shared objects" are, but fortunately for you
that part of your question is irrelevant.

Just write a piece of code that reads the object and generates
from that a C source file containing the data in a usable form.

You could do something simple like having the interface be

extern unsigned char the_shared_file[];
extern size_t size_of_the_shared_file[];

or you could go fancier with making the object static (and
thus visible only in the defining file) and providing accessor
routines, possibly even providing an fread_shared_object routine
that mimics fread() in calling parameters.

To generate the necessary C file, the utility C file would read
the entire file into memory, keeping track of how big it was,
and then could write it out even by something as crude as

printf( "size_t size_of_the_shared_file = %lu\n",
(unsigned long) size_of_object );
printf( "unsigned char the_shared_file[] = {\n" );
for (object_index = 0; object_index < size_of_object; object_index++)
printf( "0x%02x,\n", input_object[object_index] );
printf( "};\n" );

It doesn't matter whether you only output one byte per line or
if you pack the bytes into neat rows of 16 or so -- only the
compiler has to look at the generated file once you've debugged the
generating logic.
--
University of Calgary researcher Christopher Auld has found that
milk is the most "rational addiction" amongst the several studied.
Nov 15 '05 #3
pa***************@gmail.com wrote:
Hi,

How can I bundle a text/gif file in the shared object. Basically I want
to read the content of this text file but I cannot have it seperately
on the disc.


If you want to bundle a file's content into your code, it is easy enough.

Write a small program that reads the file and outputs something like
char gif[] = "\nnn\mmm"
"\ppp\qqq";
with line lengths you find convenient.
Then incorporate the initialized character array into your program.
Nov 15 '05 #4
This gives me a direction.

However if I keep such initalized character array in my program it will
consume memory whether I use them or not. In case I have lot of images
it may take substantial memory which is not desired. I would like to
initialize them when they are called for the first time in the program
and not always. Since I cannot keep them on disc seperately that is
why I asked if there is a way to bundle these images in the shared
object. ( Something like a zipfile ).

Thanks for your help.

Nov 15 '05 #5
pa***************@gmail.com wrote:
This gives me a direction.

However if I keep such initalized character array in my program it will
consume memory whether I use them or not. In case I have lot of images
it may take substantial memory which is not desired. I would like to
initialize them when they are called for the first time in the program
and not always. Since I cannot keep them on disc seperately that is
why I asked if there is a way to bundle these images in the shared
object. ( Something like a zipfile ).


You keep using the term "shared object" which has no inteligible
meaning. If you want to keep them in a disk file, just do it. You gave
the impression that you did *not* want to distribute them separately.
There are plenty of tools which are free and callable from C to compress
and uncompress such things on the fly. And there are plenty of tools to
strip unnecessary information from your executable and compress it with
a small prefix to decompress *that*.

Make up your mind what you really want. Then learn to do a search. Any
reasonable thing you might want to do has readily available free tools
to do it. None of those tools are topical in news:comp.lang.c
What you cannot do is store things in the aether. Either these things
will be in a file external to your program or stored in your program.
You don't seem to want either, but some mysterious "shared object" which
is neither distributed nor stored anywhere.
Nov 15 '05 #6
In article <11**********************@g14g2000cwa.googlegroups .com>,
<pa***************@gmail.com> wrote:
This gives me a direction.
Please quote some context. About every 3rd message these days gives
information on how to do that with google groups.

However if I keep such initalized character array in my program it will
consume memory whether I use them or not. In case I have lot of images
it may take substantial memory which is not desired. I would like to
initialize them when they are called for the first time in the program
and not always. Since I cannot keep them on disc seperately that is
why I asked if there is a way to bundle these images in the shared
object. ( Something like a zipfile ).


You have asked in comp.lang.c which only deals with what can be done
with portable standard C, and the answer in standard C is that all you
have is: code, dynamic memory allocation at runtime (malloc() etc),
and objects of static duration that are initialized by default to zero
at program startup time before any code executes.
Your problem is solvable by using OS-specific extensions in some
operating systems, but that's up to the OS, not up to C.
[OT]
A common UNIX approach is via dlopen(RTLD_LAZY) and dlsym().
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton
Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Douglass Turner | last post by:
Hi, Please release me from my own private hell. Platform: SuSE 8.1 I'm installing python 2.3 tarball as follows: ../configure --enable-shared make
17
by: David Hughes | last post by:
For example, in Python in a Nutshell, Alex Martelli shows how you can run a Windows (notepad.exe) or Unix-like (/bin/vim) text editor using os.spawnv(os.P_WAIT, editor, ) But how would you call...
2
by: Patrick | last post by:
Hello, after learning that I was taking a class in VB.NET, I have been drafted to solve all my companies VB/scripting problems - hey, I should know everything; I've already taken 6 classes ;) I...
4
by: R Reyes | last post by:
I am trying to code a file uploader (for forum/email attachments) from the client computer to a remote web server via the PUT method (since POST is not allowed ). However, the upload works ONLY...
10
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
17
by: J.S. | last post by:
I have a text file with parameters like the following embedded in the text: @@TextBox1@@, @@TextBox2@@, etc. I know how to read this text file. However, I am trying to figure out how to...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
3
by: Paddy | last post by:
Hi, I am am falling at the first hurdle when trying to access a library using ctypes. I have a file libucdb.so which the file command says is shared object, but I cannot get it to load: Any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.