Commit 65919188 authored by Steven Murray's avatar Steven Murray
Browse files

Finished moving castor::tape::aggregator::utils to castor::tape::utils.

parent e18ed86a
/******************************************************************************
* Constants.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
*
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_CONSTANTS_HPP
#define CASTOR_TAPE_CONSTANTS_HPP 1
#include <stdint.h>
#include <stdlib.h>
namespace castor {
namespace tape {
const size_t STRERRORBUFLEN = 256;
} // namespace tape
} // namespace castor
#endif // CASTOR_TAPE_CONSTANTS_HPP
......@@ -25,6 +25,7 @@
#include "castor/dlf/Dlf.hpp"
#include "castor/exception/Internal.hpp"
#include "castor/tape/Constants.hpp"
#include "castor/tape/aggregator/AggregatorDlfMessageConstants.hpp"
#include "castor/tape/aggregator/BridgeProtocolEngine.hpp"
#include "castor/tape/aggregator/Constants.hpp"
......
......@@ -34,19 +34,18 @@ namespace castor {
namespace tape {
namespace aggregator {
const size_t HDRBUFSIZ = 3 * sizeof(uint32_t);
const size_t HOSTNAMEBUFLEN = 256;
const int LISTENBACKLOG = 2;
const int MAXINITMIGFILES = 2;
const uint32_t MIGRATEUMASK = 022;
const size_t MSGBUFSIZ = 1024;
const uint32_t RECALLUMASK = 077;
const char RECORDFORMAT[2] = "F";
const int RTCPDNETRWTIMEOUT = 5;
const int RTCPDCALLBACKTIMEOUT = 5;
const int RTCPDPINGTIMEOUT = 10;
const size_t SERVICENAMEBUFLEN = 256;
const size_t STRERRORBUFLEN = 256;
const size_t HDRBUFSIZ = 3 * sizeof(uint32_t);
const size_t HOSTNAMEBUFLEN = 256;
const int LISTENBACKLOG = 2;
const int MAXINITMIGFILES = 2;
const uint32_t MIGRATEUMASK = 022;
const size_t MSGBUFSIZ = 1024;
const uint32_t RECALLUMASK = 077;
const char RECORDFORMAT[2] = "F";
const int RTCPDNETRWTIMEOUT = 5;
const int RTCPDCALLBACKTIMEOUT = 5;
const int RTCPDPINGTIMEOUT = 10;
const size_t SERVICENAMEBUFLEN = 256;
} // namespace aggregator
} // namespace tape
......
......@@ -24,7 +24,7 @@
*****************************************************************************/
#include "castor/exception/Internal.hpp"
#include "castor/tape/aggregator/Constants.hpp"
#include "castor/tape/Constants.hpp"
#include "castor/tape/utils/utils.hpp"
#include "h/rtcp_constants.h"
......@@ -38,7 +38,7 @@
//-----------------------------------------------------------------------------
// toHex
//-----------------------------------------------------------------------------
void castor::tape::aggregator::utils::toHex(const uint64_t i, char *dst,
void castor::tape::utils::toHex(const uint64_t i, char *dst,
size_t dstLen) throw(castor::exception::Exception) {
// The largest 64-bit hexadecimal string "FFFFFFFFFFFFFFFF" would ocuppy 17
......@@ -87,7 +87,7 @@ void castor::tape::aggregator::utils::toHex(const uint64_t i, char *dst,
//-----------------------------------------------------------------------------
// copyString
//-----------------------------------------------------------------------------
void castor::tape::aggregator::utils::copyString(char *const dst,
void castor::tape::utils::copyString(char *const dst,
const char *src, const size_t n) throw(castor::exception::Exception) {
const size_t srcLen = strlen(src);
......@@ -110,7 +110,7 @@ void castor::tape::aggregator::utils::copyString(char *const dst,
//-----------------------------------------------------------------------------
// magicToStr
//-----------------------------------------------------------------------------
const char *castor::tape::aggregator::utils::magicToStr(const uint32_t magic)
const char *castor::tape::utils::magicToStr(const uint32_t magic)
throw() {
switch(magic) {
case RTCOPY_MAGIC_VERYOLD: return "RTCOPY_MAGIC_VERYOLD";
......@@ -126,7 +126,7 @@ const char *castor::tape::aggregator::utils::magicToStr(const uint32_t magic)
//-----------------------------------------------------------------------------
// rtcopyReqTypeToStr
//-----------------------------------------------------------------------------
const char *castor::tape::aggregator::utils::rtcopyReqTypeToStr(
const char *castor::tape::utils::rtcopyReqTypeToStr(
const uint32_t reqType) throw() {
switch(reqType) {
case RTCP_TAPE_REQ : return "RTCP_TAPE_REQ";
......@@ -150,7 +150,7 @@ const char *castor::tape::aggregator::utils::rtcopyReqTypeToStr(
//-----------------------------------------------------------------------------
// procStatusToStr
//-----------------------------------------------------------------------------
const char *castor::tape::aggregator::utils::procStatusToStr(
const char *castor::tape::utils::procStatusToStr(
const uint32_t procStatus) throw() {
switch(procStatus) {
case RTCP_WAITING : return "RTCP_WAITING";
......@@ -168,7 +168,7 @@ const char *castor::tape::aggregator::utils::procStatusToStr(
//------------------------------------------------------------------------------
// isValidUInt
//------------------------------------------------------------------------------
bool castor::tape::aggregator::utils::isValidUInt(const char *str)
bool castor::tape::utils::isValidUInt(const char *str)
throw() {
// An empty string is not a valid unsigned integer
if(*str == '\0') {
......@@ -187,10 +187,20 @@ bool castor::tape::aggregator::utils::isValidUInt(const char *str)
}
//------------------------------------------------------------------------------
// toUpper
//------------------------------------------------------------------------------
void castor::tape::utils::toUpper(char *str) {
for(;*str != '\0'; str++) {
*str = toupper(*str);
}
}
//------------------------------------------------------------------------------
// drainFile
//------------------------------------------------------------------------------
ssize_t castor::tape::aggregator::utils::drainFile(const int fd)
ssize_t castor::tape::utils::drainFile(const int fd)
throw(castor::exception::Exception) {
char buf[1024];
......
......@@ -27,6 +27,7 @@
#define CASTOR_TAPE_AGGREGATOR_UTILS_UTILS_HPP 1
#include "castor/exception/Exception.hpp"
#include "castor/tape/Constants.hpp"
#include <errno.h>
#include <stdint.h>
......@@ -75,9 +76,8 @@
namespace castor {
namespace tape {
namespace aggregator {
namespace utils {
namespace tape {
namespace utils {
/**
* Writes the specified unsigned 64-bit integer into the specified
......@@ -177,6 +177,11 @@ namespace utils {
*/
bool isValidUInt(const char *str) throw();
/**
* Converts the specified string to uppercase.
*/
void toUpper(char *str);
/**
* Drains (reads and discards) all data from the specified file until end of
* file is reached.
......@@ -186,7 +191,6 @@ namespace utils {
ssize_t drainFile(const int fd) throw(castor::exception::Exception);
} // namespace utils
} // namespace aggregator
} // namespace tape
} // namespace castor
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment