473,386 Members | 2,050 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,386 software developers and data experts.

Running a program (gperf) inside another C program

Hello, apart from using fork() and exec*(), or system(), is there any
other way to run the gperf command line program inside a C program? I
need to generate at run-time a perfect hash function, and it seems
that gperf has no API to execute it programmatically, so the only way
is to call it as an external program, and instruct it to write the
ouput code to a certain file whose path I know.
Thanks a lot
Jun 27 '08 #1
4 2364
In article <b9**********************************@d45g2000hsc. googlegroups.com>,
Alexander Mahone <sa******************@gmail.comwrote:
>Hello, apart from using fork() and exec*(), or system(), is there any
other way to run the gperf command line program inside a C program?
Note that C does not define fork() or exec*(), only system().
>I
need to generate at run-time a perfect hash function, and it seems
that gperf has no API to execute it programmatically, so the only way
is to call it as an external program, and instruct it to write the
ouput code to a certain file whose path I know.
Which system() should do fine for.

Anything beyond system() is system-specific.

[OT]
Based upon your reference to fork() and exec*(), it looks like you
might be using a POSIX type system. If so, then -possibly-,
depending on your system architecture and how exactly gperf was
compiled, you -might- be able to use operating system facilities to
request that gperf be loaded -as if- it were a dynamic library,
find it's entry point, and dispatch to that. Common facility
names that might give this kind of access are dlopen() and dlsym().
You might or might not be able to find a symbol within the program
that gives you a callable API; if not, then you would still have
to create command line arguments, possibly use dup2() or similiar
OS facilities do feed the program with internal streams instead of
creating a real file...

On the other hand, the kinds of systems that tend to make hacks
like the above possible, usually have ways of "pre-linking"
programs: in such cases, the speed difference between the hack I
mentioned vs invocation via system() is probably close to unmeasurable.

--
"It's a hard life sometimes and the biggest temptation is to let
how hard it is be an excuse to weaken." -- Walter Dean Myers
Jun 27 '08 #2
Alexander Mahone wrote, On 26/05/08 14:41:
Hello, apart from using fork() and exec*(), or system(), is there any
other way to run the gperf command line program inside a C program? I
In standard C the only method is system(), anything else is system
specific, so I suggest asking in comp.unix.programmer.
need to generate at run-time a perfect hash function, and it seems
that gperf has no API to execute it programmatically, so the only way
is to call it as an external program, and instruct it to write the
ouput code to a certain file whose path I know.
Thanks a lot
A better method almost certainly is to either find or write a library
that does what you want. If you search the group you will find that
hashing has been discussed several times here. Alternatively a simple
google search for "perfect has library" without the quotes shows some
options.
--
Flash Gordon
Jun 27 '08 #3
Flash Gordon <sp**@flash-gordon.me.ukwrites:
[...]
A better method almost certainly is to either find or write a library
that does what you want. If you search the group you will find that
hashing has been discussed several times here. Alternatively a simple
google search for "perfect has library" without the quotes shows some
options.
You mean "perfect hash library", yes?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #4
Keith Thompson wrote, On 26/05/08 19:33:
Flash Gordon <sp**@flash-gordon.me.ukwrites:
[...]
>A better method almost certainly is to either find or write a library
that does what you want. If you search the group you will find that
hashing has been discussed several times here. Alternatively a simple
google search for "perfect has library" without the quotes shows some
options.

You mean "perfect hash library", yes?
Yes, thank you.
--
Flash Gordon
Jun 27 '08 #5

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

Similar topics

2
by: bbxrider | last post by:
for win2k adv server/iis5.0 trying to run an external program from my asp routine that has multiple parameters, see following set shell = server.createobject("wscript.shell") shell.Run...
3
by: Daragoth | last post by:
Hi, I'm writing a program using Metrowerks CodeWarrior 4.0 that determines the best possible combination of a data set by checking every possible combination. I found there were about 250,000,000...
3
by: Janos Makadi | last post by:
Hi, I have a very interesting problem. I wrote a little code which linked against an externel library. I have the debug, and the release version of the ext. lib. One library function opens a...
2
by: MattMenard | last post by:
I've written a C program that I want to run inside an Gui wrapper that I started to write in MFC. I have to select some files then kick off a process running the C program. I have the initial...
4
by: duzinga | last post by:
I am trying to have a server program that runs at startup and accepts several commands from the clients. One of the commands is to play an audio file. I am using...
2
by: James MA | last post by:
I'm writing a program to handle multiple tasks in a single batch, which may take few minutes to complete all tasks. To reduce the impact to user, no windows form will be displayed, instead I have...
8
by: Shooter4Life8 | last post by:
I am trying to run a macro from my VB.NET program. Here is my code. Dim myAccess As Access.Application Dim allMacro As String = "ALL-Macros" myAccess.DoCmd.RunMacro(allMacro) I get the error....
6
by: matt.b.williams | last post by:
I am writing a program for a handheld device. It is a simple C program and it runs in a DOS like environment. I'm compiling it in Microsoft Visual C v1.x. Anyway, as part of this application, I...
5
by: nospam | last post by:
Hi all. I am just wondering if there is a way to make a VB.Net program know whether it is running from inside a Visual Studio 2005 IDE or a compiled executable? Thanks. -CG
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.