X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=util.cc;h=b595eea602f1f11f9e76958afd5efe4a04501c85;hb=cb7620ebf655e86cfe8000bf0bac9269394b652e;hp=c1b5f41697b91e5d0ddd2e3edf81301f9fd84d0e;hpb=87c6a5ed4ec515c2e154f98529c1d2f077d2a7e4;p=cumulus.git diff --git a/util.cc b/util.cc index c1b5f41..b595eea 100644 --- a/util.cc +++ b/util.cc @@ -1,11 +1,28 @@ -/* LBS: An LFS-inspired filesystem backup system - * Copyright (C) 2007 Michael Vrable +/* Cumulus: Smart Filesystem Backup to Dumb Servers * - * Utility functions for converting various datatypes to text format (and - * later, for parsing them back, perhaps). + * Copyright (C) 2007 The Regents of the University of California + * Written by Michael Vrable + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +/* Utility functions for converting various datatypes to text format (and + * later, for parsing them back, perhaps). */ + #include +#include #include #include @@ -27,7 +44,7 @@ string uri_encode(const string &in) for (size_t i = 0; i < in.length(); i++) { unsigned char c = in[i]; - if (c >= '+' && c < 0x7f) { + if (c >= '+' && c < 0x7f && c != '@') { out += c; } else { char buf[4]; @@ -67,7 +84,7 @@ string uri_decode(const string &in) *output = '\0'; string result(buf); - delete buf; + delete[] buf; return result; } @@ -98,13 +115,3 @@ long long parse_int(const string &s) { return strtoll(s.c_str(), NULL, 0); } - -/* Output a dictionary of string key/value pairs to the given output stream. - * The format is a sequence of lines of the form "key: value". */ -void dict_output(ostream &o, map dict) -{ - for (map::const_iterator i = dict.begin(); - i != dict.end(); ++i) { - o << i->first << ": " << i->second << "\n"; - } -}