gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MS VC6.0 gnokii DLL (WIN32 x86)


From: Ladislav Michl
Subject: Re: MS VC6.0 gnokii DLL (WIN32 x86)
Date: Mon, 10 Feb 2003 10:04:54 +0100
User-agent: Mutt/1.5.3i

On Sun, Feb 09, 2003 at 11:17:38PM +0100, Pawel Kot wrote:
> On Sun, 9 Feb 2003, Marcus Godehardt wrote:
> 
> Okay. I submitted your patches. Just VC6 project files left.
> I got the VC6 files from ladis as I wrote in the previous mail. These are
> available at: http://tfuj.pl/gnokii-MSVC6/
> 
> Please discuss which one is better, I have no real opinion but see above.
> 
> > This is the new dir tree under Win32
> >
> > Win32
> > |
> > +--gnokii_vc6
> >    |
> >    +--dllgnokii
> 
> Ladis has:
>   Wind32
    ^^^^^^ - typo :)
I have also Win32
>   |
>   +--MSVC6
>      |
>      +--libgnokii
> And I'd say that I'd prefer probably gnokii_vc6 then MSVC6 and definitely
> libgnokii then dllgnokii.

MSVC6 is what whould user of Microsoft Developer Studio expect (other
projects are using this name too).

> > put gnokii.dsp, gnokii.dsw and config.h in folder gnokii_vc6
> > put dllgnokii.dsp in folder dllgnokii
> > add include to MSVC6.0 Include Directory Search Path ( otherwise compiler
> > will not find headers )
> > copy config.h to include folder ( only on local working copy if u wish to
> > compile it )
> 
> Can't it be done automatically? ladis also writes about manual copying but
> I'd really prefer having it done automatically.

MSVC is able to run external commands. Unfortunately in seems that it
can run sometning only before linking and after build. Marcus, am I
right?

> > copy gnokiirc config file in gnokii_vc6 folder ( only if u execute gnokii
> > console app )
> 
> Again: any automaton for it?

this can be done automaticaly.

> [BTW. I belive it was the reason for fcopy.bat or whatever it is called]

> > now it should compile under Win32
> 
> Good. I hope we'll put some Windows binaries publically out this week :-)

now let's write some comments to Marcus patches :)

> > Index: gnokii.c
> > ===================================================================
> > RCS file: /cvsroot/gnokii/gnokii/gnokii/gnokii.c,v
> > retrieving revision 1.332
> > diff -u -r1.332 gnokii.c
> > --- gnokii.c        2 Feb 2003 22:38:21 -0000       1.332
> > +++ gnokii.c        9 Feb 2003 07:31:02 -0000
> > @@ -54,7 +54,8 @@
> >  
> >  #  include <windows.h>
> >  #  include <process.h>
> > -#  include "getopt.h"
> > +#  include <direct.h>
> > +#  include <win32/getopt.h>
> >  
> >  #else
> >  
> > @@ -4181,7 +4182,13 @@
> >             fprintf(stderr, _("### Exists?!\n"));
> >             return GN_ERR_FAILED;
> >     }
> > +
> > +#   ifdef WIN32
> > +   _mkdir(smsdir);
> > +#   else
> >     mkdir(smsdir, 0700);
> > +#   endif
> > +

here I'd prefer to add something like
#define mkdir(x, y)     _mkdir(x)
to compat.h. And I'd guess that WinNT based systems also know something
about access rights.

> >     if ((output = fopen(buf, "w+")) == NULL) {
> >             fprintf(stderr, _("### Cannot create file %s\n"), buf);
> >             return GN_ERR_FAILED;
> > @@ -4253,7 +4260,12 @@
> >  
> >  static void list_gsm_networks(void)
> >  {
> > +#ifdef WIN32
> > +   __declspec(dllimport) gn_network networks[];
> > +#else
> >     extern gn_network networks[];
> > +#endif
> > +

What about this patch?

Index: common/gsm-networks.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-networks.c,v
retrieving revision 1.28
diff -u -r1.28 gsm-networks.c
--- common/gsm-networks.c       9 Feb 2003 21:57:56 -0000       1.28
+++ common/gsm-networks.c       10 Feb 2003 08:50:02 -0000
@@ -30,6 +30,7 @@
 
 #include "config.h"
 #include "compat.h"
+#include "misc.h"
 #include <string.h>
 #include "gsm-networks.h"
 
@@ -151,10 +152,10 @@
        { "730", "Chile" },
        { "734", "Venezuela" },
 
-       { "undefined", "unknown" }
+       { NULL, NULL }
 };
 
-API gn_network networks[] = {
+gn_network networks[] = {
        { "202 01", "Cosmote" },
        { "202 05", "Vodafone (PANAFON)" },
        { "202 10", "TELESTET" },
@@ -400,45 +401,62 @@
        { "730 10", "Entel PCS" },
        { "734 01", "Infonet" },
 
-       { "undefined", "unknown" }
+       { NULL, NULL }
 };
 
 API char *gn_network_name_get(char *network_code)
 {
        int index = 0;
 
-       while (strcmp(networks[index].code, network_code) &&
-               strcmp(networks[index].code, "undefined")) index++;
+       while (networks[index].code &&
+              strcmp(networks[index].code, network_code)) index++;
 
-       return networks[index].name;
+       /* for now be compacrapatible ;) */
+       return networks[index].name ? networks[index].name : "unknown";
 }
 
 API char *gn_network_code_get(char *network_name)
 {
        int index = 0;
 
-       while (strcmp(networks[index].name, network_name) &&
-               strcmp(networks[index].code, "undefined")) index++;
+       while (networks[index].name &&
+              strcmp(networks[index].name, network_name)) index++;
 
-       return networks[index].code;
+       return networks[index].code ? networks[index].code : "undefined";
 }
 
 API char *gn_country_name_get(char *country_code)
 {
        int index = 0;
 
-       while (strncmp(countries[index].code, country_code, 3) &&
-               strcmp(countries[index].code, "undefined")) index++;
+       while (countries[index].code &&
+              strncmp(countries[index].code, country_code, 3)) index++;
 
-       return countries[index].name;
+       return countries[index].name ? countries[index].name : "unknown";
 }
 
 API char *gn_country_code_get(char *country_name)
 {
        int index = 0;
 
-       while (strcmp(countries[index].name, country_name) &&
-               strcmp(countries[index].code, "undefined")) index++;
+       while (countries[index].name &&
+              strcmp(countries[index].name, country_name)) index++;
 
-       return countries[index].code;
+       return countries[index].code ? countries[index].code : "undefined";
+}
+
+API bool gn_network_get(gn_network *network, int index)
+{
+       if (index < 0 || index >= ARRAY_LEN(networks) - 1)
+               return false;
+       *network = networks[index];
+       return true;
+}
+
+API bool gn_country_get(gn_country *country, int index)
+{
+       if (index < 0 || index >= ARRAY_LEN(countries) - 1)
+               return false;
+       *country = countries[index];
+       return true;
 }
Index: include/gsm-api.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/gsm-api.h,v
retrieving revision 1.42
diff -u -r1.42 gsm-api.h
--- include/gsm-api.h   1 Jan 2003 21:29:06 -0000       1.42
+++ include/gsm-api.h   10 Feb 2003 08:50:02 -0000
@@ -102,12 +102,15 @@
 /* Errors */
 API char *gn_error_print(gn_error e);
 
-/* These functions are used to search the structure defined above.*/
+/* These functions are used to search for network info. */
 API char *gn_network_name_get(char *network_code);
 API char *gn_network_code_get(char *network_name);
 
 API char *gn_country_name_get(char *country_code);
 API char *gn_country_code_get(char *country_name);
+
+API bool gn_network_get(gn_network *network, int index);
+API bool gn_country_get(gn_country *country, int index);
 
 /* Ringtones */
 API u8 gn_ringtone_pack(gn_ringtone *ringtone, unsigned char *package, int 
*maxlength);
Index: gnokii/gnokii.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/gnokii/gnokii.c,v
retrieving revision 1.336
diff -u -r1.336 gnokii.c
--- gnokii/gnokii.c     9 Feb 2003 22:01:44 -0000       1.336
+++ gnokii/gnokii.c     10 Feb 2003 08:50:03 -0000
@@ -4257,13 +4257,14 @@
 
 static void list_gsm_networks(void)
 {
-       API extern gn_network networks[];
-       int i;
+
+       gn_network network;
+       int i = 0;
 
        printf("Network  Name\n");
        printf("-----------------------------------------\n");
-       for (i = 0; strcmp(networks[i].name, "unknown"); i++)
-               printf("%-7s  %s\n", networks[i].code, networks[i].name);
+       while (gn_network_get(&network, i++))
+               printf("%-7s  %s\n", network.code, network.name);
 }
 
 static int getnetworkinfo(void)

I made it backward compatible, although functions should return NULL on
failure rather than "undefined" or "unknown". If there are no
objections, i'd like to apply this patch to cvs.

> >     int i;
> >  
> >     printf("Network  Name\n");



> > Index: tekram.c
> > ===================================================================
> > RCS file: /cvsroot/gnokii/gnokii/common/devices/tekram.c,v
> > retrieving revision 1.10
> > diff -u -r1.10 tekram.c
> > --- tekram.c        5 Feb 2003 01:27:47 -0000       1.10
> > +++ tekram.c        9 Feb 2003 07:29:57 -0000
> > @@ -53,7 +53,11 @@
> >  #if defined(O_NOCTTY) && defined(O_NONBLOCK)
> >     return serial_open(file, O_RDWR | O_NOCTTY | O_NONBLOCK);
> >  #else
> > -   return serial_open(file, O_RDWR);
> > +#   ifdef WIN32
> > +           return serial_open(file, 0);
> > +#   else
> > +       return serial_open(file, O_RDWR);
> > +#   endif

MSVC defines _O_RDWR so what about
#define O_RDWR  _O_RDWR
in compat.h?

> >  #endif
> >  }

now question comes in mind. WIN32 should be defined for all compilers
building binaries for Win32 systems (gcc, MSVC, CBuilder, mingw...).
>From this point of view #ifdef WIN32 is missleading in many places.
Better solution is IMHO to use compiler specific defines and place as
much as possible to compat.h

Any comments? (I've got access to Windows box with MSVC installed, so
i'll check the rest in the evening)

        ladis




reply via email to

[Prev in Thread] Current Thread [Next in Thread]