Re: did this idea fell into a blachole?
- From: Patrick Jacquot <patrick jacquotf free fr>
- To: Christian Neumair <chris gnome-de org>
- Cc: "Nickolay V. Shmyrev" <nshmyrev yandex ru>, "nautilus-list gnome org" <nautilus-list gnome org>
- Subject: Re: did this idea fell into a blachole?
- Date: Sat, 06 May 2006 17:35:18 +0200
Le samedi 06 mai 2006 �7:23 +0200, Christian Neumair a �it :
> Am Samstag, den 06.05.2006, 14:24 +0200 schrieb Patrick Jacquot:
> > What can have happened?
>
> Providing us with the code in question would really help us to trace
> down the problem.
>
here is the last version
(if somebody knows good implementations of dirname and basename
able to handle unicode,
I would be glad to throw away my "utils" module)
#include "utils.c"
#include <unistd.h>
#include <orbit/orbit.h>
#include "nautilus-metafile-factory.h"
#include "nautilus-metafile-server.h"
#include <bonobo-activation/bonobo-activation.h>
#include <orbit/orbit-types.h>
int main(int argc, char** argv){
char*prefix="file://";
char*uri=(char*)malloc(strlen(prefix)+strlen(argv[1])+1);
Nautilus_MetafileFactory factory=CORBA_OBJECT_NIL;
strcpy(uri,prefix);
strcat(uri,argv[1]);
char* dirname=uriencode(getDirname(uri));
char* filename=uriencode(getFilename(uri));
printf("%s\n", dirname);
printf("%s\n",filename);
bonobo_init(&argc, argv);
bonobo_activate();
CORBA_Environment ev;
CORBA_exception_init(&ev);
factory=bonobo_activation_activate_from_id(
METAFILE_FACTORY_IID,0,NULL,&ev
);
if(ev._major != CORBA_NO_EXCEPTION){
printf ("activate: ev._major=%d\n", ev._major);
exit (1);
}
if (factory == CORBA_OBJECT_NIL){
printf("activate: factory=nIL\n");
exit (1);
}
printf ("factory ok, on continue\n");
Nautilus_Metafile metafile;
CORBA_exception_init(&ev);
metafile=Nautilus_MetafileFactory_open(factory,dirname,&ev);
if(ev._major!=CORBA_NO_EXCEPTION){
printf ("open metafile : ev._major=%d\n", ev._major);
exit (1);
}
if (metafile == CORBA_OBJECT_NIL){
printf("open metafile: metafile=nIL\n");
exit (1);
}
printf("metafile ok, on attend cinq secondes et oncontinue\n");
sleep(5);
CORBA_exception_init(&ev);
gboolean dejalu;
dejalu=Nautilus_Metafile_is_read(
metafile,&ev
);
if(ev._major!=CORBA_NO_EXCEPTION){
printf ("voir_si_lu : ev._major=%d\n", ev._major);
exit (1);
}
if (dejalu == CORBA_OBJECT_NIL){
printf("get_list: dejalu=NIL\n");
exit (1);
}
printf("dejalu = %d\n",dejalu);
CORBA_exception_init(&ev);
Nautilus_MetadataList * r;
r=Nautilus_Metafile_get_list(
metafile,filename,"keyword","name",&ev
);
if(ev._major!=CORBA_NO_EXCEPTION){
printf ("get_list : ev._major=%d\n", ev._major);
exit (1);
}
if (r == CORBA_OBJECT_NIL){
printf("get_list: r=nIL\n");
exit (1);
}
printf("liste ok on continue\n");
printf ("longueur de la liste: %d\n",r->_length);
printf ("lg maxi de la liste: %d\n",r->_maximum);
char* s=g_strdup(r->_buffer[0]);
printf("copie ok\n");
}
#include <stdio.h>
#include <stdlib.h>
# include <string.h>
int lc(char c){
switch (c){
case '/': return 3;
case ' ': return 3;
}
return 1;
}
char* uriencode(const char* original){
int l=0;
char* p=original;
char* r;
char* d;
// d�rminer la longueur
while (*p) l += lc(*p++);
//allouer la zone de r�ltat
d=r=(char*)malloc(l+1);
//on recommence a scanner l'original
p=original;
while(*p){
if ( lc (*p) == 1 ){
*d++=*p++;
}else{
sprintf(d,"%%%2X",*p++);
d+=3;
}
}
*d=0;
return r;
}
char* getFilename(char* path){
char* p=path;
char*q;
char*r;
int l=0;
//chercher la fin de la chaine
while (*++p);
//chercher le slash qui pr�de
while (--p>=path){
if(*p == '/'){
break;
}
l++;
}
p++;
//p pointe apr�le slash ou en d�t de chaine
char* d=r=(char*)malloc(l+1);
while (*p) *d++=*p++;
*d=0;
return r;
}
char* getDirname(char* path){
char* p=path;
char*q;
char*r;
int l=0;
//chercher la fin de la chaine
while (*++p);
//chercher le slash qui pr�de
while (--p>=path){
if(*p == '/'){
break;
}
}
p++;
//p pointe apr�le slash ou en d�t de chaine
char* d=r=(char*)malloc(p-path+1);
q=path;
while(q!=p)*d++=*q++;
*d=0;
return r;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]