Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

ClearSilver

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 335
  • Category: Open Source
  • Founded: Jul 2, 2001
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 1410 - 1439 of 1451   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#1410 From: 马亮 <bigmaliang@...>
Date: Thu Sep 1, 2011 2:42 am
Subject: Re:Re: Re:ClearSilver installing failed?
bigmaliang...
Send Email Send Email
 
- I successfully compiled the file with your command yet it gave me a segmentation fault in the runtime.
This may because of your hello.c has illgeal operation, you can use
$ gcc -g -I /usr/local/include/ClearSilver -L /usr/local/lib  -lneo_cgi -lneo_cs -lneo_utl  hello.c
to compile it with debug info, and then use gdb to debug it(this is more than clearsilver, try to get some information from google).


- how to build streamparser using the svn version?  I got a build error.
Here is scrapt from my clearsilver build script:
cd /usr/local/src &&
svn checkout http://clearsilver.googlecode.com/svn/trunk/ clearsilver
cd clearsilver &&
svn checkout http://streamhtmlparser.googlecode.com/svn/trunk/ streamhtmlparser
cd streamhtmlparser && ./configure && make && make install
cd ../ && ./autogen.sh --disable-wdb --disable-perl --disable-ruby --disable-java --disable-python && mkdir libs

At 2011-09-01 10:25:20,"Jacky Wang" <jacky.chao.wang@...> wrote:
Thanks for the reply!

- I successfully compiled the file with your command yet it gave me a segmentation fault in the runtime.
- how to build streamparser using the svn version?  I got a build error.

Best,
J

2011/8/31 马亮 <bigmaliang@...>
sorry for my mistake, seems your compile command is not correct.

first, you should copy libneo_cgi.a libneo_cs.a libneo_utl.a into /usr/local/lib
then, you need to change compile command into
$ gcc -I /usr/local/include/ClearSilver -L /usr/local/lib  -lneo_cgi -lneo_cs -lneo_utl  hello.c 

Suggest you use the svn version code, which you need to pay some attention on build streamparser library first.




At 2011-08-31 10:07:01,"马亮" <bigmaliang@...> wrote:
 


what is in the test_crc.cs.out and test_crc.cs.err ?

At 2011-08-30 18:28:52,"Jacky Wang" <jacky.chao.wang@...> wrote:
 

Hi there,

I know that it may be a dumb question, but ClearSilver installing doesn't work for me. :(

It will be great if somebody here can help me out.

Assuming that the latest version is 0.10.5 (from http://www.clearsilver.net/downloads/), I did the conventional steps "./configure && make && sudo make install". However it throws error msg as the following:

Running cs regression tests
Failed Regression Test: test_crc.cs
See test_crc.cs.out and test_crc.cs.err

Does anyone happen to know how to solve it?

And therefore I skipped the error msg and copied the cs/cs.h and libneo_cs.a to the corresponding directories (/usr/local/*), but still seeing the following errors when compiling the code:

$ gcc -I /usr/local/include/ClearSilver -L /usr/local/include hello.c
/tmp/ccxRdPgS.o: In function `main':
hello.c:(.text+0x3d): undefined reference to `hdf_init'
hello.c:(.text+0x53): undefined reference to `hdf_set_value'
hello.c:(.text+0x5f): undefined reference to `hdf_init'
hello.c:(.text+0x75): undefined reference to `hdf_set_value'
hello.c:(.text+0x88): undefined reference to `cs_init'
hello.c:(.text+0x9e): undefined reference to `cs_parse_string'
hello.c:(.text+0xc7): undefined reference to `cs_render'
hello.c:(.text+0xdd): undefined reference to `hdf_set_value'
hello.c:(.text+0xfe): undefined reference to `cs_render'
hello.c:(.text+0x10f): undefined reference to `cs_destory'
hello.c:(.text+0x120): undefined reference to `hdf_destory'
hello.c:(.text+0x131): undefined reference to `hdf_destory'
collect2: ld returned 1 exit status

The hello.c is as following:
#include <stdio.h>
#include "ClearSilver/ClearSilver.h"

NEOERR* callback(void *ctx, char *output) {
printf("%s\n", output);
}

int main(int argc, char* argv[]) {
CSPARSE *tmpl = NULL; // CS template
HDF *hdf1, *hdf2; // HDF

// setup HDF
hdf_init(&hdf1);
hdf_set_value(hdf1, "name", "Jacky");
hdf_init(&hdf2);
hdf_set_value(hdf2, "name", "Alpha");

// parse cs template
cs_init(&tmpl, hdf1);
cs_parse_string(tmpl, "Hello, <?cs var:name ?>", 24);

// register rendering callback
CSOUTFUNC cb = &callback;

// render cs with hdf2
tmpl->hdf = hdf2;
cs_render(tmpl, NULL, cb);

// render cs with modified hdf1
hdf_set_value(hdf1, "name", "Sally");
tmpl->hdf = hdf1;
cs_render(tmpl, NULL, cb);

// destroy cs template
cs_destory(&tmpl);
hdf_destory(&hdf1);
hdf_destory(&hdf2);

printf("hello\n");
}

Any ideas?

Thanks in advance.

Best,
Jacky









#1411 From: Jacky Wang <jacky.chao.wang@...>
Date: Thu Sep 1, 2011 6:13 am
Subject: Re: Re: Re:ClearSilver installing failed?
jackychaowang
Send Email Send Email
 
Thanks for the comments!

However:

/usr/bin/ld: ../libs//libstreamhtmlparser.a(libstreamhtmlparser_la-htmlparser.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
../libs//libstreamhtmlparser.a: could not read symbols: Bad value

:(

On Wed, Aug 31, 2011 at 7:42 PM, 马亮 <bigmaliang@...> wrote:
- I successfully compiled the file with your command yet it gave me a segmentation fault in the runtime.
This may because of your hello.c has illgeal operation, you can use
$ gcc -g -I /usr/local/include/ClearSilver -L /usr/local/lib  -lneo_cgi -lneo_cs -lneo_utl  hello.c
to compile it with debug info, and then use gdb to debug it(this is more than clearsilver, try to get some information from google).



- how to build streamparser using the svn version?  I got a build error.
Here is scrapt from my clearsilver build script:
cd /usr/local/src &&
svn checkout http://clearsilver.googlecode.com/svn/trunk/ clearsilver
cd clearsilver &&
svn checkout http://streamhtmlparser.googlecode.com/svn/trunk/ streamhtmlparser
cd streamhtmlparser && ./configure && make && make install
cd ../ && ./autogen.sh --disable-wdb --disable-perl --disable-ruby --disable-java --disable-python && mkdir libs


At 2011-09-01 10:25:20,"Jacky Wang" <jacky.chao.wang@...> wrote:
Thanks for the reply!

- I successfully compiled the file with your command yet it gave me a segmentation fault in the runtime.
- how to build streamparser using the svn version?  I got a build error.

Best,
J

2011/8/31 马亮 <bigmaliang@...>
sorry for my mistake, seems your compile command is not correct.

first, you should copy libneo_cgi.a libneo_cs.a libneo_utl.a into /usr/local/lib
then, you need to change compile command into
$ gcc -I /usr/local/include/ClearSilver -L /usr/local/lib  -lneo_cgi -lneo_cs -lneo_utl  hello.c 

Suggest you use the svn version code, which you need to pay some attention on build streamparser library first.




At 2011-08-31 10:07:01,"马亮" <bigmaliang@...> wrote:
 


what is in the test_crc.cs.out and test_crc.cs.err ?

At 2011-08-30 18:28:52,"Jacky Wang" <jacky.chao.wang@...> wrote:
 

Hi there,

I know that it may be a dumb question, but ClearSilver installing doesn't work for me. :(

It will be great if somebody here can help me out.

Assuming that the latest version is 0.10.5 (from http://www.clearsilver.net/downloads/), I did the conventional steps "./configure && make && sudo make install". However it throws error msg as the following:

Running cs regression tests
Failed Regression Test: test_crc.cs
See test_crc.cs.out and test_crc.cs.err

Does anyone happen to know how to solve it?

And therefore I skipped the error msg and copied the cs/cs.h and libneo_cs.a to the corresponding directories (/usr/local/*), but still seeing the following errors when compiling the code:

$ gcc -I /usr/local/include/ClearSilver -L /usr/local/include hello.c
/tmp/ccxRdPgS.o: In function `main':
hello.c:(.text+0x3d): undefined reference to `hdf_init'
hello.c:(.text+0x53): undefined reference to `hdf_set_value'
hello.c:(.text+0x5f): undefined reference to `hdf_init'
hello.c:(.text+0x75): undefined reference to `hdf_set_value'
hello.c:(.text+0x88): undefined reference to `cs_init'
hello.c:(.text+0x9e): undefined reference to `cs_parse_string'
hello.c:(.text+0xc7): undefined reference to `cs_render'
hello.c:(.text+0xdd): undefined reference to `hdf_set_value'
hello.c:(.text+0xfe): undefined reference to `cs_render'
hello.c:(.text+0x10f): undefined reference to `cs_destory'
hello.c:(.text+0x120): undefined reference to `hdf_destory'
hello.c:(.text+0x131): undefined reference to `hdf_destory'
collect2: ld returned 1 exit status

The hello.c is as following:
#include <stdio.h>
#include "ClearSilver/ClearSilver.h"

NEOERR* callback(void *ctx, char *output) {
printf("%s\n", output);
}

int main(int argc, char* argv[]) {
CSPARSE *tmpl = NULL; // CS template
HDF *hdf1, *hdf2; // HDF

// setup HDF
hdf_init(&hdf1);
hdf_set_value(hdf1, "name", "Jacky");
hdf_init(&hdf2);
hdf_set_value(hdf2, "name", "Alpha");

// parse cs template
cs_init(&tmpl, hdf1);
cs_parse_string(tmpl, "Hello, <?cs var:name ?>", 24);

// register rendering callback
CSOUTFUNC cb = &callback;

// render cs with hdf2
tmpl->hdf = hdf2;
cs_render(tmpl, NULL, cb);

// render cs with modified hdf1
hdf_set_value(hdf1, "name", "Sally");
tmpl->hdf = hdf1;
cs_render(tmpl, NULL, cb);

// destroy cs template
cs_destory(&tmpl);
hdf_destory(&hdf1);
hdf_destory(&hdf2);

printf("hello\n");
}

Any ideas?

Thanks in advance.

Best,
Jacky










#1412 From: "Jacky Wang" <jacky.chao.wang@...>
Date: Sat Sep 3, 2011 8:51 pm
Subject: Use ClearSilver in Multi-threading environment?
jackychaowang
Send Email Send Email
 
Hi,

Thanks for the helps and ClearSilver runs flawlessly on my machine.

So I'm curiosity on the tips/best practices of its usage under multi-threading
environment.

The sample code is listed as following:
- callback is the function.
- both cs and hdf are shared pointers.
- output is a local ctx pointer.

<code>
cs->hdf = hdf;
cs_render(cs, &output, &callback);  // Do I need to put a lock here?
</code>

My understanding is that if the cs_render actually doesn't change the structure
of either cs or hdf, the lock is not needed (thus won't hurt the performance). 
Does it sound?

Thanks,
Jacky

#1413 From: David Jeske <davidj@...>
Date: Sat Sep 3, 2011 11:16 pm
Subject: Re: Re: Re:ClearSilver installing failed?
jeskeca
Send Email Send Email
 
Can you share some information about the environment you are trying to compile/install in?

The test_crc.cs error is showing a sign error in output, which might be related to using a 64bit compile instead of 32bit, or a subtle change to some system library. The best way to help figure this out is for us to know what environment you are using. (uname -a, what distro?)

#1414 From: Brandon Long <blong@...>
Date: Sun Sep 4, 2011 8:50 am
Subject: Re: Use ClearSilver in Multi-threading environment?
blong42
Send Email Send Email
 
On Sat, Sep 3, 2011 at 10:51 AM, Jacky Wang <jacky.chao.wang@...> wrote:
> Hi,
>
> Thanks for the helps and ClearSilver runs flawlessly on my machine.
>
> So I'm curiosity on the tips/best practices of its usage under multi-threading
environment.
>
> The sample code is listed as following:
> - callback is the function.
> - both cs and hdf are shared pointers.
> - output is a local ctx pointer.
>
> <code>
> cs->hdf = hdf;
> cs_render(cs, &output, &callback); // Do I need to put a lock here?
> </code>
>
> My understanding is that if the cs_render actually doesn't change the
structure of either cs or hdf, the lock is not needed (thus won't hurt the
performance). Does it sound?

No, this isn't true.  I'm sure that CSPARSE contains data structures
which are updated on render, and cs commands like set definitely
modify hdf.  For example, we don't pass the callback around, its
actually set in the CSPARSE struct.  I guess in theory we could split
CSPARSE into both a PARSE and a RENDER struct, so that the PARSE would
be read-only for render, but it hasn't been the typical way we've done
this.  Typically, the parse is somewhat specific to the instance,
though I'm sure that's not necessary (jsilver definitely tries to
re-use parses, since parsing is expensive.  It also means that the
equivalent of cs_render in jsilver is thread-safe with a shared cs,
but again, HDF isn't thread-safe if the cs render has side affects).

From a normal standpoint, cs & hdf are thread safe in the sense that
you can use separate instances from separate threads safely, but they
are not safe to use from multiple threads at once.  There is a concept
of a "global HDF", though, which can be loaded and shared across
threads, as cs_parse/cs_render treat it as read-only.  That isn't to
say you can update it from another thread while its being used, but
you'd typically load a bunch of data into it at startup, and use it as
a read-only structure from that point.

The cgi libraries are mostly not thread-safe with the exception of the
escape functions.  This is because the underlying CGI interface is
based on global data (environment variables, stdin & stdout).  Since
all access to that is through the cgiwrap interface, I've debated
making the wrapper thread-safe so that you could "mimic" the CGI
interface in a thread-safe fashion, but I'm unsure how useful that
would end up being in practice.

Brandon

#1415 From: Jacky Wang <jacky.chao.wang@...>
Date: Sun Sep 4, 2011 9:33 am
Subject: Re: Re: Re:ClearSilver installing failed?
jackychaowang
Send Email Send Email
 
Thank you David!

I replied theinformation in another thread.

Current I've seen is:

<......
ranlib ../libs/libneo_cgi.a
gcc -g -O2 -pthread -Wall -I.. -I/home/chaowang/workspace/tmp/clearsilver_trunk/streamhtmlparser/src -fPIC -o static.o -c static.c
static.c: In function main:
static.c:78: warning: ignoring return value of chdir, declared with attribute warn_unused_result
gcc -o cs_static.cgi static.o -L../libs/ -lneo_cgi -lneo_cs -lneo_utl -lstreamhtmlparser -lz
gcc -shared -fPIC -o cs_static.cso static.o -L../libs/ -lneo_cgi -lneo_cs -lneo_utl -lstreamhtmlparser -lz
/usr/bin/ld: ../libs//libstreamhtmlparser.a(libstreamhtmlparser_la-htmlparser.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
../libs//libstreamhtmlparser.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [cs_static.cso] Error 1
make[1]: Leaving directory `/clearsilver_trunk/cgi'
make: *** [cs] Error 1

$ uname -a
Linux laptop 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:07:13 UTC 2011 x86_64 GNU/Linux

Many thanks!
Jacky

On Sat, Sep 3, 2011 at 4:16 PM, David Jeske <davidj@...> wrote:
Can you share some information about the environment you are trying to compile/install in?

The test_crc.cs error is showing a sign error in output, which might be related to using a 64bit compile instead of 32bit, or a subtle change to some system library. The best way to help figure this out is for us to know what environment you are using. (uname -a, what distro?)


#1416 From: "bxxx" <vincebouix@...>
Date: Tue Oct 4, 2011 3:21 pm
Subject: sanitize all value of Query
vincebouix
Send Email Send Email
 
Hello,
I would like sanitize (with function html_escape for exemple) all value of
query.

How each recursively to a final value ?

thx

#1417 From: Brandon Long <blong@...>
Date: Wed Oct 5, 2011 10:46 pm
Subject: Re: sanitize all value of Query
blong42
Send Email Send Email
 
<?cs def:sanitize(param) ?>
   <?cs set:param = html_escape(param) ?>
   <?cs each:sub = param ?>
     <?cs call:sanitize(sub) ?>
   <?cs /each ?>
<?cs /def ?>

<?cs each:param = Query ?>
   <?cs call:sanitize(param) ?>
<?cs /each ?>

or something like that.  Note, you may be better off just using the
right escaping whenever you use a Query variable instead of trying to
sanitize them all up front.  You'd be even better off using the
auto-escaping code that's in the unreleased 0.11 code base in the SVN
tree on code.google.com

Brandon

On Tue, Oct 4, 2011 at 8:21 AM, bxxx <vincebouix@...> wrote:
> Hello,
> I would like sanitize (with function html_escape for exemple) all value of
query.
>
> How each recursively to a final value ?
>
> thx
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#1418 From: "bxxx" <vincebouix@...>
Date: Thu Oct 20, 2011 1:53 pm
Subject: include into var
vincebouix
Send Email Send Email
 
Hey,

is it possible to use include with a redirect output.
for example :
<?cs
set:myvar = include: "test.cs"
?>

#1419 From: Brandon Long <blong@...>
Date: Thu Oct 20, 2011 3:45 pm
Subject: Re: include into var
blong42
Send Email Send Email
 

No, though I've considered adding one.

Brandon

On Oct 20, 2011 8:39 AM, "bxxx" <vincebouix@...> wrote:
Hey,

is it possible to use include with a redirect output.
for example :
<?cs
set:myvar = include: "test.cs"
?>





------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ClearSilver/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/ClearSilver/join
(Yahoo! ID required)

<*> To change settings via email:
ClearSilver-digest@yahoogroups.com
ClearSilver-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
ClearSilver-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/


#1420 From: "unlitechc" <unlitechc@...>
Date: Mon Nov 7, 2011 9:36 am
Subject: Using mongoose without cgi?
unlitechc
Send Email Send Email
 
I've got a problem that my boss asked me to use a light weight embedded web
server, such as mongoose, to work with existing C program.
No database should be used. All data comes from dynamic infos. No cgi support.
In other words, mongoose and clearsilver should be embedded into the C program
to handle requests and do some other tasks.
Then, how can i embed clearsilver into the C program? Mongoose can be embedded
into it.

#1421 From: Brandon Long <blong@...>
Date: Wed Nov 9, 2011 7:38 am
Subject: Re: Using mongoose without cgi?
blong42
Send Email Send Email
 
ClearSilver can be thought of as two parts, the CS templating
language, and the CGI library.

For your case, you basically need to use the CS language portions
(libcs) and not the CGI library (libcgi).

This means you need to write your own code similar to the code in
cgi/cgi.c to hook whatever parsing routines and output routines that
exist with mongoose to your program.

Brandon

On Mon, Nov 7, 2011 at 1:36 AM, unlitechc <unlitechc@...> wrote:
> I've got a problem that my boss asked me to use a light weight embedded web
server, such as mongoose, to work with existing C program.
> No database should be used. All data comes from dynamic infos. No cgi support.
> In other words, mongoose and clearsilver should be embedded into the C program
to handle requests and do some other tasks.
> Then, how can i embed clearsilver into the C program? Mongoose can be embedded
into it.
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

#1422 From: Brandon Long <blong@...>
Date: Tue Nov 29, 2011 6:13 pm
Subject: Moderate to low-risk security issue found in Clearsilver python bindings
blong42
Send Email Send Email
 
This issue was given identifier CVE-2011-4357.

This issue only affects the python wrapper for ClearSilver.

In the CGI.error method from the neo_cgi module, the string is passed
as the format parameter to the underlying cgi_error function which
takes printf-style arguments.  This means that including a % format
character in that string can result in garbage being read from the
stack.

Apparently this is enough to cause some security issues, I'm not
qualified to say how vulnerable this particular leak might be.  Redhat
classified it as moderate.

From my experience, the usage of this method is pretty uncommon, I
couldn't find any use of it in any of the code that I have, nor in any
of the code I could find in Google's Code Search.  That said, you
should check your own code and verify that you either don't use this
method, or that you don't send user input to it, or that you patch
your copy of clearsilver to fix this issue.

A change has been committed to the source svn for this bug, available here:

http://code.google.com/p/clearsilver/source/detail?r=919

At least the neo_cgi.c part of that patch should patch cleanly on most
0.10.x versions of clearsilver.  The fix will also be included in the
upcoming 0.11.x release.

This bug was found by the debian package maintainers, though no one
felt the need to email me or this group with the information.  Thanks
to Google Alerts for alerting me to the issue.  See this debian bug
for details: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=649322

Brandon

#1423 From: Michael Mileusnich <justmike2000@...>
Date: Wed Dec 7, 2011 8:24 pm
Subject: python 2.4 clearsilver 0.10.5 Ubuntu 11.10 32 bit
justmike2000@...
Send Email Send Email
 
Hello,

I am having a particularly troubling issue that I was hoping you could help shed some light on. I am working on an application that uses Python 2.4 (I am currently running Ubuntu 11.10 32bit which comes with Python 2.7) I have 2.4 setup separately. All other third party python modules I installed through setuptools-2.4 easy_installer and work just fine but I am running into issues with clearsilver. If I try to easy_install, build the so from source, or build the python egg everytime I try to import neo_cgi I get an undefined symbol: crc32 error message on python. I am assuming it has to do with zlib as I had to create a softlink between the zlib in /lib/libz.so and /lib/i386-linux-gnu and recompile python2.4 to get install tools to run on 2.4 and correct me if I am wrong but crc32 resides inside zlib. I tried editing the setup.py to include crc32 and/or zlib as a library but that gave me the same results. Any thoughts?

Thanks,

#1424 From: caox <caox@...>
Date: Wed Dec 21, 2011 6:28 am
Subject: Does nerr_log_error free the NEO_ERR *
caox@...
Send Email Send Email
 
Hi

Sorry to bother. According to the description and code example, the API  nerr_log_error should free the err chain. But I didn't find the respective code to release the err chain inside the implementation:

void nerr_log_error (NEOERR *err)
{
  NEOERR *more;
  char buf[1024];
  char *err_name;

  if (err == STATUS_OK)
    return;

  if (err == INTERNAL_ERR)
  {
    ne_warn ("Internal error");
    return;
  }

  more = err;
  fprintf (stderr, "Traceback (innermost last):\n");
  while (more && more != INTERNAL_ERR)
  {
    err = more;
    more = err->next;
    if (err->error != NERR_PASS)
    {
      NEOERR *r;
      if (err->error == 0)
      {
err_name = buf;
snprintf (buf, sizeof (buf), "Unknown Error");
      }
      else
      {
r = uListGet (Errors, err->error - 1, (void *)&err_name);
if (r != STATUS_OK)
{
  err_name = buf;
  snprintf (buf, sizeof (buf), "Error %d", err->error);
}
      }

      fprintf (stderr, "  File \"%s\", line %d, in %s()\n%s: %s\n", err->file
  err->lineno, err->func, err_name, err->desc);
    }
    else
    {
      fprintf (stderr, "  File \"%s\", line %d, in %s()\n", err->file
  err->lineno, err->func);
      if (err->desc[0])
      {
fprintf (stderr, "    %s\n", err->desc);
      }
    }
  }
}

So, is the err chain freed in other place or I have missed something inside the function? Does nerr_log_error free the err chain, as for nerr_err_string and nerr_err_traceback?

Thanks.

B.R.

#1425 From: Brandon Long <blong@...>
Date: Wed Dec 21, 2011 7:18 pm
Subject: Re: Does nerr_log_error free the NEO_ERR *
blong42
Send Email Send Email
 
I don't think any of those free the error chain, where did you get that impression? Its not in the api docs, as near as I can tell.

Brandon

On Tue, Dec 20, 2011 at 10:28 PM, caox <caox@...> wrote:


Hi

Sorry to bother. According to the description and code example, the API nerr_log_error should free the err chain. But I didn't find the respective code to release the err chain inside the implementation:

void nerr_log_error (NEOERR *err)
{
NEOERR *more;
char buf[1024];
char *err_name;

if (err == STATUS_OK)
return;

if (err == INTERNAL_ERR)
{
ne_warn ("Internal error");
return;
}

more = err;
fprintf (stderr, "Traceback (innermost last):\n");
while (more && more != INTERNAL_ERR)
{
err = more;
more = err->next;
if (err->error != NERR_PASS)
{
NEOERR *r;
if (err->error == 0)
{
err_name = buf;
snprintf (buf, sizeof (buf), "Unknown Error");
}
else
{
r = uListGet (Errors, err->error - 1, (void *)&err_name);
if (r != STATUS_OK)
{
err_name = buf;
snpri ntf (buf, sizeof (buf), "Error %d", err->error);
}
}

fprintf (stder r, " File \"%s\", line %d, in %s()\n%s: %s\n", err->file,
err->lineno, err->func, err_name, err->desc);
}
else
{
fprintf (stderr, " File \"%s\", line %d, in %s()\n", err->file,
err->lineno, err->func);
if (err->desc[0])
{
fprintf (stderr, " %s\n", err->desc);
}
}
}
}

So, is the err chain freed in other place or I have missed something inside the function? Doesnerr_log_error free the err chain, as for nerr_err_string and nerr_err_traceback?

Thanks.

B.R.




#1426 From: caox <caox@...>
Date: Thu Dec 22, 2011 2:39 am
Subject: Re: Does nerr_log_error free the NEO_ERR *
caox@...
Send Email Send Email
 
hmm... I found it in the header file "neo_err.h":

/* function: nerr_log_error
 * description: currently, this prints out the error to stderr, and
 *             free's the error chain
 */
void nerr_log_error (NEOERR *err);

Besides, I didn't find any explicit release action of neo_err in the test code like:

part of "hdf_test.c" under util/test/

int main(int argc, char **argv)
{
  NEOERR *err;

  err = dictionary_test();
  if (err)
  {
    nerr_log_error(err);
    printf("FAIL\n");
    return -1;
  }
  printf("PASS\n");
  return 0;
}

If I didn't misunderstand the src code, the neo_err *err is allocated and initialized during nerr_rasie and nerr_pass, but where does the test code free it?

On 2011-12-22, at 上午3:18, Brandon Long wrote:

I don't think any of those free the error chain, where did you get that impression?  Its not in the api docs, as near as I can tell.

Brandon

On Tue, Dec 20, 2011 at 10:28 PM, caox <caox@...> wrote:


Hi

Sorry to bother. According to the description and code example, the API  nerr_log_error should free the err chain. But I didn't find the respective code to release the err chain inside the implementation:

void nerr_log_error (NEOERR *err)
{
  NEOERR *more;
  char buf[1024];
  char *err_name;

  if (err == STATUS_OK)
    return;

  if (err == INTERNAL_ERR)
  {
    ne_warn ("Internal error");
    return;
  }

  more = err;
  fprintf (stderr, "Traceback (innermost last):\n");
  while (more && more != INTERNAL_ERR)
  {
    err = more;
    more = err->next;
    if (err->error != NERR_PASS)
    {
      NEOERR *r;
      if (err->error == 0)
      {
err_name = buf;
snprintf (buf, sizeof (buf), "Unknown Error");
      }
      else
      {
r = uListGet (Errors, err->error - 1, (void *)&err_name);
if (r != STATUS_OK)
{
  err_name = buf;
  snpri ntf (buf, sizeof (buf), "Error %d", err->error);
}
      }

      fprintf (stder r, "  File \"%s\", line %d, in %s()\n%s: %s\n", err->file
  err->lineno, err->func, err_name, err->desc);
    }
    else
    {
      fprintf (stderr, "  File \"%s\", line %d, in %s()\n", err->file
  err->lineno, err->func);
      if (err->desc[0])
      {
fprintf (stderr, "    %s\n", err->desc);
      }
    }
  }
}

So, is the err chain freed in other place or I have missed something inside the function? Does nerr_log_error free the err chain, as for nerr_err_string and nerr_err_traceback?

Thanks.

B.R.





#1427 From: Brandon Long <blong@...>
Date: Thu Dec 22, 2011 7:33 am
Subject: Re: Does nerr_log_error free the NEO_ERR *
blong42
Send Email Send Email
 


On Wed, Dec 21, 2011 at 6:39 PM, caox <caox@...> wrote:
hmm... I found it in the header file "neo_err.h":

/* function: nerr_log_error
 * description: currently, this prints out the error to stderr, and
 *             free's the error chain
 */
void nerr_log_error (NEOERR *err);

Ah, the comment was fixed:

 
Besides, I didn't find any explicit release action of neo_err in the test code like:

part of "hdf_test.c" under util/test/

int main(int argc, char **argv)
{
  NEOERR *err;

  err = dictionary_test();
  if (err)
  {
    nerr_log_error(err);
    printf("FAIL\n");
    return -1;
  }
  printf("PASS\n");
  return 0;
}

If I didn't misunderstand the src code, the neo_err *err is allocated and initialized during nerr_rasie and nerr_pass, but where does the test code free it?

It doesn't, just sloppy I guess.

Brandon
 

On 2011-12-22, at 上午3:18, Brandon Long wrote:

I don't think any of those free the error chain, where did you get that impression?  Its not in the api docs, as near as I can tell.

Brandon

On Tue, Dec 20, 2011 at 10:28 PM, caox <caox@...> wrote:


Hi

Sorry to bother. According to the description and code example, the API  nerr_log_error should free the err chain. But I didn't find the respective code to release the err chain inside the implementation:

void nerr_log_error (NEOERR *err)
{
  NEOERR *more;
  char buf[1024];
  char *err_name;

  if (err == STATUS_OK)
    return;

  if (err == INTERNAL_ERR)
  {
    ne_warn ("Internal error");
    return;
  }

  more = err;
  fprintf (stderr, "Traceback (innermost last):\n");
  while (more && more != INTERNAL_ERR)
  {
    err = more;
    more = err->next;
    if (err->error != NERR_PASS)
    {
      NEOERR *r;
      if (err->error == 0)
      {
err_name = buf;
snprintf (buf, sizeof (buf), "Unknown Error");
      }
      else
      {
r = uListGet (Errors, err->error - 1, (void *)&err_name);
if (r != STATUS_OK)
{
  err_name = buf;
  snpri ntf (buf, sizeof (buf), "Error %d", err->error);
}
      }

      fprintf (stder r, "  File \"%s\", line %d, in %s()\n%s: %s\n", err->file
  err->lineno, err->func, err_name, err->desc);
    }
    else
    {
      fprintf (stderr, "  File \"%s\", line %d, in %s()\n", err->file
  err->lineno, err->func);
      if (err->desc[0])
      {
fprintf (stderr, "    %s\n", err->desc);
      }
    }
  }
}

So, is the err chain freed in other place or I have missed something inside the function? Does nerr_log_error free the err chain, as for nerr_err_string and nerr_err_traceback?

Thanks.

B.R.






#1428 From: caox <caox@...>
Date: Thu Dec 22, 2011 7:48 am
Subject: Re: Does nerr_log_error free the NEO_ERR *
caox@...
Send Email Send Email
 
OK, I see. 

That means we need call nerr_ignore after nerr_log_error if we want the err chain to be freed correctly.

Thanks.

On 2011-12-22, at 下午3:33, Brandon Long wrote:



On Wed, Dec 21, 2011 at 6:39 PM, caox <caox@...> wrote:
hmm... I found it in the header file "neo_err.h":

/* function: nerr_log_error
 * description: currently, this prints out the error to stderr, and
 *             free's the error chain
 */
void nerr_log_error (NEOERR *err);

Ah, the comment was fixed:

 
Besides, I didn't find any explicit release action of neo_err in the test code like:

part of "hdf_test.c" under util/test/

int main(int argc, char **argv)
{
  NEOERR *err;

  err = dictionary_test();
  if (err)
  {
    nerr_log_error(err);
    printf("FAIL\n");
    return -1;
  }
  printf("PASS\n");
  return 0;
}

If I didn't misunderstand the src code, the neo_err *err is allocated and initialized during nerr_rasie and nerr_pass, but where does the test code free it?

It doesn't, just sloppy I guess.

Brandon
 

On 2011-12-22, at 上午3:18, Brandon Long wrote:

I don't think any of those free the error chain, where did you get that impression?  Its not in the api docs, as near as I can tell.

Brandon

On Tue, Dec 20, 2011 at 10:28 PM, caox <caox@...> wrote:


Hi

Sorry to bother. According to the description and code example, the API  nerr_log_error should free the err chain. But I didn't find the respective code to release the err chain inside the implementation:

void nerr_log_error (NEOERR *err)
{
  NEOERR *more;
  char buf[1024];
  char *err_name;

  if (err == STATUS_OK)
    return;

  if (err == INTERNAL_ERR)
  {
    ne_warn ("Internal error");
    return;
  }

  more = err;
  fprintf (stderr, "Traceback (innermost last):\n");
  while (more && more != INTERNAL_ERR)
  {
    err = more;
    more = err->next;
    if (err->error != NERR_PASS)
    {
      NEOERR *r;
      if (err->error == 0)
      {
err_name = buf;
snprintf (buf, sizeof (buf), "Unknown Error");
      }
      else
      {
r = uListGet (Errors, err->error - 1, (void *)&err_name);
if (r != STATUS_OK)
{
  err_name = buf;
  snpri ntf (buf, sizeof (buf), "Error %d", err->error);
}
      }

      fprintf (stder r, "  File \"%s\", line %d, in %s()\n%s: %s\n", err->file
  err->lineno, err->func, err_name, err->desc);
    }
    else
    {
      fprintf (stderr, "  File \"%s\", line %d, in %s()\n", err->file
  err->lineno, err->func);
      if (err->desc[0])
      {
fprintf (stderr, "    %s\n", err->desc);
      }
    }
  }
}

So, is the err chain freed in other place or I have missed something inside the function? Does nerr_log_error free the err chain, as for nerr_err_string and nerr_err_traceback?

Thanks.

B.R.







#1429 From: caox <caox@...>
Date: Tue Dec 27, 2011 8:07 am
Subject: Re: Use ClearSilver in Multi-threading environment?
caox@...
Send Email Send Email
 
Hi, Brandon

We use ClearSilver as our template engine in our product, and we faced the problem  your referred a few months ago.

In our situation, we have lots of developers put different cs marco into one global util.cs file so that we can include it in different cs pages for re-using. As this global file grows, the parsing time of every cs page that includes it becomes very long. And it makes our system slow, as a bottleneck, and most of the time is consumed by parsing of util.cs.

Then we decided to re-use the CSPARSE structure of each cs pages. Since it is not thread safe, we need to make one CSPARSE instance for each threads.

That means we need 8 instances for 8 threads. Besides, we can't use cs syntax such as <?cs include :Var ?>. Typically, we have same number threads as the CPU cores, and it won't be a problem since the system memory is quite enough to hold lots of CSPARSE structures. But we still want to optimize it in a more decent way.

There maybe several choices. As you mentioned, we could split the parse and the render process to make the parse read-only. And I was also wondering if we could change the implementation of cs:include or give a callback to implement it, like we could include a pre-prased structure directly.

Do you have any suggestions?

B.R.

caox

On 2011-9-4, at 下午4:50, Brandon Long wrote:

 

On Sat, Sep 3, 2011 at 10:51 AM, Jacky Wang <jacky.chao.wang@...> wrote:
> Hi,
>
> Thanks for the helps and ClearSilver runs flawlessly on my machine.
>
> So I'm curiosity on the tips/best practices of its usage under multi-threading environment.
>
> The sample code is listed as following:
> - callback is the function.
> - both cs and hdf are shared pointers.
> - output is a local ctx pointer.
>
> <code>
> cs->hdf = hdf;
> cs_render(cs, &output, &callback);  // Do I need to put a lock here?
> </code>
>
> My understanding is that if the cs_render actually doesn't change the structure of either cs or hdf, the lock is not needed (thus won't hurt the performance).  Does it sound?

No, this isn't true. I'm sure that CSPARSE contains data structures
which are updated on render, and cs commands like set definitely
modify hdf. For example, we don't pass the callback around, its
actually set in the CSPARSE struct. I guess in theory we could split
CSPARSE into both a PARSE and a RENDER struct, so that the PARSE would
be read-only for render, but it hasn't been the typical way we've done
this. Typically, the parse is somewhat specific to the instance,
though I'm sure that's not necessary (jsilver definitely tries to
re-use parses, since parsing is expensive. It also means that the
equivalent of cs_render in jsilver is thread-safe with a shared cs,
but again, HDF isn't thread-safe if the cs render has side affects).

From a normal standpoint, cs & hdf are thread safe in the sense that
you can use separate instances from separate threads safely, but they
are not safe to use from multiple threads at once. There is a concept
of a "global HDF", though, which can be loaded and shared across
threads, as cs_parse/cs_render treat it as read-only. That isn't to
say you can update it from another thread while its being used, but
you'd typically load a bunch of data into it at startup, and use it as
a read-only structure from that point.

The cgi libraries are mostly not thread-safe with the exception of the
escape functions. This is because the underlying CGI interface is
based on global data (environment variables, stdin & stdout). Since
all access to that is through the cgiwrap interface, I've debated
making the wrapper thread-safe so that you could "mimic" the CGI
interface in a thread-safe fashion, but I'm unsure how useful that
would end up being in practice.

Brandon



#1430 From: <bigmaliang@...>
Date: Tue Feb 28, 2012 7:17 am
Subject: spell bug in cgi.c
bigmaliang...
Send Email Send Email
 
 hi
   There is a spell bug in cgi.c: 899
err = nerr_register(&CGIUploadCancelled, "CGIParseNotHandled");

should be

err = nerr_register(&CGIParseNotHandled, "CGIParseNotHandled");




#1431 From: Brandon Long <blong@...>
Date: Thu Mar 8, 2012 6:23 pm
Subject: Re: spell bug in cgi.c
blong42
Send Email Send Email
 
Not sure that quite qualifies as a spell bug, but its a real bug.  Thanks, fixed in the repo.

Brandon

2012/2/27 马亮 <bigmaliang@...>


 hi
   There is a spell bug in cgi.c: 899
err = nerr_register(&CGIUploadCancelled, "CGIParseNotHandled");

should be

err = nerr_register(&CGIParseNotHandled, "CGIParseNotHandled");







#1432 From: "Matthew" <mathewxiang@...>
Date: Thu Mar 15, 2012 5:55 am
Subject: is there any syntax template for cs file?
mathewxiang
Send Email Send Email
 
http://www.vim.org/scripts/script.php?script_id=1100
I fount this, but I think it doesn't work, so who can tell me is there a file
for this?

#1433 From: "Michael Moody" <michael.moody84@...>
Date: Mon Feb 20, 2012 10:18 am
Subject: Support Ticket System - Knowledge base software
michael.moody84
Send Email Send Email
 
Dynamically route and assign help desk tickets to any specific technician or group of technicians using your organization's business logic; based on ticket categories, technician skill set, location, department, technician availability and work load balance.

knowledge base software  | knowledgebase software

#1434 From: David Jeske <davidj@...>
Date: Thu Mar 15, 2012 7:14 am
Subject: Re: is there any syntax template for cs file?
jeskeca
Send Email Send Email
 
On Wed, Mar 14, 2012 at 10:55 PM, Matthew <mathewxiang@...> wrote:
http://www.vim.org/scripts/script.php?script_id=1100
I fount this, but I think it doesn't work, so who can tell me is there a file for this?

Did you try it?

BTW - since the introduce of C#, we've kind of informally moved to .cst to avoid the extension duplication.

#1435 From: "bxxx" <vincebouix@...>
Date: Tue Mar 20, 2012 4:52 pm
Subject: Best solution for output file directly
vincebouix
Send Email Send Email
 
What is the best solution with clearsilver (C API of course) to send a file
directly to the browser?

thx

#1436 From: David Jeske <davidj@...>
Date: Tue Mar 20, 2012 5:02 pm
Subject: Re: Best solution for output file directly
jeskeca
Send Email Send Email
 
On Tue, Mar 20, 2012 at 9:52 AM, bxxx <vincebouix@...> wrote:
What is the best solution with clearsilver (C API of course) to send a file directly to the browser?

Clearsilver is for producing templated-output, such as HTML. If you want to just send a file directly to the user, you just output the bytes directly through your CGI API -- going right around clearsilver.

What C-CGI API are you using?

#1437 From: Brandon Long <blong@...>
Date: Tue Mar 20, 2012 5:54 pm
Subject: Re: Best solution for output file directly
blong42
Send Email Send Email
 
If you want to use the wrappers in CS, you can do something like:

cgiwrap_writef("Content-Type: foo/bar\r\n");
cgiwrap_writef("Content-Length: %d\r\n\r\n", content_length);
cgiwrap_write(buf, length);

In a standard CGI API, this is equivalent to using fprintf and fwrite to stdout.

Brandon

On Tue, Mar 20, 2012 at 10:02 AM, David Jeske <davidj@...> wrote:


On Tue, Mar 20, 2012 at 9:52 AM, bxxx <vincebouix@...> wrote:
What is the best solution with clearsilver (C API of course) to send a file directly to the browser?

Clearsilver is for producing templated-output, such as HTML. If you want to just send a file directly to the user, you just output the bytes directly through your CGI API -- going right around clearsilver.

What C-CGI API are you using?




#1438 From: David Jeske <davidj@...>
Date: Sat Apr 7, 2012 9:57 pm
Subject: clearsilver bug in cgi-parse, form posting with explicit chartset...
jeskeca
Send Email Send Email
 
I just ran into a bug in clearsilver that I'm surprised has existed for so long.

The problem occured because Firefox is specifying a character set in the content type of form posts, ala...

application/x-www-form-urlencoded; charset=UTF-8

Clearsilver cgi_parse was expecting an exact match for "application/x-www-form-urlencoded"..

I fixed this by having clearsilver check only the prefix of content type, as you can see in my patch below. There is probably a better way to fix this, by having clearsilver properly parse the content type for it's parts according to the spec. Though perhaps this fix is enough...




root@w5:/home/hassan# diff -c clearsilver-0.10.5-orig/cgi/cgi.c clearsilver-0.10.5/cgi/cgi.c
*** clearsilver-0.10.5-orig/cgi/cgi.c 2007-07-11 19:38:03.000000000 -0700
--- clearsilver-0.10.5/cgi/cgi.c 2012-04-07 14:52:12.742725038 -0700
***************
*** 640,646 ****

if (!strcmp(method, "POST"))
{
! if (type && !strcmp(type, "application/x-www-form-urlencoded"))
{
err = _parse_post_form(cgi);
if (err != STATUS_OK) return nerr_pass (err);
--- 640,647 ----

if (!strcmp(method, "POST"))
{
! const char *formType = "application/x-www-form-urlencoded";
! if (type && !strncmp(type, formType, strlen(formType)-1 ))
{
err = _parse_post_form(cgi);
if (err != STATUS_OK) return nerr_pass (err);


#1439 From: "bxxx" <vincebouix@...>
Date: Mon Apr 23, 2012 7:51 am
Subject: Filter at runtime
vincebouix
Send Email Send Email
 
Hello Brandon, hello everybody,

I want to filter every dataset into clearsilver hdf at runtime.
OR is it possible to (override | add hook) "var" hdf function ?

thanks
VB

Messages 1410 - 1439 of 1451   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help