Make "rename" command an alias for "mv"?
Robert Widhopf-Fenk
hack at robf.de
Thu Oct 27 01:04:02 BST 2005
On Sunday, October 23, 2005 at 20:58:06, John A Meinel wrote:
[...]
> Well, I wrote a plugin called "bzr service" which spawns an instance
> which communicates over a socket.
Below are some fixes to get it working on my x86 Debian.
You must be running on big endian!?
The HTON_4(x) macro should use bitwise-or not bitwise-and
to flip the byte order, but why bother with this if there
are ?standard? functions ;-)
So now bzr feels much faster. BTW in your other email you
said this avoids loading the python interpreter each time,
but hg is much faster here, so mayby it is not loading the
interpreter but loading bzrlib and plugins?
It is nice to got rid of the noticeable startup delay ;-)
~/<1>plugins/service > time hg help > /dev/null
0.098u 0.012s 0:00.10 100.0% 0+0k 0+0io 0pf+0w
~/<1>plugins/service > time bzr help > /dev/null
0.288u 0.037s 0:00.32 96.8% 0+0k 0+0io 0pf+0w
~/<1>plugins/service > time ./client help > /dev/null
0.000u 0.001s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
~/<1>plugins/service > time bzr diff > /dev/null
0.296u 0.046s 0:00.34 97.0% 0+0k 0+0io 0pf+0w
~/<1>plugins/service > time ./client diff > /dev/null
0.000u 0.001s 0:00.04 0.0% 0+0k 0+0io 0pf+0w
Robert.
=== modified file 'client.c'
--- client.c
+++ client.c
@@ -10,19 +10,11 @@
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <unistd.h>
-
-#ifdef __BIG_ENDIAN__
-#define HTON_4(x) x
-#else
-#define HTON_4(x) ((((x) & 0x000000FF) << 24) \
- & (((x) & 0x0000FF00) << 8) \
- & (((x) & 0x00FF0000) >> 8) \
- & (((x) & 0xFF000000) >> 24))
-#endif
-#define NTOH_4 HTON_4
/* We need a 4-byte word here.
* size_t is probably 8-bytes on 64-bit platforms
@@ -41,7 +33,7 @@
/* Failure */
return 0;
}
- *local = NTOH_4(big_endian);
+ *local = ntohl(big_endian);
return 1;
}
@@ -50,7 +42,7 @@
{
uint32 big_endian = 0;
- big_endian = HTON_4(local);
+ big_endian = htonl(local);
write(sock, &big_endian, 4);
}
@@ -104,11 +96,11 @@
char *str = 0;
addr.sin_family = AF_INET;
- addr.sin_port = 11111;
- addr.sin_addr.s_addr = 0x7F000001; /* 127.0.0.1 */
+ addr.sin_port = htons(11111);
+ addr.sin_addr.s_addr = inet_addr("127.0.0.1");
getcwd(cur_path, 8192);
-
+
sock = socket(PF_INET, SOCK_STREAM, 0);
if (sock < 0) {
perror("Failed to create socket.");
@@ -118,19 +110,20 @@
err = connect(sock, (struct sockaddr*)&addr, sizeof(addr));
if (err != 0) {
- perror("Failed to connect to localhost");
+ perror("Failed to connect to localhost.");
retcode = 2;
goto quit;
}
write_str(sock, cur_path);
+
write_uint(sock, argc - 1);
for (i = 1; i < argc; ++i) {
write_str(sock, argv[i]);
}
if (!read_uint(sock, &retcode)) {
- fprintf(stderr, "We failed to read the return code.");
+ fprintf(stderr, "We failed to read the return code.\n");
retcode = 3;
goto quit;
}
More information about the bazaar
mailing list