epicsShareFunc double epicsStrtod(const char *str, char **endp) { const char *cp = str; int negative = 0; double res; while (isspace((int)*cp)) cp++; if (*cp == '+') { cp++; } else if (*cp == '-') { negative = 1; cp++; } if (epicsStrnCaseCmp("0x", cp, 2) == 0) { if (negative) return strtol(str, endp, 16); else return strtoul(str, endp, 16); } if (!isalpha((int)*cp)) { res = strtod(str, endp); if (isinf(res)) errno = ERANGE; return res; } if (epicsStrnCaseCmp("NAN", cp, 3) == 0) { res = epicsNAN; cp += 3; if (*cp == '(') { cp++; while (*cp && (*cp++ != ')')) continue; } } else if (epicsStrnCaseCmp("INF", cp, 3) == 0) { res = negative ? -epicsINF : epicsINF; cp += 3; if (epicsStrnCaseCmp("INITY", cp, 5) == 0) { cp += 5; } } else { cp = str; res = 0; } if (endp) *endp = (char *)cp; return res; }
/* get_element * * find the next expression element in the infix expression */ static int get_element(int opnd, const char **ppsrc, const ELEMENT **ppel) { const ELEMENT *ptable, *pel; *ppel = NULL; while (isspace((int) (unsigned char) **ppsrc)) ++*ppsrc; if (**ppsrc == '\0') return FALSE; if (opnd) { ptable = operands; pel = ptable + NELEMENTS(operands) - 1; } else { ptable = operators; pel = ptable + NELEMENTS(operators) - 1; } while (pel >= ptable) { size_t len = strlen(pel->name); if (epicsStrnCaseCmp(*ppsrc, pel->name, len) == 0) { *ppel = pel; *ppsrc += len; return TRUE; } --pel; } return FALSE; }
/** Decide whether or not this frame is intended to be processed by this plugin. * By default all frames are processed. The decision not to process a frame is * made based on the string value of the FILEPLUGIN_DESTINATION: if the value does not equal * either "all" or the ASYN port name of the current plugin the frame is not to be processed. * \param[in] pAttrList A pointer to the current NDArray's attribute list. * \returns true if the frame is to be processed. false if the frame is not to be processed. */ bool NDPluginFile::attrIsProcessingRequired(NDAttributeList* pAttrList) { char destPortName[MAX_FILENAME_LEN]; NDAttribute *ndAttr; size_t destPortNameLen; NDAttrDataType_t attrDataType; ndAttr = pAttrList->find(FILEPLUGIN_DESTINATION); if (ndAttr != NULL) { ndAttr->getValueInfo(&attrDataType, &destPortNameLen); if (attrDataType == NDAttrString && destPortNameLen > 1) { if (destPortNameLen > MAX_FILENAME_LEN) destPortNameLen = MAX_FILENAME_LEN; ndAttr->getValue(NDAttrString, destPortName, destPortNameLen); if (epicsStrnCaseCmp(destPortName, "all", destPortNameLen>3?3:destPortNameLen) != 0 && epicsStrnCaseCmp(destPortName, this->portName, destPortNameLen) != 0) return false; } } return true; }
/** Check whether the attributes defining the filename has changed since last write. * If this is the first frame (NDFileNumCaptured == 1) then the file is opened. * For other frames we check whether the attribute file name or number has changed * since last write. If this is the case then the current file is closed a new one opened. */ asynStatus NDPluginFile::attrFileNameCheck() { asynStatus status = asynSuccess; NDAttribute *NDattrFileName, *NDattrFileNumber; int compare, attrFileNumber, ndFileNumber; char attrFileName[MAX_FILENAME_LEN]; char ndFileName[MAX_FILENAME_LEN]; int numCapture, numCaptured; bool reopenFile = false; if (!this->useAttrFilePrefix) return status; getIntegerParam(NDFileNumCapture, &numCapture); getIntegerParam(NDFileNumCaptured, &numCaptured); if (numCaptured == 1) { status = this->openFileBase(NDFileModeWrite | NDFileModeMultiple, this->pArrays[0]); return status; } NDattrFileName = this->pArrays[0]->pAttributeList->find(FILEPLUGIN_NAME); if (NDattrFileName != NULL) { NDattrFileName->getValue(NDAttrString, attrFileName, MAX_FILENAME_LEN); getStringParam(NDFileName, MAX_FILENAME_LEN, ndFileName); compare = epicsStrnCaseCmp(attrFileName, ndFileName, strlen(attrFileName)); if (compare != 0) reopenFile = true; } NDattrFileNumber = this->pArrays[0]->pAttributeList->find(FILEPLUGIN_NUMBER); if (NDattrFileNumber != NULL) { NDattrFileNumber->getValue(NDAttrInt32, (void*) &attrFileNumber, 0); getIntegerParam(NDFileNumber, &ndFileNumber); if (ndFileNumber != attrFileNumber) { reopenFile = true; setIntegerParam( NDFileNumber, attrFileNumber); } } asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "attrFileNameCheck: name=%s(%s) num=%d (%s) reopen=%d\n", attrFileName, ndFileName, attrFileNumber, NDattrFileNumber->getSource(), (int)reopenFile ); if (reopenFile) { this->closeFileBase(); setIntegerParam(NDFileNumCaptured, 1); status = this->openFileBase(NDFileModeWrite | NDFileModeMultiple, this->pArrays[0]); } return status; }