[Klone-users] Open a file in embedded system
Stefano Barbato
barbato at koanlogic.com
Fri Jun 12 09:20:01 EDT 2009
Great :)
s
On 12/giu/09, at 15:13, Mickael Auger wrote:
> Hi Stefano,
>
> Sorry to have you disturbed. It was an error :(
> I made a "make clean" and it's ok.
>
> Bye and thanks for your speed response :)
>
> 2009/6/12 Stefano Barbato <barbato at koanlogic.com>
> Hi Mickael,
>
> do you get a runtime error on windows? is there any message in the
> log file?
>
> stefano
>
>
> On 12/giu/09, at 11:07, Mickael Auger wrote:
>
> Hi,
>
> Situation :
> - I compile my application to WindowsXP with Cygwin.
> - I use KLone 2.2.0
>
>
> Question and problem :
> I have a file, "lang.conf", in "/webapp/etc" (like "kloned.conf").
>
> I read this file with source code (source given by KLone team in a
> previous message) :
> =========================
> static int drv_io_open(const char *uri, void **parg);
> static int drv_io_close(void *arg);
> static char *drv_io_gets(void *arg, char *buf, size_t size);
> static u_config_driver_t drv_embfs = {
> drv_io_open, drv_io_close, drv_io_gets, NULL
> };
> static int drv_io_open(const char *uri, void **parg){
> io_t *io = NULL;
> dbg_err_if(uri == NULL);
> dbg_err_if(strlen(uri) == 0);
> dbg_err_if(parg == NULL);
> warn_err_ifm(emb_open(uri, &io),
> "unable to open embedded resource: %s", uri);
> *parg = io;
> return 0;
> err:
> if(io)
> io_free(io);
> return ~0;
> }
> static int drv_io_close(void *arg){
> io_t *io = (io_t*) arg;
> dbg_err_if(io == NULL);
> io_free(io);
> return 0;
> err:
> return ~0;
> }
> static char *drv_io_gets(void *arg, char *buf, size_t size){
> io_t *io = (io_t*)arg;
> dbg_err_if (arg == NULL);
> dbg_err_if (buf == NULL);
> nop_err_if(io_gets(io, buf, size) <= 0);
> return buf;
> err:
> return NULL;
> }
>
>
> //my function to read my conf file.
> void printLangConf()
> {
> u_config_t *myconffile;
> if(u_config_load_from_drv("/etc/lang.conf",&drv_embfs,
> 0,&myconffile)==0)
> u_config_print(myconffile,0);
> }
> ======================================
>
> This source code is functional in Linux system (compile with
> standard toolchain of Linux), but it's not functional in WindowsXP
> system (compile with cygwin).
>
> Can you have a solution, please ?
> In WindowsXP, I don't understand that "webapp/etc/kloned.conf" is
> read but not my "webapp/etc/lang.conf". I think that I don't use the
> good code.
>
> For information, I test this function that read my conf file if this
> file is external at klone binary.
> Hovewer, I wish keep my conf file in embedded system to protect its
> of modifications.
> ======================================
> void printLangConf()
> {
> u_config_t *myconffile;
> if(u_config_load_from_file("lang.conf",&myconffile)==0)
> u_config_print(myconffile,0);
> }
> ======================================
>
> Thanks.
> --
> Mickaël AUGER
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>
>
>
> --
> Mickaël AUGER
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
More information about the klone-users
mailing list