Mail Archives: geda-user/2012/11/18/10:52:10
Bob Paddock:
> > And tomorrow became today.
> > Bob, or anyone, could you test the attached program.
>
> Can't say I understand this:
>
> #ifdef __linux__
> #define MAX_PATH 400
> struct HINSTANCE_t {
> const char *filename;
> };
> ....
>
> Why would __linux__ defined and care about:
>
> HINSTANCE GetModuleHandle(void *handle) {
> (void) handle;
> gg.filename = "c:\\gEDA\\bin\\gschem";
> return ≫
> }
This just about so that I can test it in *some* way on my box.
I didn't want to send you something that didn't compile.
You can remove it, it is solely for testing.
> > I don't know how to compile it for MS-Windows.
>
> If you have Windows the easiest way is:
>
> http://nuwen.net/mingw.html gets you most of what you need.
> There will still be a few missing libraries.
>
> The other way to do it on Windows is with Cygwin,
> where it has the libraries but is a lot slower.
> http://www.cygwin.com/
Sorry, don't have MS-Windows.
> If you don't have Windows then the minipack cross compiler setup is
> part of the current distribution.
> Someone was working on making a mxe.cc cross compiler version but not
> have heard anymore about it (Anyone know its status?).
> http://mxe.cc/
I found
mingw32 (contains i586-mingw32msvc-gcc)
gcc-mingw-w64-i686 (contains i686-w64-mingw32-gcc)
on debian. But I don't have any crosscompiled glib, so both fails.
> > Which version of get_locale() do you like, should we use?
Maybe it should be called get_localedir() instead.
> I'll have to run this code and see what it does, for example:
> strncpy(cc, "\\share\\locale", sz - len);
> should that be strncat()?
No, cc is at end of path, though you could use
strncat(path, "..", sz - strlen(path) -1)
might be more obvious.
> Both strncpy and strncat will result in buffer overflows if all of
> MAX_PATH is used; sz -(len -1) would fix.
Not strncpy(), but it might not '\0' terminate the string.
If strncpy() I have to add path[sz-1] = '\0' to fix that.
So these two do the same job:
$ cat Tsz.c
#include <string.h>
#include <stdio.h>
#define SZ 20
int main(void) {
char path[SZ] = "c:\\gEDA\\bin\\gschem";
size_t len = strlen(path);
strncat(path, "\\share\\locale", SZ-len-1);
printf("path <%s>\nlen: %d\n", path, strlen(path));
strncpy(path+len, "\\share\\locale", SZ-len);
path[SZ-1] = '\0';
printf("path <%s>\nlen: %d\n", path, strlen(path));
return 0;
}
$ ./Tsz
path <c:\gEDA\bin\gschem\>
len: 19
path <c:\gEDA\bin\gschem\>
len: 19
I also forgot:
g_free(localedir);
in alt2.
> I like your Alt2 better as it is shorter.
> As you already said there is already a dependency on glib.
I don't really care as long as it does its job and runs on all
MS-Windows versions that libgeda targets (even in the future
hopefully).
Which one of:
1,
GetModuleHandle()
GetModuleFileName()
2,
g_win32_get_package_installation_directory_of_module()
will be deprecated first, what do you think?
Regards,
/Karl Hammar
-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57
- Raw text -