/**
 * Callback handler for OwnerShipTransferModeHandler API.
 *
 * @param[in] ctx             ctx value passed to callback from calling function.
 * @param[in] UNUSED          handle to an invocation
 * @param[in] clientResponse  Response from queries to remote servers.
 * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
 *          and  OC_STACK_KEEP_TRANSACTION to keep it.
 */
static OCStackApplicationResult OwnerTransferModeHandler(void *ctx, OCDoHandle UNUSED,
                                                         OCClientResponse *clientResponse)
{
    OC_LOG(DEBUG, TAG, "IN OwnerTransferModeHandler");

    VERIFY_NON_NULL(TAG, clientResponse, WARNING);
    VERIFY_NON_NULL(TAG, ctx, WARNING);

    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
    (void)UNUSED;
    if(clientResponse->result == OC_STACK_OK)
    {
        OC_LOG(INFO, TAG, "OwnerTransferModeHandler : response result = OC_STACK_OK");
        //Send request : GET /oic/sec/pstat
        OCStackResult res = GetProvisioningStatusResource(otmCtx);
        if(OC_STACK_OK != res)
        {
            OC_LOG(WARNING, TAG, "Failed to get pstat information");
            SetResult(otmCtx, res);
        }
    }
    else
    {
        OC_LOG_V(WARNING, TAG, "OwnerTransferModeHandler : Client response is incorrect : %d",
        clientResponse->result);
        SetResult(otmCtx, clientResponse->result);
    }

    OC_LOG(DEBUG, TAG, "OUT OwnerTransferModeHandler");

exit:
    return  OC_STACK_DELETE_TRANSACTION;
}
Beispiel #2
0
void MCPrinter::Close(void)
{
    // In the future this should throw an execution error
    if (m_loop_nesting == 0)
        return;

    m_loop_nesting -= 1;

    if (m_loop_nesting == 0)
    {
        if (m_loop_status == STATUS_READY)
        {
            MCPrinterResult t_result;
            t_result = DoEndPrint(m_device);
            m_device = NULL;
            SetStatusFromResult(t_result);
        }

        // Before we reset status, make sure the result reflects the current status.
        SetResult();

        // Reset status
        SetStatus(STATUS_READY);
    }
    else
        SetResult();
}
Beispiel #3
0
static void my_MySQLquery(RESULT * result, RESULT * query)
{
    char *q;
    double value;
    MYSQL_RES *res;
    MYSQL_ROW row = NULL;

    if (configure_mysql() < 0) {
	value = -1;
	SetResult(&result, R_NUMBER, &value);
	return;
    }

    q = R2S(query);

    /* mysql_ping(MYSQL *mysql) checks whether the connection to the server is working. */
    /* If it has gone down, an automatic reconnection is attempted. */
    mysql_ping(&conex);
    if (mysql_real_query(&conex, q, (unsigned int) strlen(q))) {
	error("[MySQL] query error: %s", mysql_error(&conex));
	value = -1;
    } else {
	/* We don't use res=mysql_use_result();  because mysql_num_rows() will not */
	/* return the correct value until all the rows in the result set have been retrieved */
	/* with mysql_fetch_row(), so we use res=mysql_store_result(); instead */
	res = mysql_store_result(&conex);
	row = mysql_fetch_row(res);
	mysql_free_result(res);
    }

    SetResult(&result, R_STRING, row[0]);
}
Beispiel #4
0
static void my_proc_stat(RESULT * result, const int argc, RESULT * argv[])
{
    char *string;
    double number;

    if (parse_proc_stat() < 0) {
	SetResult(&result, R_STRING, "");
	return;
    }

    switch (argc) {
    case 1:
	string = hash_get(&Stat, R2S(argv[0]), NULL);
	if (string == NULL)
	    string = "";
	SetResult(&result, R_STRING, string);
	break;
    case 2:
	number = hash_get_delta(&Stat, R2S(argv[0]), NULL, R2N(argv[1]));
	SetResult(&result, R_NUMBER, &number);
	break;
    default:
	error("proc_stat(): wrong number of parameters");
	SetResult(&result, R_STRING, "");
    }
}
void CCKAHUMTESTUI2Dlg::OnStmChange() 
{	
	CKAHFW::HNETWORKLIST hNetList = NULL;	

	CKAHUM::OpResult result = CKAHFW::GetNetworkList (&hNetList);

	if (result == CKAHUM::srOK)
	{
		int index = m_NetListCtrl.GetCurSel();		
		
		CKAHFW::Network network;
		
		if ((result = CKAHFW::NetworkList_GetItem (hNetList, index, &network)) == CKAHUM::srOK)
		{
            if (network.HasIPv4)
            {
                CKAHSTM::StmNet Net = { CKAHUM::IP(network.IPv4) , CKAHUM::IP(network.Maskv4) };
    			
			    ClearResult ();
			    result = CKAHSTM::AddNet( &Net );
			    SetResult (result);
            }
            if (network.HasIPv6)
            {
                CKAHSTM::StmNet Net = { CKAHUM::IP(network.IPv6) , CKAHUM::IP(network.Maskv6) };
    			
			    ClearResult ();
			    result = CKAHSTM::AddNet( &Net );
			    SetResult (result);
            }
		}

		CKAHFW::NetworkList_Delete (hNetList);
	}
}
Beispiel #6
0
static void my_uname(RESULT * result, RESULT * arg1)
{
    struct utsname utsbuf;
    char *key, *value;

    key = R2S(arg1);

    if (uname(&utsbuf) != 0) {
	error("uname() failed: %s", strerror(errno));
	SetResult(&result, R_STRING, "");
	return;
    }

    if (strcasecmp(key, "sysname") == 0) {
	value = utsbuf.sysname;
    } else if (strcasecmp(key, "nodename") == 0) {
	value = utsbuf.nodename;
    } else if (strcasecmp(key, "release") == 0) {
	value = utsbuf.release;
    } else if (strcasecmp(key, "version") == 0) {
	value = utsbuf.version;
    } else if (strcasecmp(key, "machine") == 0) {
	value = utsbuf.machine;
#if defined(_GNU_SOURCE) && ! defined(__APPLE__) && ! defined(__CYGWIN__)
    } else if (strcasecmp(key, "domainname") == 0) {
	value = utsbuf.domainname;
#endif
    } else {
	error("uname: unknown field '%s'", key);
	value = "";
    }

    SetResult(&result, R_STRING, value);
}
/**
 * Callback handler of default ACL provisioning.
 *
 * @param[in] ctx             ctx value passed to callback from calling function.
 * @param[in] UNUSED          handle to an invocation
 * @param[in] clientResponse  Response from queries to remote servers.
 * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
 *          and OC_STACK_KEEP_TRANSACTION to keep it.
 */
static OCStackApplicationResult ProvisionDefaultACLCB(void *ctx, OCDoHandle UNUSED,
                                                       OCClientResponse *clientResponse)
{
    OC_LOG_V(INFO, TAG, "IN ProvisionDefaultACLCB.");

    VERIFY_NON_NULL(TAG, clientResponse, ERROR);
    VERIFY_NON_NULL(TAG, ctx, ERROR);

    OTMContext_t* otmCtx = (OTMContext_t*) ctx;
    (void)UNUSED;

    if (OC_STACK_RESOURCE_CREATED == clientResponse->result)
    {
        OC_LOG_V(INFO, TAG, "Staring commit hash task.");
        // TODO hash currently have fixed value 0.
        uint16_t aclHash = 0;
        otmCtx->selectedDeviceInfo->pstat->commitHash = aclHash;
        otmCtx->selectedDeviceInfo->pstat->tm = NORMAL;
        OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
        if(!secPayload)
        {
            OC_LOG(ERROR, TAG, "Failed to memory allocation");
            return OC_STACK_NO_MEMORY;
        }
        secPayload->base.type = PAYLOAD_TYPE_SECURITY;
        secPayload->securityData = BinToPstatJSON(otmCtx->selectedDeviceInfo->pstat);
        if (NULL == secPayload->securityData)
        {
            OICFree(secPayload);
            SetResult(otmCtx, OC_STACK_INVALID_JSON);
            return OC_STACK_DELETE_TRANSACTION;
        }
        OC_LOG_V(INFO, TAG, "Created payload for commit hash: %s",secPayload->securityData);

        char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
        if(!PMGenerateQuery(true,
                            otmCtx->selectedDeviceInfo->endpoint.addr,
                            otmCtx->selectedDeviceInfo->securePort,
                            otmCtx->selectedDeviceInfo->connType,
                            query, sizeof(query), OIC_RSRC_PSTAT_URI))
        {
            OC_LOG(ERROR, TAG, "ProvisionDefaultACLCB : Failed to generate query");
            return OC_STACK_ERROR;
        }
        OC_LOG_V(DEBUG, TAG, "Query=%s", query);

        OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
        cbData.cb = &FinalizeProvisioningCB;
        cbData.context = (void*)otmCtx;
        cbData.cd = NULL;
        OCStackResult ret = OCDoResource(NULL, OC_REST_PUT, query, 0, (OCPayload*)secPayload,
                otmCtx->selectedDeviceInfo->connType, OC_HIGH_QOS, &cbData, NULL, 0);
        OC_LOG_V(INFO, TAG, "OCDoResource returned: %d",ret);
        if (ret != OC_STACK_OK)
        {
            OC_LOG(ERROR, TAG, "OCStack resource error");
            SetResult(otmCtx, ret);
        }
    }
/**
 * Callback handler for ProvisioningStatusResouceHandler API.
 *
 * @param[in] ctx             ctx value passed to callback from calling function.
 * @param[in] UNUSED          handle to an invocation
 * @param[in] clientResponse  Response from queries to remote servers.
 * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
 *          and  OC_STACK_KEEP_TRANSACTION to keep it.
 */
static OCStackApplicationResult ListMethodsHandler(void *ctx, OCDoHandle UNUSED,
                                                    OCClientResponse *clientResponse)
{
    OC_LOG(DEBUG, TAG, "IN ListMethodsHandler");

    VERIFY_NON_NULL(TAG, clientResponse, WARNING);
    VERIFY_NON_NULL(TAG, ctx, WARNING);

    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
    (void)UNUSED;
    if  (OC_STACK_OK == clientResponse->result)
    {
        if  (NULL == clientResponse->payload)
        {
            OC_LOG(INFO, TAG, "Skiping Null payload");
            SetResult(otmCtx, OC_STACK_ERROR);
            return OC_STACK_DELETE_TRANSACTION;
        }

        if (PAYLOAD_TYPE_SECURITY != clientResponse->payload->type)
        {
            OC_LOG(INFO, TAG, "Unknown payload type");
            SetResult(otmCtx, OC_STACK_ERROR);
            return OC_STACK_DELETE_TRANSACTION;
        }

        OicSecPstat_t* pstat = JSONToPstatBin(
                ((OCSecurityPayload*)clientResponse->payload)->securityData);
        if(NULL == pstat)
        {
            OC_LOG(ERROR, TAG, "Error while converting json to pstat bin");
            SetResult(otmCtx, OC_STACK_ERROR);
            return OC_STACK_DELETE_TRANSACTION;
        }
        otmCtx->selectedDeviceInfo->pstat = pstat;

        //Select operation mode (Currently supported SINGLE_SERVICE_CLIENT_DRIVEN only)
        OicSecDpom_t selectedOperationMode;
        SelectOperationMode(otmCtx->selectedDeviceInfo, &selectedOperationMode);

        //Send request : PUT /oic/sec/pstat [{"OM":"0x11", .. }]
        OCStackResult res = PutUpdateOperationMode(otmCtx, selectedOperationMode);
        if (OC_STACK_OK != res)
        {
            OC_LOG(ERROR, TAG, "Error while updating operation mode.");
            SetResult(otmCtx, res);
        }
    }
    else
    {
        OC_LOG_V(WARNING, TAG, "ListMethodsHandler : Client response is incorrect : %d",
            clientResponse->result);
        SetResult(otmCtx, clientResponse->result);
    }

    OC_LOG(DEBUG, TAG, "OUT ListMethodsHandler");
exit:
    return  OC_STACK_DELETE_TRANSACTION;
}
/**
 * Response handler for update operation mode.
 *
 * @param[in] ctx             ctx value passed to callback from calling function.
 * @param[in] UNUSED          handle to an invocation
 * @param[in] clientResponse  Response from queries to remote servers.
 * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
 *          and  OC_STACK_KEEP_TRANSACTION to keep it.
 */
static OCStackApplicationResult OperationModeUpdateHandler(void *ctx, OCDoHandle UNUSED,
                                OCClientResponse *clientResponse)
{
    OC_LOG(DEBUG, TAG, "IN OperationModeUpdateHandler");

    VERIFY_NON_NULL(TAG, clientResponse, WARNING);
    VERIFY_NON_NULL(TAG, ctx, WARNING);

    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
    (void) UNUSED;
    if  (OC_STACK_OK == clientResponse->result)
    {
        OCStackResult res = OC_STACK_ERROR;
        OicSecOxm_t selOxm = otmCtx->selectedDeviceInfo->doxm->oxmSel;
        //DTLS Handshake
        //Load secret for temporal secure session.
        if(g_OTMDatas[selOxm].loadSecretCB)
        {
            res = g_OTMDatas[selOxm].loadSecretCB(otmCtx);
            if(OC_STACK_OK != res)
            {
                OC_LOG(ERROR, TAG, "OperationModeUpdate : Failed to load secret");
                SetResult(otmCtx, res);
                return  OC_STACK_DELETE_TRANSACTION;
            }
        }

        //Try DTLS handshake to generate secure session
        if(g_OTMDatas[selOxm].createSecureSessionCB)
        {
            res = g_OTMDatas[selOxm].createSecureSessionCB(otmCtx);
            if(OC_STACK_OK != res)
            {
                OC_LOG(ERROR, TAG, "OperationModeUpdate : Failed to create DTLS session");
                SetResult(otmCtx, res);
                return OC_STACK_DELETE_TRANSACTION;
            }
        }

        //Send request : PUT /oic/sec/doxm [{"Owned":"True", .. , "Owner":"PT's UUID"}]
        res = PutOwnershipInformation(otmCtx);
        if(OC_STACK_OK != res)
        {
            OC_LOG(ERROR, TAG, "OperationModeUpdate : Failed to send owner information");
            SetResult(otmCtx, res);
        }
    }
    else
    {
        OC_LOG(ERROR, TAG, "Error while update operation mode");
        SetResult(otmCtx, clientResponse->result);
    }

    OC_LOG(DEBUG, TAG, "OUT OperationModeUpdateHandler");

exit:
    return  OC_STACK_DELETE_TRANSACTION;
}
void CCAsyncDBJob_UpdateDuelTournamentCharInfo::Run(void* pContext)
{
	CCMatchDBMgr* pDBMgr = (CCMatchDBMgr*)pContext;

	if (!pDBMgr->UpdateDuelTournamentCharacterInfo(m_dwPlayerCID, m_szTimeStamp, m_pDTCharInfo))
	{
		SetResult(CCASYNC_RESULT_FAILED);;
	}

	SetResult(CCASYNC_RESULT_SUCCEED);
}
Beispiel #11
0
static void my_cpu(RESULT * result, RESULT * arg1, RESULT * arg2)
{
    char *key;
    int delay;
    double value;
    double cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_total;
    double cpu_iow, cpu_irq, cpu_sirq;

    if (parse_proc_stat() < 0) {
	SetResult(&result, R_STRING, "");
	return;
    }

    key = R2S(arg1);
    delay = R2N(arg2);

    cpu_user = hash_get_delta(&Stat, "cpu.user", NULL, delay);
    cpu_nice = hash_get_delta(&Stat, "cpu.nice", NULL, delay);
    cpu_system = hash_get_delta(&Stat, "cpu.system", NULL, delay);
    cpu_idle = hash_get_delta(&Stat, "cpu.idle", NULL, delay);

    /* new fields for kernel 2.6 */
    /* even if we dont have this param (ie kernel 2.4) */
    /* the return is 0.0 and not change the results */
    cpu_iow = hash_get_delta(&Stat, "cpu.iow", NULL, delay);
    cpu_irq = hash_get_delta(&Stat, "cpu.irq", NULL, delay);
    cpu_sirq = hash_get_delta(&Stat, "cpu.sirq", NULL, delay);

    cpu_total = cpu_user + cpu_nice + cpu_system + cpu_idle + cpu_iow + cpu_irq + cpu_sirq;

    if (strcasecmp(key, "user") == 0)
	value = cpu_user;
    else if (strcasecmp(key, "nice") == 0)
	value = cpu_nice;
    else if (strcasecmp(key, "system") == 0)
	value = cpu_system;
    else if (strcasecmp(key, "idle") == 0)
	value = cpu_idle;
    else if (strcasecmp(key, "iowait") == 0)
	value = cpu_iow;
    else if (strcasecmp(key, "irq") == 0)
	value = cpu_irq;
    else if (strcasecmp(key, "softirq") == 0)
	value = cpu_sirq;
    else if (strcasecmp(key, "busy") == 0)
	value = cpu_total - cpu_idle;

    if (cpu_total > 0.0)
	value = 100 * value / cpu_total;
    else
	value = 0.0;

    SetResult(&result, R_NUMBER, &value);
}
Beispiel #12
0
void MAsyncDBJob_GetAccountCharList::Run(void* pContext)
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;

	if (!pDBMgr->GetAccountCharList(m_nAID, m_CharList, &m_nCharCount))
	{
		SetResult(MASYNC_RESULT_FAILED);
		return;
	}

	SetResult(MASYNC_RESULT_SUCCEED);
}
void MAsyncDBJob_BuyQuestItem::Run( void* pContext )
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;

	if( !pDBMgr->UpdateCharBP(m_dwCID, -m_nPrice) )
	{
		SetResult( MASYNC_RESULT_FAILED );
		return;
	}

	SetResult( MASYNC_RESULT_SUCCEED );
}
Beispiel #14
0
static void getFilename(RESULT * result)
{
    const char *value = NULL;
    mpd_update();
    if (currentSong != NULL) {
	value = mpd_song_get_uri(currentSong);
    }
    if (value)
	SetResult(&result, R_STRING, charset_from_utf8(value));
    else
	SetResult(&result, R_STRING, "");
}
Beispiel #15
0
static void getAlbum(RESULT * result)
{
    const char *value = NULL;
    mpd_update();
    if (currentSong != NULL) {
	value = mpd_song_get_tag(currentSong, MPD_TAG_ALBUM, 0);
    }
    if (value)
	SetResult(&result, R_STRING, charset_from_utf8(value));
    else
	SetResult(&result, R_STRING, "");
}
Beispiel #16
0
void MAsyncDBJob_ResetAccountHackingBlock::Run( void* pContext )
{
	MMatchDBMgr* pDBMgr = reinterpret_cast< MMatchDBMgr* >( pContext );

	if( !pDBMgr->ResetAccountHackingBlock(m_dwAID, m_btBlockType) )
	{
		SetResult( MASYNC_RESULT_FAILED );
		return;
	}

	SetResult( MASYNC_RESULT_SUCCEED );
}
void MBMatchAsyncDBJob_BuyBountyItem::Run( void* pContext )
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;

	if( !pDBMgr->BuyBountyItem(m_nCID, m_nAID, m_nItemID, m_nItemCount, m_dwPrice, m_wRentHourPeriod, m_bIsSpendableItem, &m_dwCIID, m_nBuyMode) )
	{
		SetResult( MASYNC_RESULT_FAILED );
		return;
	}

	SetResult( MASYNC_RESULT_SUCCEED );
}
void CCAsyncDBJob_GetDuelTournamentTimeStamp::Run(void* pContext)
{
	CCMatchDBMgr* pDBMgr = (CCMatchDBMgr*)pContext;

	if (!pDBMgr->GetDuelTournamentTimeStamp(m_szTimeStamp) )
	{
		SetResult(CCASYNC_RESULT_FAILED);
		return;
	}

	SetResult(CCASYNC_RESULT_SUCCEED);
}
void CCAsyncDBJob_GetDuelTournamentSideRankingInfo::Run(void* pContext)
{
	CCMatchDBMgr* pDBMgr = (CCMatchDBMgr*)pContext;

	if (!pDBMgr->GetDuelTournamentSideRankingInfo(m_dwPlayerCID, &m_SideRankingList) )
	{
		SetResult(CCASYNC_RESULT_FAILED);
		return;
	}

	SetResult(CCASYNC_RESULT_SUCCEED);
}
void MBMatchAsyncDBJob_BringBackAccountItemStackable::Run( void* pContext )
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;

	if( !pDBMgr->BringBackAccountItemStackable(m_dwAID, m_dwCID, m_dwCIID, m_dwItemCnt) )
	{
		SetResult( MASYNC_RESULT_FAILED );
		return;
	}

	SetResult( MASYNC_RESULT_SUCCEED );
}
void CCAsyncDBJob_UpdateDuelTournamentGameLog::Run(void* pContext)
{
	CCMatchDBMgr* pDBMgr = (CCMatchDBMgr*)pContext;

	if (!pDBMgr->UpdateDuelTournamentGameLog(m_szTimeStamp, m_nLogID, m_nChampionCID) )
	{
		SetResult(CCASYNC_RESULT_FAILED);
		return;
	}

	SetResult(CCASYNC_RESULT_SUCCEED);
}
void CCAsyncDBJob_GetDuelTournamentPreviousCharInfo::Run(void* pContext)
{
	CCMatchDBMgr* pDBMgr = (CCMatchDBMgr*)pContext;

	if (!pDBMgr->GetDuelTournamentPreviousCharacterInfo(m_dwPlayerCID, 
		&m_nPrevTP, &m_nPrevWins, &m_nPrevLoses, &m_nPrevRanking, &m_nPrevFinalWins) )
	{
		SetResult(CCASYNC_RESULT_FAILED);;
	}

	SetResult(CCASYNC_RESULT_SUCCEED);
}
void CCAsyncDBJob_InsertDuelTournamentGameLogDetail::Run(void* pContext)
{
	CCMatchDBMgr* pDBMgr = (CCMatchDBMgr*)pContext;

	if (!pDBMgr->InsertDuelTournamentGameLogDetail(m_nLogID, m_szTimeStamp, (int)m_nDTRoundState, m_nPlayTime
		, m_nWinnerCID, m_nGainTP, m_nLoserCID, m_nLoseTP) )
	{
		SetResult(CCASYNC_RESULT_FAILED);
		return;
	}

	SetResult(CCASYNC_RESULT_SUCCEED);
}
Beispiel #24
0
void MAsyncDBJob_ExpelClanMember::Run(void* pContext)
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;

	// 실제로 디비상에서 권한 변경
	if (!pDBMgr->ExpelClanMember(m_nCLID, m_nClanGrade, m_szTarMember, &m_nDBResult))
	{
		SetResult(MASYNC_RESULT_FAILED);
		return;
	}

	SetResult(MASYNC_RESULT_SUCCEED);
}
Beispiel #25
0
void MAsyncDBJob_UpdateCharClanContPoint::Run(void* pContext)
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;


	if (!pDBMgr->UpdateCharClanContPoint(m_nCID, m_nCLID, m_nAddedContPoint))
	{
		SetResult(MASYNC_RESULT_FAILED);
		return;
	}


	SetResult(MASYNC_RESULT_SUCCEED);
}
Beispiel #26
0
void MAsyncDBJob_DeleteChar::Run(void* pContext)
{
	MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;

	if (!pDBMgr->DeleteCharacter(m_nAID, m_nCharNum, m_szCharName))
	{
		m_nDeleteResult = MERR_CANNOT_DELETE_CHAR;
		SetResult(MASYNC_RESULT_FAILED);
		return;
	}

	m_nDeleteResult = MOK;
	SetResult(MASYNC_RESULT_SUCCEED);
}
Beispiel #27
0
bool CreateExecutor::DExecute() {
  LOG_TRACE("Executing Create...");
  const planner::CreatePlan &node = GetPlanNode<planner::CreatePlan>();
  auto current_txn = context->GetTransaction();

  // Check if query was for creating table
  if (node.GetCreateType() == CreateType::TABLE) {
    std::string table_name = node.GetTableName();
    auto database_name = node.GetDatabaseName();
    std::unique_ptr<catalog::Schema> schema(node.GetSchema());

    ResultType result = catalog::Catalog::GetInstance()->CreateTable(
        database_name, table_name, std::move(schema), current_txn);
    current_txn->SetResult(result);

    if (current_txn->GetResult() == ResultType::SUCCESS) {
      LOG_TRACE("Creating table succeeded!");
    } else if (current_txn->GetResult() == ResultType::FAILURE) {
      LOG_TRACE("Creating table failed!");
    } else {
      LOG_TRACE("Result is: %s",
                ResultTypeToString(current_txn->GetResult()).c_str());
    }
  }

  // Check if query was for creating index
  if (node.GetCreateType() == CreateType::INDEX) {
    std::string table_name = node.GetTableName();
    std::string index_name = node.GetIndexName();
    bool unique_flag = node.IsUnique();
    IndexType index_type = node.GetIndexType();

    auto index_attrs = node.GetIndexAttributes();

    ResultType result = catalog::Catalog::GetInstance()->CreateIndex(
        DEFAULT_DB_NAME, table_name, index_attrs, index_name, unique_flag,
        index_type, current_txn);
    current_txn->SetResult(result);

    if (current_txn->GetResult() == ResultType::SUCCESS) {
      LOG_TRACE("Creating table succeeded!");
    } else if (current_txn->GetResult() == ResultType::FAILURE) {
      LOG_TRACE("Creating table failed!");
    } else {
      LOG_TRACE("Result is: %s",
                ResultTypeToString(current_txn->GetResult()).c_str());
    }
  }
  return false;
}
logical cClassCodeBase :: GetClassName ( )
{
  PropertyHandle   *prophdl = GetPropertyHandle();
  logical           term    = NO;
BEGINSEQ
  if ( !(prophdl = prophdl->GetParentProperty()->GetParentProperty()->GetParentProperty()) )
                                                     ERROR
  SetResult(prophdl->GPH("sys_ident")->GetString());
RECOVER
  SetResult("");
  term = YES;
ENDSEQ
  return(term);
}
Beispiel #29
0
static void my_apm(RESULT * result, RESULT * arg1)
{
    char *val;

    if (parse_proc_apm() < 0) {
	SetResult(&result, R_STRING, "");
	return;
    }

    val = hash_get(&APM, R2S(arg1), NULL);
    if (val == NULL)
	val = "";

    SetResult(&result, R_STRING, val);
}
/**
 * Callback handler of SRPFinalizeProvisioning.
 *
 * @param[in] ctx             ctx value passed to callback from calling function.
 * @param[in] UNUSED          handle to an invocation
 * @param[in] clientResponse  Response from queries to remote servers.
 * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
 *          and OC_STACK_KEEP_TRANSACTION to keep it.
 */
static OCStackApplicationResult FinalizeProvisioningCB(void *ctx, OCDoHandle UNUSED,
                                                       OCClientResponse *clientResponse)
{
    OC_LOG_V(INFO, TAG, "IN FinalizeProvisioningCB.");

    VERIFY_NON_NULL(TAG, clientResponse, ERROR);
    VERIFY_NON_NULL(TAG, ctx, ERROR);

    OTMContext_t* otmCtx = (OTMContext_t*)ctx;
    (void)UNUSED;
    if(OC_STACK_OK == clientResponse->result)
    {
        OCStackResult res = PDMAddDevice(&otmCtx->selectedDeviceInfo->doxm->deviceID);

         if (OC_STACK_OK == res)
         {
                OC_LOG_V(INFO, TAG, "Add device's UUID in PDM_DB");
                SetResult(otmCtx, OC_STACK_OK);
                return OC_STACK_DELETE_TRANSACTION;
         }
         else
         {
              OC_LOG(ERROR, TAG, "Ownership transfer is complete but adding information to DB is failed.");
         }
    }
exit:
    return OC_STACK_DELETE_TRANSACTION;
}