/** * Request Reader Initialize */ int ngisiRequestReaderInitialize( ngisiContext_t *context, ngisiRequestReader_t *requestReader, int *error) { static const char fName[] = "ngisiRequestReaderInitialize"; int result; /* Check the arguments */ assert(context != NULL); assert(requestReader != NULL); ngislRequestReaderInitializeMember(requestReader); result = ngisiMutexInitialize( context, &requestReader->ngisr_mutex, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Initialize the mutex failed.\n"); return 0; } requestReader->ngisr_mutexInitialized = 1; result = ngisiCondInitialize( context, &requestReader->ngisr_cond, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Initialize the cond failed.\n"); return 0; } requestReader->ngisr_condInitialized = 1; result = ngisiReadBufferInitialize( context, &requestReader->ngisr_readBuffer, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Initialize the Read Buffer failed.\n"); return 0; } result = ngislRequestReaderStatusSet( context, NGISI_REQUEST_READER_STATUS_INITIALIZED, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Set the Request Reader Status failed.\n"); return 0; } result = ngislRequestReaderStart(context, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Start the Request Reader failed.\n"); return 0; } /* Success */ return 1; }
/** * RefreshCredential: Initialize. */ int ngisiRefreshCredentialInitialize( ngisiContext_t *context, ngisiRefreshCredential_t *ref, int *error) { static const char fName[] = "ngisiRefreshCredentialInitialize"; int result; /* Check the arguments */ assert(context != NULL); assert(ref != NULL); ngislRefreshCredentialInitializeMember(ref); result = ngisiMutexInitialize( context, &ref->ngisrc_mutex, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Initialize the mutex failed.\n"); return 0; } ref->ngisrc_mutexInitialized = 1; result = ngisiCondInitialize( context, &ref->ngisrc_cond, error); if (result == 0) { ngisiLogPrintf(context, NGISI_LOG_LEVEL_ERROR, fName, "Initialize the cond failed.\n"); return 0; } ref->ngisrc_condInitialized = 1; ref->ngisrc_updateInterval = 0; /* disable at first */ ref->ngisrc_continue = 0; /* Thread is not invoked at first. */ ref->ngisrc_working = 0; /* Success */ return 1; }