⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mgrcmddispatcher.c

📁 SyncML手册及其编程
💻 C
📖 第 1 页 / 共 2 页
字号:
 	  // Reset the Workspace (the remaining unparsed document fragment will be lost) 	  mgrResetWorkspace(id);  }   return rc;}/** * FUNCTION:  * Parses the next Sync Command in the sync document. * * IN:              InstanceID *                  current InstanceID to pass to callback functions * * IN:              InstanceInfo *                  state information of the given InstanceID * * RETURN:          Return value of the Parser of the called application callback,             *                  SML_ERR_OK if next command was handled successfully */static Ret_t mgrProcessNextCommand(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo){  /* --- Definitions --- */   Ret_t               rc;                          // Temporary return code saver  SmlProtoElement_t   cmdType;                     // ID of the command to process  VoidPtr_t           pContent=NULL;               // data of the command to process  MemPtr_t            pCurrentReadPosition;        // current Position from which is read  MemPtr_t            pBeginPosition;              // saves the first position which has been reading  MemSize_t           usedSize;                    // size of used memory to be read   Boolean_t           final;                       // flag indicates last message within a package    /* --- Get Read Access to the workspace --- */  rc = smlLockReadBuffer(id, &pCurrentReadPosition, &usedSize);    if (rc!=SML_ERR_OK) {    // abort, unlock the buffer again without changing it's current position    smlUnlockReadBuffer(id, (MemSize_t)0);      return rc;    }  // Remember the position we have started reading  pBeginPosition=pCurrentReadPosition;                 /* --- Parse next Command --- */   rc = xltDecNext(pInstanceInfo->decoderState, pCurrentReadPosition+usedSize, &pCurrentReadPosition, &cmdType, &pContent);  if (rc!=SML_ERR_OK) {    // abort, unlock the buffer again without changing it's current position    smlUnlockReadBuffer(id, (MemSize_t)0);    	// Reset the decoder module (free the decoding object)	  xltDecReset(pInstanceInfo->decoderState);    // this decoding job is over! reset Instance Info pointer    pInstanceInfo->decoderState=NULL;             	// Reset the Workspace (the remaining unparsed document fragment will be lost)	  mgrResetWorkspace(id);    return rc;  }  /* --- End Read Access to the workspace --- */  rc = smlUnlockReadBuffer(id, (MemSize_t)pCurrentReadPosition-(MemSize_t)pBeginPosition);  if (rc!=SML_ERR_OK) {    // abort, unlock the buffer again without changing it's current position    smlUnlockReadBuffer(id, (MemSize_t)0);      return rc;  }    /* --- Did we reach end of synchronization document? --- */  if (((XltDecoderPtr_t)(pInstanceInfo->decoderState))->finished!=0) {    final = ((XltDecoderPtr_t)(pInstanceInfo->decoderState))->final; // flag is returned to appl. with callback    rc=xltDecTerminate(pInstanceInfo->decoderState);    if (rc!=SML_ERR_OK) 	  {      // abort, unlock the buffer again without changing it's current position      smlUnlockReadBuffer(id, (MemSize_t)0);        // Reset the decoder module (free the decoding object)	    xltDecReset(pInstanceInfo->decoderState);      // this decoding job is over! reset Instance Info pointer      pInstanceInfo->decoderState=NULL;           	    // Reset the Workspace (the remaining unparsed document fragment will be lost)    	mgrResetWorkspace(id);      return rc;	  }    // this decoding job is over! reset Instance Info pointer	  // (the decoding object itself has been freed by the decoder)    pInstanceInfo->decoderState=NULL;          // Call the callback for handling an message ending    if (pInstanceInfo->callbacks->endMessageFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;        rc=pInstanceInfo->callbacks->endMessageFunc(id, pInstanceInfo->userData, final);    return rc;   }   /* --- Dispatch parsed command (and call the applications command handler function)--- */  switch (cmdType)  {    /* Handle ADD Command */    case SML_PE_ADD:      if (pInstanceInfo->callbacks->addCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->addCmdFunc (id, pInstanceInfo->userData, pContent);       break;    /* Handle ALERT Command */    case SML_PE_ALERT:      if (pInstanceInfo->callbacks->alertCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->alertCmdFunc (id, pInstanceInfo->userData, pContent);       break;            /* Handle DELETE Command */    case SML_PE_DELETE:      if (pInstanceInfo->callbacks->deleteCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->deleteCmdFunc (id, pInstanceInfo->userData, pContent);        break;    /* Handle PUT Command */    case SML_PE_PUT:      if (pInstanceInfo->callbacks->putCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->putCmdFunc (id, pInstanceInfo->userData, pContent);         break;    /* Handle GET Command */    case SML_PE_GET:      if (pInstanceInfo->callbacks->getCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->getCmdFunc (id, pInstanceInfo->userData, pContent);           break;            #ifdef MAP_RECEIVE          /* Handle MAP Command */    case SML_PE_MAP:      if (pInstanceInfo->callbacks->mapCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->mapCmdFunc (id, pInstanceInfo->userData, pContent);           break;    #endif          #ifdef RESULT_RECEIVE    /* Handle RESULTS Command */    case SML_PE_RESULTS:      if (pInstanceInfo->callbacks->resultsCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->resultsCmdFunc (id, pInstanceInfo->userData, pContent);       break;    #endif    /* Handle STATUS Command */    case SML_PE_STATUS:      if (pInstanceInfo->callbacks->statusCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->statusCmdFunc (id, pInstanceInfo->userData, pContent);        break;    /* Handle START SYNC Command */    case SML_PE_SYNC_START:      if (pInstanceInfo->callbacks->startSyncFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->startSyncFunc (id, pInstanceInfo->userData, pContent);        break;    /* Handle END SYNC Command */    case SML_PE_SYNC_END:      if (pInstanceInfo->callbacks->endSyncFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->endSyncFunc (id, pInstanceInfo->userData);                    break;    /* Handle REPLACE Command */    case SML_PE_REPLACE:      if (pInstanceInfo->callbacks->replaceCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->replaceCmdFunc (id, pInstanceInfo->userData, pContent);        break;    /* Handle Final Flag */    case SML_PE_FINAL:      // if a FINAL Flag appears do nothing      return SML_ERR_OK;      break;    #ifdef SEARCH_RECEIVE  /* these API calls are NOT included in the Toolkit lite version */    /* Handle SEARCH Command */    case SML_PE_SEARCH:      if (pInstanceInfo->callbacks->searchCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->searchCmdFunc (id, pInstanceInfo->userData, pContent);        break;    #endif    #ifdef SEQUENCE_RECEIVE    /* Handle START SEQUENCE Command */    case SML_PE_SEQUENCE_START:      if (pInstanceInfo->callbacks->startSequenceFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->startSequenceFunc (id, pInstanceInfo->userData, pContent);       break;    /* Handle END SEQUENCE Command */    case SML_PE_SEQUENCE_END:      if (pInstanceInfo->callbacks->endSequenceFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->endSequenceFunc (id, pInstanceInfo->userData);                   break;    #endif    #ifdef ATOMIC_RECEIVE    /* Handle START ATOMIC Command */    case SML_PE_ATOMIC_START:      if (pInstanceInfo->callbacks->startAtomicFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->startAtomicFunc (id, pInstanceInfo->userData, pContent);      break;            /* Handle END ATOMIC Command */    case SML_PE_ATOMIC_END:      if (pInstanceInfo->callbacks->endAtomicFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->endAtomicFunc (id, pInstanceInfo->userData);                  break;    #endif          #ifdef COPY_RECEIVE    /* Handle COPY Command */    case SML_PE_COPY:      if (pInstanceInfo->callbacks->copyCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->copyCmdFunc (id, pInstanceInfo->userData, pContent);          break;    #endif    #ifdef EXEC_RECEIVE    /* Handle EXEC Command */    case SML_PE_EXEC:      if (pInstanceInfo->callbacks->execCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;      return pInstanceInfo->callbacks->execCmdFunc (id, pInstanceInfo->userData, pContent);          break;            #endif        /* Handle ERROR DETECTED  */    //case SML_PE_ERROR:    //  if (pInstanceInfo->callbacks->handleErrorFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;    //  return pInstanceInfo->callbacks->handleErrorFunc (id, pInstanceInfo->userData);            //  break;    /* --- Invalid Command Element --- */    default:      return SML_ERR_XLT_INVAL_PROTO_ELEM;         break;  } // switch }/* eof */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -