[TAG] Compliments to you all.
Jimmy O'Regan
jimregan at o2.ie
Sat Jun 5 08:00:33 MSD 2004
Ben Okopnik wrote:
>On Fri, Jun 04, 2004 at 11:23:39AM -0400, Tom Brown wrote:
>
>
>> Anyway, I'm trying to find the time to learn how to write GUI
>>programs in Linux (I've done some command-line stuff -- you know, pipe
>>the output of this program to the input of that program, and pipe the
>>result to a third one...), but spend a lot of time working with Windows
>>(to pay the bills, you see).
>>
>>
>
>Take a look at Tcl/Tk. Conversely, consider CGI, where most of the
>graphics setup has been done for you. If you want to stick with C,
>there's a "Visual"-type form builder that I've used and was rather
>impressed with that came with a libforms0.88 tarball that I got off the
>net somewhere. Sorry I'm not being more precise, but I've just checked,
>and I don't have the tarball anymore. [shrug] Perl/Tk does everything I
>need in that direction, which isn't very much in the first place.
>
>Tcl/Tk, however, is a fun little gadget, and the basics are not that
>hard to learn. Here's a little proglet that lets you put your laptop in
>suspend mode using a GUI instead of the command line:
>
>``
>#!/usr/bin/wish
>
>proc cmd {} { exec sudo /usr/bin/apm "-s"; exit; }
>button .b -text "Sleep" -command cmd; .b config -bg yellow; pack .b
>button .x -text "Quit" -command exit; .x config -activebackground red; pack .x
>''
>
>
With GNOME and KDE you get interface designers which can generate code
for most supported languages. With GNOME at least, the GLADE program can
generate C, C++, Perl, Python, Ruby (it can probably even generate COBOL
- GNOME people like their language bindings).
>[snip]
>Tell you what - here, take a look at this code, and see if you can
>figure out what's wrong with it (note that input length _is_ being
>validated!):
>
>-----------------------------------------------------------------------
>// by Aaron Adams <aadams at securityfocus.com>
>
>#include <stdio.h>
>#include <stdlib.h>
>
>#define SIZE 252
>
>int main(int argc, char *argv[])
>{
> int i;
> char *p1, *p2;
> char *buf1 = malloc(SIZE);
> char *buf2 = malloc(SIZE);
>
>
Now, my C is rusty, but shouldn't those malloc calls be
malloc ((SIZE + 1) * sizeof (char));
Plus it's bad practise to have an assignment like this in a declaration
in C.
More information about the TAG
mailing list