/** * Construct. */ static ngcliLocalMachineInformationManager_t * ngcllLocalMachineInformationConstruct( ngclContext_t *context, ngclLocalMachineInformation_t *lmInfo, int *error) { int result; ngcliLocalMachineInformationManager_t *lmInfoMng; static const char fName[] = "ngcllLocalMachineInformationConstruct"; /* Check the arguments */ assert(context != NULL); assert(lmInfo != NULL); /* Allocate */ lmInfoMng = NGI_ALLOCATE(ngcliLocalMachineInformationManager_t, context->ngc_log, error); if (lmInfoMng == NULL) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't allocate the storage for Local Machine Information.\n"); return NULL; } /* Initialize */ result = ngcllLocalMachineInformationManagerInitialize( context, lmInfoMng, lmInfo, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Local Machine Information.\n"); goto error; } /* Register */ result = ngcliContextRegisterLocalMachineInformation( context, lmInfoMng, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't register the Local Machine Information for Ninf-G Context.\n"); goto error; } /* Success */ return lmInfoMng; /* Error occurred */ error: result = ngcllLocalMachineInformationDestruct(context, lmInfoMng, error); if (result == 0) { ngclLogFatalContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't free the storage for Local Machine Information Manager.\n"); return NULL; } return NULL; }
/* * Socket: Create(common) */ static ngrcSocket_t * ngrclSocketCreate(int fd) { ngLog_t *log; ngemResult_t nResult; ngrcSocket_t *sock = NULL; NGEM_FNAME(ngrclSocketCreate); log = ngemLogGetDefault(); sock = NGI_ALLOCATE(ngrcSocket_t, log, NULL); if (sock == NULL) { ngLogError(log, NGRC_LOGCAT_GT, fName, "Can't allocate the storage for socket.\n."); goto error; } sock->ngs_fd = fd; sock->ngs_pipe[0] = -1; sock->ngs_pipe[1] = -1; nResult = ngemFDsetNonblockFlag(sock->ngs_fd); if (nResult != NGEM_SUCCESS) { ngLogError(log, NGRC_LOGCAT_GT, fName, "Can't set non-block flag to fd.\n"); goto error; } nResult = ngemNonblockingPipe(sock->ngs_pipe); if (nResult != NGEM_SUCCESS) { ngLogError(log, NGRC_LOGCAT_GT, fName, "Can't create the pipe.\n"); goto error; } return sock; error: nResult = ngrcSocketDestroy(sock); if (nResult != NGEM_SUCCESS) { ngLogError(log, NGRC_LOGCAT_GT, fName, "Can't destroy the socket.\n"); } sock = NULL; return NULL; }
/** * Construct */ ngSessionInformation_t * ngiSessionInformationConstruct( ngLog_t *log, int *error) { int result; ngSessionInformation_t *info; static const char fName[] = "ngiSessionInformationConstruct"; /* Allocate */ info = NGI_ALLOCATE(ngSessionInformation_t, log, error); if (info == NULL) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't allocate the storage for Session Information.\n"); return NULL; } /* Initialize */ result = ngiSessionInformationInitialize(info, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Session Information.\n"); goto error; } /* Success */ return info; /* Error occurred */ error: result = NGI_DEALLOCATE(ngSessionInformation_t, info, log, NULL); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't deallocate the storage for Session Information.\n"); return NULL; } /* Failed */ return NULL; }