PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Running a program (gperf) inside another C program
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Running a program (gperf) inside another C program

Réponse
 
LinkBack Outils de la discussion
Vieux 26/05/2008, 14h41   #1
Alexander Mahone
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
Vieux 26/05/2008, 15h13   #2
Flash Gordon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program (gperf) inside another C program

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
  Réponse avec citation
Vieux 26/05/2008, 15h46   #3
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program (gperf) inside another C program

In article <b91dbf2d-7c63-4c01-ad5d-2476fbe6fc60@d45g2000hsc.googlegroups.com>,
Alexander Mahone <salvodanilogiuffrida@gmail.com> wrote:
>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
  Réponse avec citation
Vieux 26/05/2008, 19h33   #4
Keith Thompson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program (gperf) inside another C program

Flash Gordon <spam@flash-gordon.me.uk> writes:
[...]
> 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) kst-u@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"
  Réponse avec citation
Vieux 26/05/2008, 22h31   #5
Flash Gordon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program (gperf) inside another C program

Keith Thompson wrote, On 26/05/08 19:33:
> Flash Gordon <spam@flash-gordon.me.uk> writes:
> [...]
>> 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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h51.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14270 seconds with 13 queries