To use PACKAGE and VERSION declare them as extern in your vala source code.
Sorry, I pasted the man page of gets but FileStream.gets is the wrapper of fgets. char *fgets(char *s, int size, FILE *stream); fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A '\0' is stored after the last character in the buffer. That means that FileStream.gets will stop reading when the buffer size is reached. However, fgets does not know of utf-8. You will have instead to look at the objects in GIO (the glib input/output objects/functions). On Thu, Feb 3, 2011 at 5:33 PM, Giulio Paci <giuliop...@gmail.com> wrote: > Hi Sandino, > > thank you for your very quick reply, > > > Il 03/02/2011 23:23, Sandino Flores Moreno ha scritto: > >> On Thu, Feb 3, 2011 at 3:27 PM, Giulio Paci <giuliop...@gmail.com> wrote: >>> 1) I tried to create a gstreamer plugin following the Gstreamer Plugin >>> Writer's Guide >>> (http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/index.html). >>> I was able to create the plugin, but I was not able to create it using >>> vala alone, because I was not able to insert in the generated C output >>> this code: >>> >>> #include <glib.h> >>> #include <gst/gst.h> >>> GST_PLUGIN_DEFINE ( >>> GST_VERSION_MAJOR, >>> GST_VERSION_MINOR, >>> "my_filter", >>> "My filter plugin", >>> plugin_init, >>> VERSION, >>> "LGPL", >>> "GStreamer", >>> "http://gstreamer.net/" >>> ) >>> >>> At last I decided it was not a big issue to put this code in a C file, >>> but is there any way to directly inject C code in vala? >> Regarding question 1: >> ================== >> >> Check the next source code: >> https://github.com/tigrux/gst-plugin-omap4videodecbin/blob/master/gst/gstomap4videodecbin.vala >> >> There you can see a line like these: >> public const Gst.PluginDesc gst_plugin_desc = { >> ... >> } >> >> That's what you are missing in your gstreamer plugin. >> > This is very close to what I wanted. > What I'm still missing is the possibility to use PACKAGE and VERSION > macros. >>> 2) I tried to read a file, one line at time, using the FileStream >>> object, but I was not able to get the desired result with the current >>> API, because I needed the whole line (EOL inclusive), while read_line() >>> removes it. The work around of adding a new line to each line does not >>> allow to know if the last character of the file was a new line or not. >>> Is there any way to (easily) read a file including the EOL character? >> Regarding question 2: >> ================== >> >> Use the method FileStream.gets which corresponds to fgets. >> public unowned string FileStream.gets (char[] s); >> >> >From the man page of fgets: >> gets() reads a line from stdin into the buffer pointed to by s >> until >> either a terminating newline or EOF, which it replaces with '\0'. >> No >> check for buffer overrun is performed (see BUGS below). >> >> gets() reads a line from stdin into the buffer pointed to by s >> until >> either a terminating newline or EOF, which it replaces with '\0'. >> No >> check for buffer overrun is performed (see BUGS below). >> > This sounds exactly what I need. As I need to have valid utf-8 > characters, do I have to perform any check for the last returned bytes > (if the line is longer than the char array) or does FileStream.gets > guarantee that the last returned character is valid? > > By the way, Is there a better documentation than > http://www.valadoc.org/glib-2.0/GLib.FileStream.html? By reading it I > avoided even trying FileStream.gets as I thought it was just some sort > of gets and not fgets. > > Bests, > Giulio. > > _______________________________________________ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list