Обсуждение: WinCE/Pocket PC port for the C client library
Hello, I'm implementing a WinCE 4.x (Pocket PC 2003) application which needs to get data from a postgres database, so I "hacked" the 8.1.2 libpq source so I could get it working. Well, it seems to be working ok, but, as I don't know the code, have no idea if my hack is acceptable or induces other bugs I haven't seen yet. I attach my patch here, for any people interested. I also extended a test application I had already made for sqlite3 so it could be used as a basic test - SQLmd. It allows to open a sqlite3 or postgres database and make queries on it. Full source, including eVC4 project files and a "sparse" version of the postgres source are available at the following address: http://www.xpto.ath.cx/~lucas/postgres/SQLmd_source.zip For those who just want to try it, a PocketPC 2003 binary (ARM) is available here: http://www.xpto.ath.cx/~lucas/postgres/SQLmd_dbg.exe Well, I'll wait for people to tell me how I should proceed now... Best regards, ~Nuno Lucas
Вложения
> Hello, > > I'm implementing a WinCE 4.x (Pocket PC 2003) application > which needs to get data from a postgres database, so I > "hacked" the 8.1.2 libpq source so I could get it working. > > Well, it seems to be working ok, but, as I don't know the > code, have no idea if my hack is acceptable or induces other > bugs I haven't seen yet. # add_file "src/include/pg_config.h" # add_file "src/include/pg_config_paths.h" This part certainly isn't right :-) Those files are supposed to be auto-generated, not put in the source. As for: - if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR, - (char *) &optval, &optlen) == -1) + int err = getsockopt(conn->sock, SOL_SOCKET, SO_ERROR, + (char *) &optval, &optlen); +#if defined(_WIN32_WCE) + /* This was "googled" from the curl library source */ + /* Always returns this error, bug in CE? */ + if ( err == -1 && SOCK_ERRNO == WSAENOPROTOOPT ) + err=0; +#endif + if ( err == -1 ) Does it actually *have* the option and fail to set it, or is the option just not there? If it doesn't exist, you should just #ifdef out the tryign to set the option, IMHO. Apart from that it looks OK to me. There definitly needs to be some documentation on how to build it, though... //Magnus
On 4/13/06, Magnus Hagander <mha@sollentuna.net> wrote: > # add_file "src/include/pg_config.h" > # add_file "src/include/pg_config_paths.h" > > This part certainly isn't right :-) Those files are supposed to be > auto-generated, not put in the source. Right. It's here just for convenience and because there is no chance of autogenerating those (no autoconf port that I know of will ever understand a WinCE target). Maybe they should be already generated with some other name (e.g., pg_config_wince.h) and some readme telling users to rename/move them to the right place. > As for: > - if (getsockopt(conn->sock, SOL_SOCKET, > SO_ERROR, > - (char *) > &optval, &optlen) == -1) > + int err = getsockopt(conn->sock, > SOL_SOCKET, SO_ERROR, > + > (char *) &optval, &optlen); > +#if defined(_WIN32_WCE) > + /* This was "googled" from the curl > library source */ > + /* Always returns this error, bug in CE? > */ > + if ( err == -1 && SOCK_ERRNO == > WSAENOPROTOOPT ) > + err=0; > +#endif > + if ( err == -1 ) > > > Does it actually *have* the option and fail to set it, or is the option > just not there? If it doesn't exist, you should just #ifdef out the > tryign to set the option, IMHO. I really have no idea. It seems it accepts the option, but always returns the error when checking for it on WinCE. After I tried googling for it I discovered the curl library port for WinCE also checks for that error and ignores it (on WinCE). I was hoping some WinCE sockets "guru" could explain that to me ;-) A link to some curl library source I found with google is here: http://cool.haxx.se/cvs.cgi/curl/lib/connect.c?rev=1.120&content-type=text/vnd.viewcvs-markup Look for the verifyconnect() static function and you'll notice their use. > Apart from that it looks OK to me. There definitly needs to be some > documentation on how to build it, though... Yeah, that's why I included the eVC 4 project files, which include projects for building it as static library and as a DLL. For those that know it's way around the eVC compiler it should be easy enough to see what files need to be included on the project. As I'm not an english native speaker I was hopping some interested user would help in the documentation. Best regards, ~Nuno Lucas P.S.- I had an old sourceforge project when I ported SQLite for WinCE (which is now part of the official source) and as the SQLmd is also a SQLite utility program, I put the source there (instead of in my bandwidth limited home server). You can get the source here: http://sourceforge.net/project/showfiles.php?group_id=88393&package_id=187273&release_id=409524 > > //Magnus >