From 4206d9754486d2c1e18217cbcdbaad8f31f5244b Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Thu, 8 May 2008 11:23:38 +0200 Subject: net: more whitespace cleanup (This used to be commit ef0184d580500734fc7af51e1c790b075180a3d0) --- source3/utils/net_cache.c | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'source3/utils/net_cache.c') diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c index e59a534e4a..091d8f2e55 100644 --- a/source3/utils/net_cache.c +++ b/source3/utils/net_cache.c @@ -1,18 +1,18 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility Copyright (C) Rafal Szczesniak 2002 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 3 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, see . */ @@ -57,11 +57,11 @@ static void print_cache_entry(const char* keystr, const char* datastr, if (timeout_tm.tm_year != now_tm->tm_year || timeout_tm.tm_mon != now_tm->tm_mon || timeout_tm.tm_mday != now_tm->tm_mday) { - + timeout_str = asctime(&timeout_tm); if (!timeout_str) { return; - } + } timeout_str[strlen(timeout_str) - 1] = '\0'; /* remove tailing CR */ } else { asprintf(&alloc_str, "%.2d:%.2d:%.2d", timeout_tm.tm_hour, @@ -71,7 +71,7 @@ static void print_cache_entry(const char* keystr, const char* datastr, } timeout_str = alloc_str; } - + d_printf("Key: %s\t Timeout: %s\t Value: %s %s\n", keystr, timeout_str, datastr, timeout > now_t ? "": "(expired)"); @@ -105,7 +105,7 @@ static time_t parse_timeout(const char* timeout_str) } else { number_begin = 0; } - + /* unit detection */ len = strlen(timeout_str); switch (timeout_str[len - 1]) { @@ -115,12 +115,12 @@ static time_t parse_timeout(const char* timeout_str) case 'd': case 'w': unit = timeout_str[len - 1]; } - + /* number detection */ len = (sign) ? strlen(&timeout_str[number_begin]) : len; number_end = (unit) ? len - 1 : len; number = SMB_STRNDUP(&timeout_str[number_begin], number_end); - + /* calculate actual timeout value */ timeout = (time_t)atoi(number); @@ -130,21 +130,21 @@ static time_t parse_timeout(const char* timeout_str) case 'd': timeout *= 60*60*24; break; case 'w': timeout *= 60*60*24*7; break; /* that's fair enough, I think :) */ } - + switch (sign) { case '!': timeout = time(NULL) - timeout; break; case '+': default: timeout += time(NULL); break; } - + if (number) SAFE_FREE(number); - return timeout; + return timeout; } /** * Add an entry to the cache. If it does exist, then set it. - * + * * @param c A net_context structure * @param argv key, value and timeout are passed in command line * @return 0 on success, otherwise failure @@ -153,29 +153,29 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) { const char *keystr, *datastr, *timeout_str; time_t timeout; - + if (argc < 3) { d_printf("\nUsage: net cache add \n"); return -1; } - + keystr = argv[0]; datastr = argv[1]; timeout_str = argv[2]; - + /* parse timeout given in command line */ timeout = parse_timeout(timeout_str); if (!timeout) { d_fprintf(stderr, "Invalid timeout argument.\n"); return -1; } - + if (gencache_set(keystr, datastr, timeout)) { d_printf("New cache entry stored successfully.\n"); gencache_shutdown(); return 0; } - + d_fprintf(stderr, "Entry couldn't be added. Perhaps there's already such a key.\n"); gencache_shutdown(); return -1; @@ -183,7 +183,7 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) /** * Delete an entry in the cache - * + * * @param c A net_context structure * @param argv key to delete an entry of * @return 0 on success, otherwise failure @@ -191,12 +191,12 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) static int net_cache_del(struct net_context *c, int argc, const char **argv) { const char *keystr = argv[0]; - + if (argc < 1) { d_printf("\nUsage: net cache del \n"); return -1; } - + if(gencache_del(keystr)) { d_printf("Entry deleted.\n"); return 0; @@ -209,7 +209,7 @@ static int net_cache_del(struct net_context *c, int argc, const char **argv) /** * Get and display an entry from the cache - * + * * @param c A net_context structure * @param argv key to search an entry of * @return 0 on success, otherwise failure @@ -224,7 +224,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) d_printf("\nUsage: net cache get \n"); return -1; } - + if (gencache_get(keystr, &valuestr, &timeout)) { print_cache_entry(keystr, valuestr, timeout, NULL); return 0; @@ -237,7 +237,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) /** * Search an entry/entries in the cache - * + * * @param c A net_context structure * @param argv key pattern to match the entries to * @return 0 on success, otherwise failure @@ -245,12 +245,12 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) static int net_cache_search(struct net_context *c, int argc, const char **argv) { const char* pattern; - + if (argc < 1) { d_printf("Usage: net cache search \n"); return -1; } - + pattern = argv[0]; gencache_iterate(print_cache_entry, NULL, pattern); return 0; @@ -259,7 +259,7 @@ static int net_cache_search(struct net_context *c, int argc, const char **argv) /** * List the contents of the cache - * + * * @param c A net_context structure * @param argv ignored in this functionailty * @return always returns 0 @@ -275,7 +275,7 @@ static int net_cache_list(struct net_context *c, int argc, const char **argv) /** * Flush the whole cache - * + * * @param c A net_context structure * @param argv ignored in this functionality * @return always returns 0 -- cgit