summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pool <mbp@sourcefrog.net>2015-11-22 22:10:18 -0800
committerMartin Pool <mbp@sourcefrog.net>2015-11-22 22:10:18 -0800
commit8763b7ca5ffda8871afeef17ad17e6fe1773b7d4 (patch)
treed789022e180137ba28e87cbeb3bd2719542af24b
parentbbbfc268e33df4c72890907a1f50c8ba3d822e62 (diff)
downloadlibrsync-rust.tar.gz
Add new rs_version() to get the library versionrust
-rw-r--r--TODO.md5
-rw-r--r--src/lib.rs9
-rw-r--r--src/librsync.h4
-rw-r--r--src/rdiff.c10
4 files changed, 18 insertions, 10 deletions
diff --git a/TODO.md b/TODO.md
index 0e54631..9b89082 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,3 +1,8 @@
+## Rust port
+
+* How to handle rs_version, exposing a static string char*?
+
+## Misc
* Upload built documentation to librsync.sourcefrog.net, delete dead sites.
* Documentation
diff --git a/src/lib.rs b/src/lib.rs
index dae7ac6..468b398 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,9 +17,12 @@
extern crate libc;
-pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
+// pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
+
+pub static VERSION: &'static str = env!("CARGO_PKG_VERSION");
#[no_mangle]
-pub extern fn rs_hello() {
- println!("hello from rust!");
+pub extern fn rs_version() -> *const libc::c_char {
+ // Version from environment has nul termination (I think we can count on this?)
+ return VERSION.as_ptr() as *const libc::c_char;
}
diff --git a/src/librsync.h b/src/librsync.h
index e9eb822..430b6e4 100644
--- a/src/librsync.h
+++ b/src/librsync.h
@@ -47,9 +47,11 @@
extern "C" {
#endif
-extern char const rs_librsync_version[];
+/* rs_librsync_version was replaced by rs_version() in 2.0 */
extern char const rs_licence_string[];
+const char* rs_version();
+
typedef unsigned char rs_byte_t;
diff --git a/src/rdiff.c b/src/rdiff.c
index 2ed74ff..b14e4d2 100644
--- a/src/rdiff.c
+++ b/src/rdiff.c
@@ -173,14 +173,14 @@ static void rdiff_show_version(void)
#ifdef HAVE_LIBBZ2
bzlib = ", bzip2";
#endif
-#endif
+#endif /* if 0 */
#ifndef DO_RS_TRACE
trace = ", trace disabled";
#endif
- printf("rdiff (%s) [%s]\n"
- "Copyright (C) 1997-2014 by Martin Pool, Andrew Tridgell and others.\n"
+ printf("rdiff (%s)\n"
+ "Copyright (C) 1997-2015 by Martin Pool, Andrew Tridgell and others.\n"
"http://librsync.sourcefrog.net/\n"
"Capabilities: %ld bit files%s%s%s\n"
"\n"
@@ -188,7 +188,7 @@ static void rdiff_show_version(void)
"You may redistribute copies of librsync under the terms of the GNU\n"
"Lesser General Public License. For more information about these\n"
"matters, see the files named COPYING.\n",
- rs_librsync_version, RS_CANONICAL_HOST,
+ rs_version(),
(long) (8 * sizeof(rs_long_t)), zlib, bzlib, trace);
}
@@ -199,8 +199,6 @@ static void rdiff_options(poptContext opcon)
int c;
char const *a;
- rs_hello();
-
while ((c = poptGetNextOpt(opcon)) != -1) {
switch (c) {
case 'h':