X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fbin%2Fmemcp.cc;h=0087b536b4673da231808e076f6f12f92e7b16e6;hb=92d18858b417309f6bdee6bce464a4f3d6a375fd;hp=114a2f8562328250e8822c12ab398a5a39d95cba;hpb=f2d0ed355899d265edbcc7156dace706df2f160a;p=awesomized%2Flibmemcached diff --git a/src/bin/memcp.cc b/src/bin/memcp.cc index 114a2f85..0087b536 100644 --- a/src/bin/memcp.cc +++ b/src/bin/memcp.cc @@ -1,6 +1,6 @@ /* +--------------------------------------------------------------------+ - | libmemcached - C/C++ Client Library for memcached | + | libmemcached-awesome - C/C++ Client Library for memcached | +--------------------------------------------------------------------+ | Redistribution and use in source and binary forms, with or without | | modification, are permitted under the terms of the BSD license. | @@ -9,7 +9,7 @@ | the terms online at: https://opensource.org/licenses/BSD-3-Clause | +--------------------------------------------------------------------+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ | - | Copyright (c) 2020 Michael Wallner | + | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ | +--------------------------------------------------------------------+ */ @@ -21,14 +21,23 @@ #include "common/options.hpp" #include "common/checks.hpp" +#include "p9y/libgen.hpp" +#include "p9y/realpath.hpp" #include #include #include -#include #include #include +#ifndef PATH_MAX +# ifdef MAX_PATH +# define PATH_MAX MAX_PATH +# else +# define PATH_MAX 256 +# endif +#endif + struct memcp_file { enum class type { basename, @@ -46,7 +55,7 @@ struct memcp_file { }; static inline std::string stream2string(const std::istream &istream) { - return dynamic_cast(std::ostringstream{} << istream.rdbuf()).str(); + return dynamic_cast(std::ostringstream{} << istream.rdbuf()).str(); } static memcached_return_t memcp(const client_options &opt, memcached_st &memc, const char *key, @@ -130,7 +139,7 @@ static bool path2key(const client_options &opt, memcp_file &file, char **path) { } else if (file.key == memcp_file::type::relative) { *path = file.path; } else { - *path = basename((file.path)); + *path = basename(file.path); } return true; } @@ -140,7 +149,7 @@ int main(int argc, char *argv[]) { client_options opt{PROGRAM_NAME, PROGRAM_VERSION, PROGRAM_DESCRIPTION, "file [file ...]" "\n\t\t\t# NOTE: order of flags and positional" - "\n\t\t\t# arguments matters on GNU systems)"}; + "\n\t\t\t# arguments matters on GNU systems"}; opt.add(nullptr, '-', no_argument, "GNU argv extension") .parse = [&files](client_options &opt_, client_options::extended_option &ext) {