En fait j'ai peut-etre trouvé un des problèmes :
J'ai ajouté la librairie #include <fcntl.h>, dans laquelle est contenue open() qui semble être utiliser par libtar... (si quelqu'un peut confirmer ?)
Par contre, depuis que j'ai ajouté cette entête, il me dit qu'il ne connaît pas la fonction tar_open !!
Pourquoi ces deux entêtes ne pourraient-elles pas coexister ? Ou et ce que l'erreur ce situe ailleurs ?
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <libtar.h>
char * list_options = "a:o:";
int option;
char * tar_path;
TAR *tarh;
tartype_t Type;
int nMode = 0644;
int main(int argc, char *argv[])
{
while ((option = getopt(argc, argv, list_options)) != -1) {
switch (option) {
case 'a' :
fprintf(stdout, "option a : %s\n", optarg);
break;
case 'o' :
fprintf(stdout, "option o : %s\n", optarg);
tar_path = optarg;
break;
case '?' :
fprintf(stdout, "wrong option !\n");
break;
}
}
//fprintf(stdout, "voilà le path :%s", tar_path);
/*
Type.openfunc=open;
Type.closefunc=close;
Type.readfunc=read;
Type.writefunc=write;
*/
tar_open(&tarh, tar_path, &Type, O_RDONLY, 0, TAR_GNU);
//tar_close(&tarh);
return EXIT_SUCCESS;
}
[^] # Re: Docs
Posté par helmut . En réponse au message utilisation de libtar. Évalué à 1.
#ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <libtar.h> char * list_options = "a:o:"; int option; char * tar_path; TAR *tarh; tartype_t Type; int nMode = 0644; int main(int argc, char *argv[]) { while ((option = getopt(argc, argv, list_options)) != -1) { switch (option) { case 'a' : fprintf(stdout, "option a : %s\n", optarg); break; case 'o' : fprintf(stdout, "option o : %s\n", optarg); tar_path = optarg; break; case '?' : fprintf(stdout, "wrong option !\n"); break; } } //fprintf(stdout, "voilà le path :%s", tar_path); /* Type.openfunc=open; Type.closefunc=close; Type.readfunc=read; Type.writefunc=write; */ tar_open(&tarh, tar_path, &Type, O_RDONLY, 0, TAR_GNU); //tar_close(&tarh); return EXIT_SUCCESS; }