else
{
if (opt_verbose)
++ {
printf("key: %s\nflags: %x\nlength: %zu\nvalue: ",
argv[optind], flags, string_length);
- printf("%.*s\n", (int)string_length, string);
- if (opt_file) {
- FILE *fp;
- size_t written = 0;
-
- fp = fopen(opt_file, "w");
- if (!fp) {
- perror("fopen");
- return_code= -1;
- break;
- }
-
- written = fwrite(string, 1, string_length, fp);
- if (written != string_length) {
- fprintf(stderr, "error writing file (written %d, should be %d)\n", written, string_length);
- return_code= -1;
- break;
- }
-
- if (fclose(fp)) {
- fprintf(stderr, "error closing file\n");
- return_code= -1;
- break;
- }
+ }
- else {
++
++ if (opt_file)
++ {
++ FILE *fp;
++ size_t written;
++
++ fp= fopen(opt_file, "w");
++ if (!fp)
++ {
++ perror("fopen");
++ return_code= -1;
++ break;
++ }
++
++ written= fwrite(string, 1, string_length, fp);
++ if (written != string_length)
++ {
++ fprintf(stderr, "error writing file (written %zu, should be %zu)\n", written, string_length);
++ return_code= -1;
++ break;
++ }
++
++ if (fclose(fp))
++ {
++ fprintf(stderr, "error closing file\n");
++ return_code= -1;
++ break;
++ }
++ }
++ else
++ {
+ printf("%.*s\n", (int)string_length, string);
+ }
free(string);
}
}
fprintf(stderr, "memcat: %s: memcache error %s",
argv[optind], memcached_strerror(memc, rc));
if (memc->cached_errno)
++ {
fprintf(stderr, " system error %s", strerror(memc->cached_errno));
++ }
fprintf(stderr, "\n");
return_code= -1;
test-memcat: clients/memcat clients/memcp
@echo "Testing memcat"
@@MEMC_BINARY@ -d -P `pwd`/tests/Xumemc.pid -p 12555
-- @clients/memcp --servers="localhost:12555" clients/memcp
-- @clients/memcat --servers="localhost:12555" memcp > tests/scratch
++ @clients/memcp --servers="localhost:12555" `pwd`/clients/memcp
++ @clients/memcat --servers="localhost:12555" memcp > `pwd`/tests/scratch
++ @clients/memcat --servers="localhost:12555" --file=`pwd`/tests/scratch2 memcp
# @diff clients/memcp tests/scratch
-- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
-- @rm tests/Xumemc.pid
-- @rm tests/scratch
++ @cat `pwd`/tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
++ @rm `pwd`/tests/Xumemc.pid
++ @rm `pwd`/tests/scratch
++ @rm `pwd`/tests/scratch2
valgrind-memcat: clients/memcat clients/memcp
@echo "Testing memcat"