I forgot to add a new file to the patch. Here it is attached.
other compatibility things.
Post by Pedro AlvesHi guys,
The CeGCC project [1] has a need for a consistent set of rapi tools
across linux and windows hosts. I took a stab at porting the
librapi2/tools to Cygwin, and the attached patch is the result. The
biggest change, is that I made the tools dir independent of its
parent dir autoconf wise. Ideally it would be moved to the root dir,
or somewhere else not directly under librapi2. This also has the
advantage of having an example of an app that is ported to native
rapi.dll and to the synce api, without much effort.
I would be happy to clean this patch up before inclusion. I am seeking
for opinions from the maintainers to understand if such a port
would be accepted.
I have been using this port for over two months to run the gdb testsuite
against MSFT's WinCE emulator. The testsuite copies (pcp) and runs (prun)
a few thousand apps in a single run in series without problems.
Cheers,
Pedro Alves
P.S.: Is this list still appropriate? Seem like SynCE-windowsmobile2005
list has much more traffic these days. Also, should I rebase my patch
against any branch? I'm confused as to where is the main development
going on these days. (Granted; I didn't look enough, I'm lazy :) )
[1] http://cegcc.sourceforge.net
------------------------------------------------------------------------
Index: prm.c
===================================================================
--- prm.c (revision 2623)
+++ prm.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -69,14 +71,17 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 1;
- char* path = NULL;
- RapiConnection* connection = NULL;
+ char* path = NULL;
+#ifndef WIN32
+ RapiConnection* connection = NULL;
+#endif
HRESULT hr;
WCHAR* wide_path = NULL;
if (!handle_parameters(argc, argv, &path))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -85,6 +90,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
Index: pls.c
===================================================================
--- pls.c (revision 2623)
+++ pls.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -227,14 +229,16 @@ bool list_directory(WCHAR* directory)
int main(int argc, char** argv)
{
int result = 1;
- RapiConnection* connection = NULL;
+#ifndef WIN32
+ RapiConnection* connection = NULL;
+#endif
char* path = NULL;
WCHAR* wide_path = NULL;
HRESULT hr;
if (!handle_parameters(argc, argv, &path))
goto exit;
-
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -243,6 +247,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
Index: pmv.c
===================================================================
--- pmv.c (revision 2623)
+++ pmv.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -70,7 +72,9 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 1;
- RapiConnection* connection = NULL;
+#ifndef WIN32
+ RapiConnection* connection = NULL;
+#endif
char* source = NULL;
char* dest = NULL;
HRESULT hr;
@@ -80,6 +84,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv, &source, &dest))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -88,6 +93,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
Index: pstatus.c
===================================================================
--- pstatus.c (revision 2623)
+++ pstatus.c (working copy)
@@ -1,6 +1,9 @@
/* $Id$ */
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -210,7 +213,14 @@ void print_battery_status(const char* na
int main(int argc, char** argv)
{
int result = 1;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#else
+ typedef BOOL __stdcall (*CeGetSystemMemoryDivision_t)( LPDWORD, LPDWORD, LPDWORD);
+ HINSTANCE rapidll = LoadLibrary ("rapi.dll");
+ CeGetSystemMemoryDivision_t CeGetSystemMemoryDivision
+ = (CeGetSystemMemoryDivision_t)GetProcAddress(rapidll, (LPCSTR)19);
+#endif
HRESULT hr;
CEOSVERSIONINFO version;
SYSTEM_INFO system;
@@ -221,6 +231,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -229,6 +240,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
@@ -334,9 +346,21 @@ int main(int argc, char** argv)
}
else
{
- fprintf(stderr, "%s: Failed to get battery status: %s\n",
- argv[0],
- synce_strerror(CeGetLastError()));
+ DWORD err = CeGetLastError();
+ if (err == ERROR_SERVICE_DOES_NOT_EXIST)
+ {
+ printf(
+ "Power\n"
+ "=====\n"
+ );
+ printf("Not supported\n\n");
+ }
+ else
+ {
+ fprintf(stderr, "%s: Failed to get battery status: %s\n",
+ argv[0],
+ synce_strerror(err));
+ }
}
/*
@@ -378,6 +402,10 @@ int main(int argc, char** argv)
CeRapiUninit();
+#ifndef WIN32
rapi_connection_destroy(connection);
+#else
+ FreeLibrary(rapidll);
+#endif
return result;
}
Index: pkillall.c
===================================================================
--- pkillall.c (revision 2623)
+++ pkillall.c (working copy)
@@ -1,5 +1,8 @@
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,12 +60,19 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 0;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#else
+ typedef BOOL __stdcall (*CeKillAllApps_t) (void);
+ HINSTANCE rapidll = LoadLibrary ("rapi.dll");
+ CeKillAllApps_t CeKillAllApps = (CeKillAllApps_t)GetProcAddress(rapidll, (LPCSTR)24);
+#endif
HRESULT hr;
if (!handle_parameters(argc, argv))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -71,6 +81,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
{
@@ -90,7 +101,10 @@ int main(int argc, char** argv)
CeRapiUninit();
+#ifndef WIN32
rapi_connection_destroy(connection);
-
+#else
+ FreeLibrary(rapidll);
+#endif
return result;
}
Index: pcommon.c
===================================================================
--- pcommon.c (revision 2623)
+++ pcommon.c (working copy)
@@ -1,12 +1,100 @@
/* $Id$ */
#include "pcommon.h"
-#include "rapi.h"
-#include <synce_log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if !defined (WIN32)
+#include "rapi.h"
+#include <synce_log.h>
+#else
+
+static void
+_wce_strerror (char *buf, DWORD error)
+{
+ WCHAR* msgbuf;
+ DWORD chars = FormatMessageW (
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ error,
+ 0, /* Default language */
+ (LPVOID)&msgbuf,
+ 0,
+ NULL);
+ if (chars == 0)
+ {
+ /* Handle a few important cases ourselves when the
+ device doesn't support them (like mine). */
+ switch (error)
+ {
+ sprintf (buf, "WSAECONNRESET (%ld)", error);
+ break;
+ sprintf (buf, "unknown error (%ld)", error);
+ }
+ }
+ else
+ {
+ /* There is an \r\n appended; Kill it. */
+ if (chars >= 2)
+ msgbuf[chars - 2] = 0;
+ wcstombs(buf, msgbuf, chars + 1);
+ LocalFree (msgbuf);
+ }
+}
+
+const char *
+synce_strerror (DWORD err)
+{
+ static char buf[1024];
+ sprintf (buf, "err: %u, ", (int)err);
+ char* b = buf + strlen (buf);
+ _wce_strerror (b, err);
+ size_t len = strlen (b);
+ b[len] = '\n';
+ b[len + 1] = 0;
+ return buf;
+}
+
+WCHAR* wstr_from_current(const char* str)
+{
+ size_t count = strlen (str) + 1;
+ WCHAR* wstr = malloc (count * 2);
+ mbstowcs(wstr, str, count);
+ return wstr;
+}
+
+char* wstr_to_current(const WCHAR* wstr)
+{
+ size_t count = wcslen (wstr) + 1;
+ char* str = malloc (count);
+ wcstombs(str, wstr, count);
+ return str;
+}
+
+WCHAR* win32_wcsdup(const WCHAR* org)
+{
+ size_t count = wcslen (org) + 1;
+ WCHAR* cpy = malloc (count * 2);
+ wcscpy(cpy, org);
+ return cpy;
+}
+
+
+static int log_level;
+void synce_log_set_level(int level)
+{
+ log_level = level;
+}
+
+#endif
+
+#if !defined (WIN32)
#define WIDE_BACKSLASH htole16('\\')
+#else
+#define WIDE_BACKSLASH '\\'
+#endif
void convert_to_backward_slashes(char* path)
{
@@ -81,12 +169,12 @@ static void anyfile_remote_close(AnyFile
static bool anyfile_remote_read(AnyFile* file, unsigned char* buffer, size_t bytes, size_t* bytesAccessed)
{
- return CeReadFile(file->handle.remote, buffer, bytes, bytesAccessed, NULL);
+ return CeReadFile(file->handle.remote, buffer, bytes, (DWORD*)bytesAccessed, NULL);
}
static bool anyfile_remote_write(AnyFile* file, unsigned char* buffer, size_t bytes, size_t* bytesAccessed)
{
- return CeWriteFile(file->handle.remote, buffer, bytes, bytesAccessed, NULL);
+ return CeWriteFile(file->handle.remote, buffer, bytes, (DWORD*)bytesAccessed, NULL);
}
static void anyfile_local_close(AnyFile* file)
@@ -157,16 +245,17 @@ static AnyFile* anyfile_local_open(const
switch (access)
{
- file->handle.local = fopen(filename, "r");
+ file->handle.local = fopen(filename, "rb");
break;
- file->handle.local = fopen(filename, "w");
+ file->handle.local = fopen(filename, "wb");
break;
}
if (NULL == file->handle.local)
{
+ perror("open file error\n");
free(file);
file = NULL;
}
Index: pcommon.h
===================================================================
--- pcommon.h (revision 2623)
+++ pcommon.h (working copy)
@@ -1,7 +1,12 @@
#ifndef __pcommon_h__
#define __pcommon_h__
+#if !defined (WIN32) && !defined (__CYGWIN__)
#include <synce.h>
+#else
+#include <windows.h>
+#include "wincompat.h"
+#endif
#ifdef __cplusplus
extern "C"
Index: rapiconfig.c
===================================================================
--- rapiconfig.c (revision 2623)
+++ rapiconfig.c (working copy)
@@ -1,7 +1,10 @@
/* $Id$ */
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce.h>
#include <synce_log.h>
+#endif
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -104,7 +107,13 @@ int main(int argc, char** argv)
long bytes_left;
LPWSTR config = NULL;
LPWSTR reply = NULL;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#else
+ typedef HRESULT __stdcall (*CeProcessConfig_t) (LPCWSTR, DWORD, LPWSTR*);
+ HINSTANCE rapidll = LoadLibrary ("rapi.dll");
+ CeProcessConfig_t CeProcessConfig = (CeProcessConfig_t)GetProcAddress(rapidll, (LPCSTR)25);
+#endif
/*
Initialization
@@ -171,7 +180,7 @@ int main(int argc, char** argv)
/*
Do the bossanova
*/
-
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -180,6 +189,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
@@ -203,6 +213,9 @@ int main(int argc, char** argv)
CeRapiUninit();
+#ifdef WIN32
+ FreeLibrary(rapidll);
+#endif
if (buffer)
free(buffer);
Index: pcp.c
===================================================================
--- pcp.c (revision 2623)
+++ pcp.c (working copy)
@@ -1,20 +1,28 @@
/* $Id$ */
#include "pcommon.h"
#include <rapi.h>
+
+#if !defined (WIN32)
#include <synce_log.h>
+#else
+#include "wincompat.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
char* devpath = NULL;
+bool verbose = false;
static void show_usage(const char* name)
{
fprintf(stderr,
"Syntax:\n"
"\n"
- "\t%s [-d LEVEL] [-p DEVPATH] [-h] SOURCE DESTINATION\n"
+ "\t%s [-d LEVEL] [-p DEVPATH] [-h] [-v] SOURCE DESTINATION\n"
"\n"
"\t-d LEVEL Set debug log level\n"
"\t 0 - No logging (default)\n"
@@ -22,7 +30,8 @@ static void show_usage(const char* name)
"\t 2 - Errors and warnings\n"
"\t 3 - Everything\n"
"\t-h Show this help message\n"
- "\t-p DEVPATH Device path\n"
+ "\t-v Verbose\n"
+ "\t-p DEVPATH Device path\n"
"\tSOURCE The source filename\n"
"\tDESTINATION The destination filename\n",
name);
@@ -34,7 +43,7 @@ static bool handle_parameters(int argc,
int path_count;
int log_level = SYNCE_LOG_LEVEL_LOWEST;
- while ((c = getopt(argc, argv, "d:hp:")) != -1)
+ while ((c = getopt(argc, argv, "d:hvp:")) != -1)
{
switch (c)
{
@@ -46,6 +55,9 @@ static bool handle_parameters(int argc,
devpath = optarg;
break;
+ verbose = true;
+ break;
show_usage(argv[0]);
@@ -72,7 +84,16 @@ static bool handle_parameters(int argc,
static bool remote_copy(const char* ascii_source, const char* ascii_dest)
{
+#ifndef WIN32
return CeCopyFileA(ascii_source, ascii_dest, false);
+#else
+ WCHAR* src = wstr_from_current(ascii_source);
+ WCHAR* dest = wstr_from_current(ascii_dest);
+ bool ret = CeCopyFile(src, dest, false);
+ wstr_free_string(src);
+ wstr_free_string(dest);
+ return ret;
+#endif
}
#define ANYFILE_BUFFER_SIZE (4*1024)
int main(int argc, char** argv)
{
int result = 1;
- RapiConnection* connection = NULL;
+#ifndef WIN32
+ RapiConnection* connection = NULL;
+#endif
char* source = NULL;
char* dest = NULL;
HRESULT hr;
- time_t start;
- time_t duration;
size_t bytes_copied = 0;
if (!handle_parameters(argc, argv, &source, &dest))
goto exit;
-
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -177,6 +198,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
@@ -264,22 +286,25 @@ int main(int argc, char** argv)
}
else
{
- start = time(NULL);
+ time_t start;
+ if (verbose)
+ start = time(NULL);
- /*
+ /*
* At least one is local, Use the AnyFile functions
*/
if (!anyfile_copy(source, dest, argv[0], &bytes_copied))
goto exit;
- duration = time(NULL) - start;
-
- if (0 == duration)
- printf("File copy took less than one second!\n");
- else
- printf("File copy of %i bytes took %li minutes and %li seconds, that's %li bytes/s.\n",
- bytes_copied, duration / 60, duration % 60, bytes_copied / duration);
-
+ if (verbose)
+ {
+ time_t duration = time(NULL) - start;
+ if (0 == duration)
+ printf("File copy took less than one second!\n");
+ else
+ printf("File copy of %i bytes took %li minutes and %li seconds, that's %li bytes/s.\n",
+ bytes_copied, duration / 60, duration % 60, bytes_copied / duration);
+ }
}
result = 0;
if (dest)
free(dest);
- CeRapiUninit();
+ if (!FAILED(hr))
+ CeRapiUninit();
return result;
}
Index: synce-list-programs.c
===================================================================
--- synce-list-programs.c (revision 2623)
+++ synce-list-programs.c (working copy)
@@ -1,6 +1,9 @@
/* $Id$ */
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,7 +60,9 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int return_value = 1;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#endif
HRESULT hr;
LONG result;
HKEY parent_key;
@@ -69,6 +74,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -77,6 +83,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
Index: prun.c
===================================================================
--- prun.c (revision 2623)
+++ prun.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
#include "pcommon.h"
-#include "rapi.h"
+#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -42,9 +44,9 @@ static bool handle_parameters(int argc,
log_level = atoi(optarg);
break;
- devpath = optarg;
- break;
+ devpath = optarg;
+ break;
@@ -64,8 +66,31 @@ static bool handle_parameters(int argc,
*program = strdup(argv[optind++]);
- if (optind < argc)
- *parameters = strdup(argv[optind]);
+ {
+ size_t len = 0;
+ int i;
+ for(i = optind; i < argc; i++)
+ len += strlen(argv[i]) + 1;
+ if (len)
+ {
+ char* p = malloc(len);
+ char* o = p;
+ *p = '\0';
+ for(; optind < argc; optind++)
+ {
+ strcat(p, argv[optind]);
+ p += strlen(argv[optind]);
+ *p = ' ';
+ p++;
+ }
+ *p = '\0';
+ *parameters = o;
+ }
+ else
+ {
+ *parameters = 0;
+ }
+ }
return true;
}
@@ -73,7 +98,9 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 1;
- RapiConnection* connection = NULL;
+#ifndef WIN32
+ RapiConnection* connection = NULL;
+#endif
char* program = NULL;
char* parameters = NULL;
HRESULT hr;
@@ -84,6 +111,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv, &program, ¶meters))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -92,6 +120,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
@@ -135,15 +164,16 @@ int main(int argc, char** argv)
result = 0;
- wstr_free_string(wide_program);
- wstr_free_string(wide_parameters);
-
+ if (wide_program)
+ wstr_free_string(wide_program);
+ if (wide_parameters)
+ wstr_free_string(wide_parameters);
if (program)
free(program);
-
if (parameters)
free(parameters);
- CeRapiUninit();
+ if (!FAILED(hr))
+ CeRapiUninit();
return result;
}
Index: pmkdir.c
===================================================================
--- pmkdir.c (revision 2623)
+++ pmkdir.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -69,7 +71,9 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 1;
- RapiConnection* connection = NULL;
+#ifndef WIN32
+ RapiConnection* connection = NULL;
+#endif
char* path = NULL;
HRESULT hr;
WCHAR* wide_path = NULL;
@@ -77,6 +81,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv, &path))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -85,6 +90,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
Index: oidinfo.c
===================================================================
--- oidinfo.c (revision 2623)
+++ oidinfo.c (working copy)
@@ -1,12 +1,17 @@
/* $Id$ */
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef WIN32
char* devpath = NULL;
+#endif
static void show_usage(const char* name)
{
@@ -40,7 +45,9 @@ static bool handle_parameters(int argc,
break;
+#ifndef WIN32
devpath = optarg;
+#endif
break;
@@ -70,11 +77,14 @@ int main(int argc, char** argv)
HRESULT hr;
CEOID oid = 0;
CEOIDINFO info;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#endif
if (!handle_parameters(argc, argv, &oid))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -83,6 +93,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
Index: synce-registry.c
===================================================================
--- synce-registry.c (revision 2623)
+++ synce-registry.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
-#include <pcommon.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -435,10 +437,33 @@ int write_val(HKEY key, LPCWSTR value_na
return 0;
}
+#ifdef WIN32
+/* This function is exported by synce, but
+ rapi.dll only has the wide version. */
+bool rapi_reg_open_key(HKEY parent, const char* name, HKEY* key)
+{
+ WCHAR* name_wide = wstr_from_current(name);
+
+ LONG result = CeRegOpenKeyEx(
+ parent,
+ name_wide,
+ 0,
+ 0,
+ key
+ );
+
+ wstr_free_string(name_wide);
+
+ return ERROR_SUCCESS == result;
+}
+#endif
+
int main(int argc, char** argv)
{
int result = 1;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#endif
char* parent_str = NULL;
char* key_name = NULL;
char* value_name = NULL;
@@ -478,6 +503,7 @@ int main(int argc, char** argv)
goto exit;
}
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -486,6 +512,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
if (S_OK != (hr = CeRapiInit()))
{
fprintf(stderr, "%s: Unable to initialize RAPI: %s\n",
Index: Makefile.am
===================================================================
--- Makefile.am (revision 2623)
+++ Makefile.am (working copy)
@@ -1,12 +1,11 @@
+AM_CFLAGS = $(TOOLS_CFLAGS)
+AM_LDFLAGS = $(TOOLS_LDFLAGS)
-INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/support
-LDADD = ../src/librapi.la
+INCLUDES =
+LDADD =
noinst_PROGRAMS = oidinfo
-
-oidinfo_SOURCES = oidinfo.c
+oidinfo_SOURCES = pcommon.c oidinfo.c
bin_PROGRAMS = pcp pls pmkdir pmv prm prmdir prun pstatus rapiconfig pkillall pshortcut psettime \
synce-list-programs synce-registry
@@ -18,14 +17,14 @@ pmv_SOURCES = pcommon.c pmv.c
prm_SOURCES = pcommon.c prm.c
prmdir_SOURCES = pcommon.c prmdir.c
prun_SOURCES = pcommon.c prun.c
-pstatus_SOURCES= pstatus.c
-pkillall_SOURCES=pkillall.c
-pshortcut_SOURCES=pcommon.c pshortcut.c
-psettime_SOURCES=psettime.c
+pstatus_SOURCES= pcommon.c pstatus.c
+pkillall_SOURCES = pcommon.c pkillall.c
+pshortcut_SOURCES = pcommon.c pshortcut.c
+psettime_SOURCES = pcommon.c psettime.c
-rapiconfig_SOURCES = rapiconfig.c
+rapiconfig_SOURCES = pcommon.c rapiconfig.c
-synce_list_programs_SOURCES = synce-list-programs.c
+synce_list_programs_SOURCES = pcommon.c synce-list-programs.c
synce_registry_SOURCES = synce-registry.c pcommon.c
SUBDIRS = man
Index: psettime.c
===================================================================
--- psettime.c (revision 2623)
+++ psettime.c (working copy)
@@ -1,5 +1,8 @@
+#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,12 +60,15 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 0;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#endif
HRESULT hr;
if (!handle_parameters(argc, argv))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -71,6 +77,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
{
@@ -81,16 +88,24 @@ int main(int argc, char** argv)
goto exit;
}
+#ifdef WIN32
+ typedef BOOL __stdcall (*CeSyncTimeToPc_t) (void);
+ HINSTANCE rapidll = LoadLibrary ("rapi.dll");
+ /* 13 or 16, or? */
+ CeSyncTimeToPc_t CeSyncTimeToPc = (CeSyncTimeToPc_t)GetProcAddress(rapidll, (LPCSTR)13);
+#endif
if (!CeSyncTimeToPc())
{
fprintf(stderr,"%s: CeSyncTimeToPc failed\n",argv[0]);
result = 2;
goto exit;
}
-
CeRapiUninit();
+#ifndef WIN32
rapi_connection_destroy(connection);
-
+#else
+ FreeLibrary(rapidll);
+#endif
return result;
}
Index: pshortcut.c
===================================================================
--- pshortcut.c (revision 2623)
+++ pshortcut.c (working copy)
@@ -1,6 +1,8 @@
#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -70,9 +72,12 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 0;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#endif
HRESULT hr;
- char *shortcut, *target;
+ char *shortcut = NULL;
+ char *target = NULL;
WCHAR* wide_shortcut = NULL;
WCHAR* wide_target = NULL;
WCHAR *tmp, *tmp_quote;
@@ -80,7 +85,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv, &shortcut, &target))
goto exit;
-
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -89,6 +94,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
@@ -144,7 +150,9 @@ int main(int argc, char** argv)
free(target);
CeRapiUninit();
+#ifndef WIN32
rapi_connection_destroy(connection);
+#endif
return result;
}
Index: prmdir.c
===================================================================
--- prmdir.c (revision 2623)
+++ prmdir.c (working copy)
@@ -1,7 +1,9 @@
/* $Id$ */
#include "pcommon.h"
#include <rapi.h>
+#ifndef WIN32
#include <synce_log.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -69,7 +71,9 @@ static bool handle_parameters(int argc,
int main(int argc, char** argv)
{
int result = 1;
+#ifndef WIN32
RapiConnection* connection = NULL;
+#endif
char* path = NULL;
HRESULT hr;
WCHAR* wide_path = NULL;
@@ -77,6 +81,7 @@ int main(int argc, char** argv)
if (!handle_parameters(argc, argv, &path))
goto exit;
+#ifndef WIN32
if ((connection = rapi_connection_from_path(devpath)) == NULL)
{
fprintf(stderr, "%s: Could not find configuration at path '%s'\n",
@@ -85,6 +90,7 @@ int main(int argc, char** argv)
goto exit;
}
rapi_connection_select(connection);
+#endif
hr = CeRapiInit();
if (FAILED(hr))
------------------------------------------------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
------------------------------------------------------------------------
_______________________________________________
Synce-devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel