📄 fwwebhttprpmwmbpost.c
字号:
sbyte * pVal; sbyte * pInst; sbyte * pStrTokState; sbyte * pArgMagicMarkup; sbyte4 instLen; void * pBuffer; sbyte * tempBuf; sbyte4 written; WMB_OBJ_T obj; HTTP_GEN_LIST_ENTRY_ID lstEntry; static char sUnchecked[] = "OFF"; sbyte inlineMark[kMagicMarkupBufferSize + 1]; /* should be max instance length ??*/ if (NULL == reqId || NULL == reqId->argListId) return wmError (ERROR_GENERAL_NULL_POINTER, errFmt); lstEntry = httpGenListFind (reqId->argListId, "END_OF_HEADERS"); if (lstEntry == NULL) return wmError(0, errFmt); /* * We use the memory pool associated with this HTTP request because * it should be more efficient than a general malloc(). */ tempBuf = memPoolAlloc(reqId->memPool,httpMaxTempBufSize); if (tempBuf == NULL) return wmError(0, errFmt); /* Even if this next allocation fails, it is safe to proceed. */ pBuffer = (pGetSession) ? memPoolAlloc(reqId->memPool, wmVarMagicMarkupBufferSize) : NULL; while (httpGenListIterator(reqId->argListId, &lstEntry) != NULL) { pMagicMarkup = httpGenListIdGet (lstEntry); /* * tempBuf has sufficient size and pMagicMarkup does point to * a null terminated string */ STRCPY (tempBuf, pMagicMarkup); /* Check for braces */ if (NULL != (pInst = strstr(tempBuf,"{["))) { /* expand the instances */ httpExpandInstance (pSession, pInst, inlineMark); if (inlineMark[0] == '\0') return (wmError (ERROR_GENERAL, errFmt)); tempBuf[(pInst - tempBuf) - 1] = '\0'; } else if (NULL != (pInst = strstr(tempBuf,"{("))) { /* expand the instances */ httpExpandInstance (pSession, pInst, inlineMark); if (inlineMark[0] == '\0') return (wmError (ERROR_GENERAL, errFmt)); tempBuf[(pInst - tempBuf) - 1] = '\0'; } else { /* look for instance information (dotted OID suffix or parenthesis) */ pInst = lclParseInstanceInfo (tempBuf); STRCPY(inlineMark, (NULL != pInst) ? pInst : ""); } instLen = strlen(inlineMark) + 1; /* * Deal with the only special WindMark: the checkbox manager. * Arguments of this "Windmark" are a list of all the checkboxes * in the form. We use this list to determine which boxes are * not checked. */ if (0 == strcmp(tempBuf, "CheckBoxManager")) { pArgMagicMarkup = httpGetEnv (reqId, pMagicMarkup); /* * Parse comma delimited list of checkboxes. This is a * destructive parse which renders the list unusable. */ for (pArgMagicMarkup = STRTOK_REENTRANT(pArgMagicMarkup, ",",&pStrTokState); pArgMagicMarkup != NULL; pArgMagicMarkup = STRTOK_REENTRANT(NULL, ",", &pStrTokState) ) { if (NULL == httpGetEnv (reqId, pArgMagicMarkup)) { /* * If pArgMagicMarkup is not found in the environment * (CGI stream), set it to "OFF". We may not do this * if it is already "OFF". */ if (pBuffer) /* set only if value will change */ { if (wmbDataStringGet(pGetSession,pArgMagicMarkup, inlineMark,instLen, pBuffer,wmVarMagicMarkupBufferSize, &written) == OK) { if (strcmp(pBuffer,sUnchecked) == 0) continue; } } if ((OK != wmbObjectCreate(tid, pArgMagicMarkup, inlineMark, instLen, &obj)) || (OK != wmbObjectValueCreate(obj, sUnchecked, sizeof(sUnchecked), DATATYPE_STRING_K, TRUE))) { httpWindMarkSetFailed(reqId, pArgMagicMarkup, errno); } } } } else if (wmbDataExists(pSession, tempBuf)) { pVal = httpGetEnv(reqId, pMagicMarkup); /* * Create object (memory representation of a WindMark) * that will be added to transaction list. The object * might not be created if its value would not change. */ if (pBuffer) /* set only if value will change */ { if (wmbDataStringGet(pGetSession,tempBuf,inlineMark, instLen, pBuffer,wmVarMagicMarkupBufferSize, &written) == OK) { /* * Unfortunately, "written" is not necessarily the * size of the string returned, so we do a strcmp(). */ if (strcmp(pBuffer,pVal) == 0) continue; } } if ((OK != wmbObjectCreate(tid, tempBuf, inlineMark, instLen, &obj)) || (OK != wmbObjectValueCreate(obj,pVal,strlen(pVal) + 1, DATATYPE_STRING_K,TRUE))) { httpWindMarkSetFailed(reqId, pMagicMarkup, errno); } } else /* WindMark does not exist in wmb */ { httpWindMarkSetFailed(reqId, pMagicMarkup, errno); } } /* while */ /* * We don't really have to free stuff here because it will be * freed when the request is ended, but it is not a good idea * to let garbage accumulate. */ memPoolFree(reqId->memPool,tempBuf); if (pBuffer) memPoolFree(reqId->memPool,pBuffer); return OK; } /* lclBuildSetTrans *//**************************************************************************** lclReportError - return RPM_ERROR and display error message** This is an error reporting function used by the local RPMs. <errno>* should have already been set when we get here, so we pass a zero* to wmError() which won't change <errno>.** RETURNS: RPM_ERROR*/LOCAL short lclReportError() { logErrorMsg (errFmt,errnoGet()); wmError (0, errFmt); return RPM_ERROR; }/**************************************************************************** lclParseInstanceInfo - look for instance information in a posted WindMark** This function looks for instance information in a posted WindMark. Currently* there are two types of instance data supported: a dotted OID following the* WindMarks' name (such as ifPhysAddr.2.3.1), and a string delimited by* parenthesis (such as myFormat(1.12x)). On the first example, the instance* data is considered to be the string "2.3.1" and in the second, "1.12x".** This function takes a pointer to the full WindMark name as its first parameter,* parses it for either type of instance information, and if found, a pointer* to it will be returned.** All processing is done "in place" so no new memory is allocated.**.NOMANUAL*/LOCAL sbyte * lclParseInstanceInfo ( sbyte * fullWindMarkName ) { sbyte * pInst; sbyte * pStrTokState = NULL; /* look for a dot or an opening parens */ STRTOK_REENTRANT (fullWindMarkName, ".(", &pStrTokState); pInst = pStrTokState; /* look for closing parens - don't care for result, just to overwrite it */ pStrTokState = STRTOK_REENTRANT (NULL, ")", &pStrTokState); return pInst; }#if 0/**************************************************************************** lclDumpTrans - print transaction info for debugging** RETURNS:*/LOCAL void lclDumpTrans ( WMB_TID_T tid, char * title ) { WMB_OBJ_T obj; sbyte4 written; sbyte * pName; STATUS s; static sbyte temp[512]; if (title) printf("-------- %s --------\r\n",title); obj = wmbTransactionHeadGet (tid); while (! wmbObjectBad(obj)) { temp[0] = '\0'; pName = wmbObjectNameGet (obj); s = wmbObjectExport(obj,temp,sizeof(temp),DATATYPE_STRING_K,&written); if (s == OK) { printf("%s [%d bytes] = %s\r\n", pName, written, temp); } else { printf("%s [ERROR]\r\n", pName); } obj = wmbObjectListNextGet (obj); }#if 0 wmOidPrint(table->rowOidSfx, "instance");#endif return ; }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -