#ifndef PQ_UTIL_H #define PQ_UTIL_H /* ========================================================================== ** * util.h * * Copyright: * Copyright (C) 2010 by Christopher R. Hertel * * Email: crh@ubiqx.com * * $Id: util.h 14 2011-05-30 03:32:32Z crh $ * * -------------------------------------------------------------------------- ** * * Description: * Utility functions for use with the Prequel Distributed Cache server. * * -------------------------------------------------------------------------- ** * * License: * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * -------------------------------------------------------------------------- ** * * Notes: * * ========================================================================== ** */ #include /* For printf(3), et al. */ /* -------------------------------------------------------------------------- ** * Macros: * * Say() - This is a conceited little macro that simply replaces * printf(3) with something shorter and easier to type. * The printf(3) function returns the number of bytes * written, but most coders ignore the return value and * many don't even know that there is a return value. * The Say() macro simply discards the return value. */ #define Say (void)printf /* -------------------------------------------------------------------------- ** * Functions: */ void Fail( char *fmt, ... ); /* ------------------------------------------------------------------------ ** * Format and print a failure message on , then exit the process. * * Input: fmt - Format string, as used in printf(), etc. * ... - Variable parameter list. * * Output: * * ------------------------------------------------------------------------ ** */ void Err( char *fmt, ... ); /* ------------------------------------------------------------------------ ** * Format and print a message on , then return. * * Input: fmt - Format string, as used in printf(), etc. * ... - Variable parameter list. * * Output: * * ------------------------------------------------------------------------ ** */ int GetTcpPortNo( const char *pname ); /* ------------------------------------------------------------------------ ** * Use the input string to look up an entry in /etc/services. * * Input: pname - A string containing either a port number (as a string * of decimal numerals) or port name. * * Output: The actual port number, or -1 on error. * * Notes: This function returns only TCP port assigments. * * This function is a wrapper around getservbyname(3). Note, * however, that if the input string is a decimal numeric * string that represents a valid port number, this function * will return that number. For example, if "1392" is passed * in, and there is no matching entry in the /etc/services * file, this function will still return the value 1392. * * ------------------------------------------------------------------------ ** */ /* ========================================================================== */ #endif /* PW_UTIL_H */