A new addition to desktop-file-utils? (Repost)
Jeff Abbott
fdiv_bug at sniping.org
Sat Oct 7 00:24:26 EEST 2006
On Oct 6, 2006, at 4:39 PM, Brian J. Tarricone wrote:
> 1. If it's going into a cross-desktop set of utility programs, the
> calls to gnome_desktop_file_*() have to go. It should't be too
> hard to
> just fopen() the file, fgets() each line until you see "[Desktop
> Entry]", then, assuming you don't see another line starting with '[',
> grab the first line that starts with "Exec=", "Name=", etc.
I was using these functions because they're already in use in the
desktop-file-utils toolset. I agree, though, and while I haven't dug
through all the source -- and don't really have the time to do so
right now -- it looks like those are purely names and don't have any
actual connection to GNOME. Thus, they could easily be renamed to
have more cross-desktop-friendly names and still provide internal
consistency for desktop-file-utils. Dunno what external stuff that
might break, though. I'd be willing to work up a patch for that, if
there was interest, and if my tool would be better suited outside of
desktop-file-utils I've got nothing against doing what little parsing
I need done the manual way, as you mention.
> 2. Instead of using system() and returning its exit code, you should
> use one of the exec*() functions instead.
To be honest, I used system() because it did the job I wanted and
seemed to do so well enough. Is there a reason for preferring exec*
() to it? I've got no problem with using one of the exec*()s, though
it was convenient to simply pass the string straight to system()
without having to do any coercion to make it fit the array params for
the execv*() functions that seemed to be the ones I might want.
> 3. Just use fprintf(stderr, ...) and avoid needing glib at all.
I was using Glib because it was already there for the other desktop-
file-utils stuff. Again, if I were to divorce the tool from that
toolset, though, I'd be up for removing Glib as a dependency.
> 4. Your use of strcat() is unsafe.
Should I be using strncat() instead? Something else?
Thanks a bunch for the feedback,
Jeff
More information about the xdg
mailing list