From 8133681a483b84647b92bf0d4dbbf899c4ab1495 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 24 Sep 2002 17:51:09 +0000 Subject: [PATCH] fixed formatting and sun pro warning --- src/cas/example/directoryService/main.cc | 276 ++++++++++++----------- 1 file changed, 139 insertions(+), 137 deletions(-) diff --git a/src/cas/example/directoryService/main.cc b/src/cas/example/directoryService/main.cc index 788657ac5..4eda59e5b 100644 --- a/src/cas/example/directoryService/main.cc +++ b/src/cas/example/directoryService/main.cc @@ -32,78 +32,78 @@ LOCAL int parseDirectoryFP (FILE *pf, const char *pFileName); // extern int main (int argc, const char **argv) { - epicsTime begin(epicsTime::getCurrent()); - directoryServer *pCAS; - unsigned debugLevel = 0u; - double executionTime; - char pvPrefix[128] = ""; - char fileName[128] = "pvDirectory.txt"; - unsigned aliasCount = 0u; - bool forever = true; - int nPV; - int i; + epicsTime begin(epicsTime::getCurrent()); + directoryServer *pCAS; + unsigned debugLevel = 0u; + double executionTime; + char pvPrefix[128] = ""; + char fileName[128] = "pvDirectory.txt"; + unsigned aliasCount = 0u; + bool forever = true; + int nPV; + int i; - for (i=1; i -t -p -c -f]\n", - argv[0]); + argv[0]); - return (1); - } + return (1); + } - nPV = parseDirectoryFile (fileName); - if (nPV<=0) { - fprintf(stderr, + nPV = parseDirectoryFile (fileName); + if (nPV<=0) { + fprintf(stderr, "No PVs in directory file=%s. Exiting because there is no useful work to do.\n", - fileName); - return (-1); - } + fileName); + return (-1); + } - pCAS = new directoryServer(pvPrefix, aliasCount); - if (!pCAS) { - return (-1); - } + pCAS = new directoryServer(pvPrefix, aliasCount); + if (!pCAS) { + return (-1); + } - pCAS->setDebugLevel(debugLevel); + pCAS->setDebugLevel(debugLevel); - if (forever) { - // - // loop here forever - // - while (true) { - fileDescriptorManager.process (1000.0); - } - } - else { - double delay = epicsTime::getCurrent() - begin; - // - // loop here untime the specified execution time - // expires - // - while (delay < executionTime) { - fileDescriptorManager.process (delay); - delay = epicsTime::getCurrent() - begin; - } - } - pCAS->show(2u); - delete pCAS; - return (0); + if (forever) { + // + // loop here forever + // + while (true) { + fileDescriptorManager.process (1000.0); + } + } + else { + double delay = epicsTime::getCurrent() - begin; + // + // loop here untime the specified execution time + // expires + // + while (delay < executionTime) { + fileDescriptorManager.process (delay); + delay = epicsTime::getCurrent() - begin; + } + } + pCAS->show(2u); + delete pCAS; + return (0); } // @@ -116,24 +116,24 @@ extern int main (int argc, const char **argv) LOCAL int parseDirectoryFile (const char *pFileName) { - FILE *pf; - int nPV; + FILE *pf; + int nPV; - // - // open a file that contains the PV directory - // - pf = fopen(pFileName, "r"); - if (!pf) { - fprintf(stderr, "Directory file access probems with file=\"%s\" because \"%s\"\n", - pFileName, strerror(errno)); - return (-1); - } + // + // open a file that contains the PV directory + // + pf = fopen(pFileName, "r"); + if (!pf) { + fprintf(stderr, "Directory file access probems with file=\"%s\" because \"%s\"\n", + pFileName, strerror(errno)); + return (-1); + } - nPV = parseDirectoryFP (pf, pFileName); - - fclose (pf); + nPV = parseDirectoryFP (pf, pFileName); + + fclose (pf); - return nPV; + return nPV; } // @@ -145,65 +145,67 @@ LOCAL int parseDirectoryFile (const char *pFileName) // LOCAL int parseDirectoryFP (FILE *pf, const char *pFileName) { - pvInfo *pPVI; - char pvNameStr[128]; - struct sockaddr_in ipa; - char hostNameStr[128]; - int nPV=0; - - ipa.sin_family = AF_INET; - while (TRUE) { - - // - // parse the PV name entry from the file - // - if (fscanf(pf, " %127s ", pvNameStr) != 1) { - return nPV; // success - } + pvInfo *pPVI; + char pvNameStr[128]; + struct sockaddr_in ipa; + char hostNameStr[128]; + int nPV=0; + + ipa.sin_family = AF_INET; + while (TRUE) { + + // + // parse the PV name entry from the file + // + if (fscanf(pf, " %127s ", pvNameStr) != 1) { + return nPV; // success + } - // - // parse out server address - // - if (fscanf(pf, " %s ", hostNameStr) == 1) { - int status; + // + // parse out server address + // + if (fscanf(pf, " %s ", hostNameStr) == 1) { + int status; - status = aToIPAddr (hostNameStr, 0u, &ipa); - if (status) { - fprintf (pf, "Unknown host name=\"%s\" (or bad dotted ip addr) in \"%s\" with PV=\"%s\"?\n", - hostNameStr, pFileName, pvNameStr); - return -1; - } - } - else { - fprintf (stderr,"No host name (or dotted ip addr) after PV name in \"%s\" with PV=\"%s\"?\n", - pFileName, pvNameStr); - return -1; - } - - // - // parse out optional IP port number - // - unsigned portNumber; - if (fscanf(pf, " %u ", &portNumber) == 1) { - if (portNumber>0xffff) { - fprintf (stderr,"Port number supplied is to large in \"%s\" with PV=\"%s\" host=\"%s\" port=%u?\n", - pFileName, pvNameStr, hostNameStr, portNumber); - return -1; - } - - ipa.sin_port = htons((aitUint16) portNumber); - } - else { - ipa.sin_port = 0u; // use the default CA server port - } + status = aToIPAddr (hostNameStr, 0u, &ipa); + if (status) { + fprintf (pf, "Unknown host name=\"%s\" (or bad dotted ip addr) in \"%s\" with PV=\"%s\"?\n", + hostNameStr, pFileName, pvNameStr); + return -1; + } + } + else { + fprintf (stderr,"No host name (or dotted ip addr) after PV name in \"%s\" with PV=\"%s\"?\n", + pFileName, pvNameStr); + return -1; + } + + // + // parse out optional IP port number + // + unsigned portNumber; + if (fscanf(pf, " %u ", &portNumber) == 1) { + if (portNumber>0xffff) { + fprintf (stderr,"Port number supplied is to large in \"%s\" with PV=\"%s\" host=\"%s\" port=%u?\n", + pFileName, pvNameStr, hostNameStr, portNumber); + return -1; + } + + ipa.sin_port = htons((aitUint16) portNumber); + } + else { + ipa.sin_port = 0u; // use the default CA server port + } - pPVI = new pvInfo (pvNameStr, ipa); - if (!pPVI) { - fprintf (stderr, "Unable to allocate space for a new PV in \"%s\" with PV=\"%s\" host=\"%s\"\n", - pFileName, pvNameStr, hostNameStr); - return -1; - } - nPV++; - } - return 0; // Make compiler happy + pPVI = new pvInfo (pvNameStr, ipa); + if (!pPVI) { + fprintf (stderr, "Unable to allocate space for a new PV in \"%s\" with PV=\"%s\" host=\"%s\"\n", + pFileName, pvNameStr, hostNameStr); + return -1; + } + nPV++; + } +#if defined ( __HP_aCC ) && ( _HP_aCC <= 033300 ) + return 0; // Make HP compiler happy +#endif }