这篇教程C++ rstrcpy函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中rstrcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ rstrcpy函数的具体用法?C++ rstrcpy怎么用?C++ rstrcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了rstrcpy函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: rsMkBundlePathintrsMkBundlePath( rsComm_t *rsComm, char *collection, char *bundlePath, int myRanNum ) { int status; char *tmpStr; char startBundlePath[MAX_NAME_LEN]; char destBundleColl[MAX_NAME_LEN], myFile[MAX_NAME_LEN]; char *bundlePathPtr; bundlePathPtr = bundlePath; *bundlePathPtr = '/'; bundlePathPtr++; tmpStr = collection + 1; /* copy the zone */ while ( *tmpStr != '/0' ) { *bundlePathPtr = *tmpStr; bundlePathPtr ++; if ( *tmpStr == '/' ) { tmpStr ++; break; } tmpStr ++; } if ( *tmpStr == '/0' ) { rodsLog( LOG_ERROR, "rsMkBundlePath: input path %s too short", collection ); return USER_INPUT_PATH_ERR; } /* cannot bundle trash and bundle */ if ( strncmp( tmpStr, "trash/", 6 ) == 0 || strncmp( tmpStr, "bundle/", 7 ) == 0 ) { rodsLog( LOG_ERROR, "rsMkBundlePath: cannot bundle trash or bundle path %s", collection ); return USER_INPUT_PATH_ERR; } /* don't want to go back beyond /myZone/bundle/home */ *bundlePathPtr = '/0'; rstrcpy( startBundlePath, bundlePath, MAX_NAME_LEN ); snprintf( bundlePathPtr, MAX_NAME_LEN, "bundle/%s.%u", tmpStr, ( unsigned int )myRanNum ); if ( ( status = splitPathByKey( bundlePath, destBundleColl, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) < 0 ) { rodsLog( LOG_ERROR, "rsMkBundlePath: splitPathByKey error for %s ", bundlePath ); return USER_INPUT_PATH_ERR; } status = rsMkCollR( rsComm, startBundlePath, destBundleColl ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsMkBundlePath: rsMkCollR error for startPath %s, destPath %s ", startBundlePath, destBundleColl ); } return status;}
开发者ID:jrandall,项目名称:irods,代码行数:62,
示例2: resolveRodsTarget/* resolveRodsTarget - based on srcPath and destPath, fill in targPath. * oprType - * MOVE_OPR - do not create the target coll or dir because rename will * take care of it. * RSYNC_OPR - udes the destPath and the targPath if the src is a * collection * All other oprType will be treated as normal. */intresolveRodsTarget (rcComm_t *conn, rodsEnv *myRodsEnv,rodsPathInp_t *rodsPathInp, int oprType) { rodsPath_t *srcPath, *destPath; char srcElement[MAX_NAME_LEN], destElement[MAX_NAME_LEN]; int status; int srcInx; rodsPath_t *targPath; if (rodsPathInp == NULL) { rodsLog (LOG_ERROR, "resolveRodsTarget: NULL rodsPathInp or targPath input"); return (USER__NULL_INPUT_ERR); } destPath = rodsPathInp->destPath; if (destPath != NULL && destPath->objState == UNKNOWN_ST) { getRodsObjType (conn, destPath); } for (srcInx = 0; srcInx < rodsPathInp->numSrc; srcInx++) { srcPath = &rodsPathInp->srcPath[srcInx]; targPath = &rodsPathInp->targPath[srcInx]; /* we don't do wild card yet */ if (srcPath->objState == UNKNOWN_ST) { getRodsObjType (conn, srcPath); if (srcPath->objState == NOT_EXIST_ST) { rodsLog (LOG_ERROR, "resolveRodsTarget: srcPath %s does not exist", srcPath->outPath); return (USER_INPUT_PATH_ERR); } } if (destPath->objType >= UNKNOWN_FILE_T && strcmp (destPath->outPath, STDOUT_FILE_NAME) == 0) { /* pipe to stdout */ if (srcPath->objType != DATA_OBJ_T) { rodsLog (LOG_ERROR, "resolveRodsTarget: src %s is the wrong type for dest -", srcPath->outPath); return (USER_INPUT_PATH_ERR); } *targPath = *destPath; targPath->objType = LOCAL_FILE_T; } else if (srcPath->objType == DATA_OBJ_T || srcPath->objType == LOCAL_FILE_T) { /* file type source */ if ((destPath->objType == COLL_OBJ_T || destPath->objType == LOCAL_DIR_T) && destPath->objState == EXIST_ST) { if (destPath->objType <= COLL_OBJ_T) { targPath->objType = DATA_OBJ_T; } else { targPath->objType = LOCAL_FILE_T; } /* collection */ getLastPathElement (srcPath->inPath, srcElement); if (strlen (srcElement) > 0) { snprintf (targPath->outPath, MAX_NAME_LEN, "%s/%s", destPath->outPath, srcElement); if (destPath->objType <= COLL_OBJ_T) getRodsObjType (conn, destPath); } else { rstrcpy (targPath->outPath, destPath->outPath, MAX_NAME_LEN); } } else if (destPath->objType == DATA_OBJ_T || destPath->objType == LOCAL_FILE_T || rodsPathInp->numSrc == 1) { *targPath = *destPath; if (destPath->objType <= COLL_OBJ_T) { targPath->objType = DATA_OBJ_T; } else { targPath->objType = LOCAL_FILE_T; } } else { rodsLogError (LOG_ERROR, USER_FILE_DOES_NOT_EXIST, "resolveRodsTarget: target %s does not exist", destPath->outPath); return (USER_FILE_DOES_NOT_EXIST); } } else if (srcPath->objType == COLL_OBJ_T || srcPath->objType == LOCAL_DIR_T) { /* directory type source */ if (destPath->objType <= COLL_OBJ_T) { targPath->objType = COLL_OBJ_T;//.........这里部分代码省略.........
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:101,
示例3: collStatintcollStat( rsComm_t *rsComm, dataObjInp_t *dataObjInp, rodsObjStat_t **rodsObjStatOut ) { genQueryInp_t genQueryInp; genQueryOut_t *genQueryOut = NULL; int status; char condStr[MAX_NAME_LEN]; sqlResult_t *dataId; sqlResult_t *ownerName; sqlResult_t *ownerZone; sqlResult_t *createTime; sqlResult_t *modifyTime; sqlResult_t *collType; sqlResult_t *collInfo1; sqlResult_t *collInfo2; /* see if objPath is a collection */ memset( &genQueryInp, 0, sizeof( genQueryInp ) ); snprintf( condStr, MAX_NAME_LEN, "='%s'", dataObjInp->objPath ); addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, condStr ); addInxIval( &genQueryInp.selectInp, COL_COLL_ID, 1 ); /* XXXX COL_COLL_NAME added for queueSpecColl */ addInxIval( &genQueryInp.selectInp, COL_COLL_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_COLL_OWNER_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_COLL_OWNER_ZONE, 1 ); addInxIval( &genQueryInp.selectInp, COL_COLL_CREATE_TIME, 1 ); addInxIval( &genQueryInp.selectInp, COL_COLL_MODIFY_TIME, 1 ); /* XXXX may want to do this if spec coll is supported */ addInxIval( &genQueryInp.selectInp, COL_COLL_TYPE, 1 ); addInxIval( &genQueryInp.selectInp, COL_COLL_INFO1, 1 ); addInxIval( &genQueryInp.selectInp, COL_COLL_INFO2, 1 ); genQueryInp.maxRows = MAX_SQL_ROWS; status = rsGenQuery( rsComm, &genQueryInp, &genQueryOut ); if ( status >= 0 ) { *rodsObjStatOut = ( rodsObjStat_t * ) malloc( sizeof( rodsObjStat_t ) ); memset( *rodsObjStatOut, 0, sizeof( rodsObjStat_t ) ); ( *rodsObjStatOut )->objType = COLL_OBJ_T; status = ( int )COLL_OBJ_T; if ( ( dataId = getSqlResultByInx( genQueryOut, COL_COLL_ID ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat: getSqlResultByInx for COL_COLL_ID failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( ownerName = getSqlResultByInx( genQueryOut, COL_COLL_OWNER_NAME ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_OWNER_NAME failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( ownerZone = getSqlResultByInx( genQueryOut, COL_COLL_OWNER_ZONE ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_OWNER_ZONE failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( createTime = getSqlResultByInx( genQueryOut, COL_COLL_CREATE_TIME ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_CREATE_TIME failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( modifyTime = getSqlResultByInx( genQueryOut, COL_COLL_MODIFY_TIME ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_MODIFY_TIME failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( collType = getSqlResultByInx( genQueryOut, COL_COLL_TYPE ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_TYPE failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( collInfo1 = getSqlResultByInx( genQueryOut, COL_COLL_INFO1 ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_INFO1 failed" ); return UNMATCHED_KEY_OR_INDEX; } else if ( ( collInfo2 = getSqlResultByInx( genQueryOut, COL_COLL_INFO2 ) ) == NULL ) { rodsLog( LOG_ERROR, "_rsObjStat:getSqlResultByInx for COL_COLL_INFO2 failed" ); return UNMATCHED_KEY_OR_INDEX; } else { rstrcpy( ( *rodsObjStatOut )->dataId, dataId->value, NAME_LEN ); rstrcpy( ( *rodsObjStatOut )->ownerName, ownerName->value, NAME_LEN ); rstrcpy( ( *rodsObjStatOut )->ownerZone, ownerZone->value, NAME_LEN ); rstrcpy( ( *rodsObjStatOut )->createTime, createTime->value, TIME_LEN ); rstrcpy( ( *rodsObjStatOut )->modifyTime, modifyTime->value, TIME_LEN );//.........这里部分代码省略.........
开发者ID:bpow,项目名称:irods,代码行数:101,
示例4: msiobjput_slink int msiobjput_slink( msParam_t* inMSOPath, msParam_t* inCacheFilename, msParam_t* inFileSize, ruleExecInfo_t* rei ) { RE_TEST_MACRO( " Calling msiobjput_slink" ); /* check for input parameters */ if ( inMSOPath == NULL || strcmp( inMSOPath->type , STR_MS_T ) != 0 || inMSOPath->inOutStruct == NULL ) { return USER_PARAM_TYPE_ERR; } if ( inCacheFilename == NULL || strcmp( inCacheFilename->type , STR_MS_T ) != 0 || inCacheFilename->inOutStruct == NULL ) { return USER_PARAM_TYPE_ERR; } if ( inFileSize == NULL || strcmp( inFileSize->type , STR_MS_T ) != 0 || inFileSize->inOutStruct == NULL ) { return USER_PARAM_TYPE_ERR; } /* coerce input to local variables */ char * str = strdup( ( char * ) inMSOPath->inOutStruct ); char * reqStr = strstr( str, ":" ); if ( reqStr == NULL ) { free( str ); return USER_INPUT_FORMAT_ERR; } reqStr = reqStr + 1; dataObjInp_t dataObjInp; memset( &dataObjInp, 0, sizeof( dataObjInp_t ) ); rstrcpy( dataObjInp.objPath, reqStr, MAX_NAME_LEN ); addKeyVal( &dataObjInp.condInput, FORCE_FLAG_KW, "" ); free( str ); rsComm_t * rsComm = rei->rsComm; int outDesc = rsDataObjCreate( rsComm, &dataObjInp ); if ( outDesc < 0 ) { printf( "msiputobj_slink: Unable to open file %s:%i/n", dataObjInp.objPath, outDesc ); return outDesc; } /* Read the cache and Do the upload*/ char * cacheFilename = ( char * ) inCacheFilename->inOutStruct; int srcFd = open( cacheFilename, O_RDONLY, 0 ); if ( srcFd < 0 ) { int status = UNIX_FILE_OPEN_ERR - errno; printf( "msiputobj_slink: open error for %s, status = %d/n", cacheFilename, status ); return status; } int single_buff_sz = 0; irods::error ret = irods::get_advanced_setting<int>( irods::CFG_MAX_SIZE_FOR_SINGLE_BUFFER, single_buff_sz ); if( !ret.ok() ) { irods::log( PASS( ret ) ); return ret.code(); } single_buff_sz *= 1024 * 1024; size_t dataSize = atol( ( char * ) inFileSize->inOutStruct ); if ( dataSize > single_buff_sz ) { dataSize = single_buff_sz; } openedDataObjInp_t dataObjWriteInp; memset( &dataObjWriteInp, 0, sizeof( dataObjWriteInp ) ); dataObjWriteInp.l1descInx = outDesc; openedDataObjInp_t dataObjCloseInp; memset( &dataObjCloseInp, 0, sizeof( dataObjCloseInp ) ); dataObjCloseInp.l1descInx = outDesc; char * myBuf = ( char * ) malloc( dataSize ); bytesBuf_t writeBuf; writeBuf.buf = myBuf; int bytesRead; for ( bytesRead = read( srcFd, ( void * ) myBuf, dataSize ); bytesRead > 0; bytesRead = read( srcFd, ( void * ) myBuf, dataSize ) ) { writeBuf.len = bytesRead; dataObjWriteInp.len = bytesRead; int bytesWritten = rsDataObjWrite( rsComm, &dataObjWriteInp, &writeBuf ); if ( bytesWritten != bytesRead ) { free( myBuf ); close( srcFd ); rsDataObjClose( rsComm, &dataObjCloseInp ); printf( "msiputobj_slink: Write Error: bytesRead %d != bytesWritten %d/n", bytesRead, bytesWritten ); return SYS_COPY_LEN_ERR; }//.........这里部分代码省略.........
开发者ID:nesi,项目名称:irods,代码行数:101,
示例5: parseCmdLinePathintparseCmdLinePath (int argc, char **argv, int optInd, rodsEnv *myRodsEnv, int srcFileType, int destFileType, int flag, rodsPathInp_t *rodsPathInp){ int nInput; int i, status; int numSrc; nInput = argc - optInd; if (rodsPathInp == NULL) { rodsLog (LOG_ERROR, "parseCmdLinePath: NULL rodsPathInp input"); return (USER__NULL_INPUT_ERR); } memset (rodsPathInp, 0, sizeof (rodsPathInp_t)); if (nInput <= 0) { if ((flag & ALLOW_NO_SRC_FLAG) == 0) { return (USER__NULL_INPUT_ERR); } else { numSrc = 1; } } else if (nInput == 1) { numSrc = 1; } else if (destFileType == NO_INPUT_T) { /* no dest input */ numSrc = nInput; } else { numSrc = nInput - 1; } for (i = 0; i < numSrc; i++) { if (nInput <= 0) { /* just add cwd */ addSrcInPath (rodsPathInp, "."); } else { addSrcInPath (rodsPathInp, argv[optInd + i]); } if (srcFileType <= COLL_OBJ_T) { status = parseRodsPath (&rodsPathInp->srcPath[i], myRodsEnv); } else { status = parseLocalPath (&rodsPathInp->srcPath[i]); } if (status < 0) { return (status); } } if (destFileType != NO_INPUT_T) { rodsPathInp->destPath = (rodsPath_t*)malloc (sizeof (rodsPath_t)); memset (rodsPathInp->destPath, 0, sizeof (rodsPath_t)); if (nInput > 1) { rstrcpy (rodsPathInp->destPath->inPath, argv[argc - 1], MAX_NAME_LEN); } else { rstrcpy (rodsPathInp->destPath->inPath, ".", MAX_NAME_LEN); } if (destFileType <= COLL_OBJ_T) { status = parseRodsPath (rodsPathInp->destPath, myRodsEnv); } else { status = parseLocalPath (rodsPathInp->destPath); } } return (status);}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:68,
示例6: initCondForGet//.........这里部分代码省略......... } }#endif if (rodsArgs->replNum == True) { addKeyVal (&dataObjOprInp->condInput, REPL_NUM_KW, rodsArgs->replNumValue); } if (rodsArgs->resource == True) { if (rodsArgs->resourceString == NULL) { rodsLog (LOG_ERROR, "initCondForPut: NULL resourceString error"); return (USER__NULL_INPUT_ERR); } else { addKeyVal (&dataObjOprInp->condInput, RESC_NAME_KW, rodsArgs->resourceString); } } if (rodsArgs->ticket == True) { if (rodsArgs->ticketString == NULL) { rodsLog (LOG_ERROR, "initCondForPut: NULL ticketString error"); return (USER__NULL_INPUT_ERR); } else { addKeyVal (&dataObjOprInp->condInput, TICKET_KW, rodsArgs->ticketString); } }#ifdef RBUDP_TRANSFER if (rodsArgs->rbudp == True) { /* use -Q for rbudp transfer */ addKeyVal (&dataObjOprInp->condInput, RBUDP_TRANSFER_KW, ""); } if (rodsArgs->veryVerbose == True) { addKeyVal (&dataObjOprInp->condInput, VERY_VERBOSE_KW, ""); } if ((tmpStr = getenv (RBUDP_SEND_RATE_KW)) != NULL) { addKeyVal (&dataObjOprInp->condInput, RBUDP_SEND_RATE_KW, tmpStr); } if ((tmpStr = getenv (RBUDP_PACK_SIZE_KW)) != NULL) { addKeyVal (&dataObjOprInp->condInput, RBUDP_PACK_SIZE_KW, tmpStr); }#else /* RBUDP_TRANSFER */ if (rodsArgs->rbudp == True) { rodsLog (LOG_NOTICE, "initCondForGet: RBUDP_TRANSFER (-d) not supported"); }#endif /* RBUDP_TRANSFER */ if (rodsArgs->purgeCache == True) { addKeyVal (&dataObjOprInp->condInput, PURGE_CACHE_KW, ""); } memset (rodsRestart, 0, sizeof (rodsRestart_t)); if (rodsArgs->restart == True) { int status; status = openRestartFile (rodsArgs->restartFileString, rodsRestart, rodsArgs); if (status < 0) { rodsLogError (LOG_ERROR, status, "initCondForPut: openRestartFile of %s errno", rodsArgs->restartFileString); return (status); } } if (rodsArgs->retries == True && rodsArgs->restart == False && rodsArgs->lfrestart == False) { rodsLog (LOG_ERROR, "initCondForGet: --retries must be used with -X option"); return USER_INPUT_OPTION_ERR; } if (rodsArgs->lfrestart == True) { if (rodsArgs->rbudp == True) { rodsLog (LOG_NOTICE, "initCondForPut: --lfrestart cannot be used with -Q option"); } else { conn->fileRestart.flags = FILE_RESTART_ON; rstrcpy (conn->fileRestart.infoFile, rodsArgs->lfrestartFileString, MAX_NAME_LEN); } } if (rodsArgs->rlock == True) { addKeyVal (&dataObjOprInp->condInput, LOCK_TYPE_KW, READ_LOCK_TYPE); } if (rodsArgs->wlock == True) { rodsLog (LOG_ERROR, "initCondForPut: --wlock not supported, changing it to --rlock"); addKeyVal (&dataObjOprInp->condInput, LOCK_TYPE_KW, READ_LOCK_TYPE); } dataObjOprInp->openFlags = O_RDONLY; return (0);}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:101,
示例7: getCollUtilintgetCollUtil (rcComm_t **myConn, char *srcColl, char *targDir, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp,rodsRestart_t *rodsRestart){ int status = 0; int savedStatus = 0; char srcChildPath[MAX_NAME_LEN], targChildPath[MAX_NAME_LEN];#if 0 int collLen;#else char parPath[MAX_NAME_LEN], childPath[MAX_NAME_LEN];#endif collHandle_t collHandle; collEnt_t collEnt; dataObjInp_t childDataObjInp; rcComm_t *conn; if (srcColl == NULL || targDir == NULL) { rodsLog (LOG_ERROR, "getCollUtil: NULL srcColl or targDir input"); return (USER__NULL_INPUT_ERR); } if (rodsArgs->recursive != True) { rodsLog (LOG_ERROR, "getCollUtil: -r option must be used for getting %s collection", targDir); return (USER_INPUT_OPTION_ERR); } if (rodsArgs->redirectConn == True) { int reconnFlag; if (rodsArgs->reconnect == True) { reconnFlag = RECONN_TIMEOUT; } else { reconnFlag = NO_RECONN; } /* reconnect to the resource server */ rstrcpy (dataObjOprInp->objPath, srcColl, MAX_NAME_LEN); redirectConnToRescSvr (myConn, dataObjOprInp, myRodsEnv, reconnFlag); rodsArgs->redirectConn = 0; /* only do it once */ } conn = *myConn; printCollOrDir (targDir, LOCAL_DIR_T, rodsArgs, dataObjOprInp->specColl);#if 0 status = rclOpenCollection (conn, srcColl, RECUR_QUERY_FG, &collHandle);#else status = rclOpenCollection (conn, srcColl, 0, &collHandle);#endif if (status < 0) { rodsLog (LOG_ERROR, "getCollUtil: rclOpenCollection of %s error. status = %d", srcColl, status); return status; }#if 0 collLen = strlen (srcColl); collLen = getOpenedCollLen (&collHandle);#endif while ((status = rclReadCollection (conn, &collHandle, &collEnt)) >= 0) { if (collEnt.objType == DATA_OBJ_T) { rodsLong_t mySize; mySize = collEnt.dataSize; /* have to save it. May be freed */ #if 0 snprintf (targChildPath, MAX_NAME_LEN, "%s%s/%s", targDir, collEnt.collName + collLen, collEnt.dataName);#else snprintf (targChildPath, MAX_NAME_LEN, "%s/%s", targDir, collEnt.dataName);#endif snprintf (srcChildPath, MAX_NAME_LEN, "%s/%s", collEnt.collName, collEnt.dataName); status = chkStateForResume (conn, rodsRestart, targChildPath, rodsArgs, LOCAL_FILE_T, &dataObjOprInp->condInput, 1); if (status < 0) { /* restart failed */ break; } else if (status == 0) { continue; } status = getDataObjUtil (conn, srcChildPath, targChildPath, mySize, collEnt.dataMode, myRodsEnv, rodsArgs, dataObjOprInp); if (status < 0) { rodsLogError (LOG_ERROR, status, "getCollUtil: getDataObjUtil failed for %s. status = %d", srcChildPath, status); savedStatus = status; if (rodsRestart->fd > 0) break; } else {//.........这里部分代码省略.........
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:101,
示例8: msiDigestMonStat//.........这里部分代码省略......... } if ( strcmp( disk_wght->type, STR_MS_T ) == 0 ) { weight[4] = atoi( ( const char* )disk_wght->inOutStruct ); } else { rodsLogAndErrorMsg( LOG_ERROR, &rsComm->rError, rei->status, "msiDigestMonStat: Unsupported input disk_wght type %s", disk_wght->type ); return rei->status; } if ( strcmp( netin_wght->type, STR_MS_T ) == 0 ) { weight[5] = atoi( ( const char* )netin_wght->inOutStruct ); } else { rodsLogAndErrorMsg( LOG_ERROR, &rsComm->rError, rei->status, "msiDigestMonStat: Unsupported input netin_wght type %s", netin_wght->type ); return rei->status; } if ( strcmp( netout_wght->type, STR_MS_T ) == 0 ) { weight[6] = atoi( ( const char* )netout_wght->inOutStruct ); } else { rodsLogAndErrorMsg( LOG_ERROR, &rsComm->rError, rei->status, "msiDigestMonStat: Unsupported input netout_wght type %s", netout_wght->type ); return rei->status; } totalWeight = 0; for ( i = 0; i < NRESULT; i++ ) { totalWeight += weight[i]; } memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_SL_RESC_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_CREATE_TIME, SELECT_MAX ); genQueryInp.maxRows = MAX_SQL_ROWS; status = rsGenQuery( rsComm, &genQueryInp, &genQueryOut ); if ( NULL == genQueryOut ) { // JMC cppcheck - nullptr rodsLog( LOG_ERROR, "msiDigestMonStat :: &genQueryOut is NULL" ); return rei->status; } if ( status == 0 ) { nresc = genQueryOut->rowCnt; for ( i = 0; i < genQueryOut->attriCnt; i++ ) { for ( j = 0; j < nresc; j++ ) { tResult = genQueryOut->sqlResult[i].value; tResult += j * genQueryOut->sqlResult[i].len; if ( i == 0 ) { rstrcpy( rescList[j], tResult, genQueryOut->sqlResult[i].len ); } if ( i == 1 ) { rstrcpy( timeList[j], tResult, genQueryOut->sqlResult[i].len ); } } } } else { rodsLog( LOG_ERROR, "msiDigestMonStat: Unable to retrieve information / from R_SERVER_LOAD" ); return rei->status; } memset( &genQueryInp, 0, sizeof( genQueryInp ) ); addInxIval( &genQueryInp.selectInp, COL_SL_CPU_USED, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_MEM_USED, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_SWAP_USED, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_RUNQ_LOAD, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_DISK_SPACE, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_NET_INPUT, 1 ); addInxIval( &genQueryInp.selectInp, COL_SL_NET_OUTPUT, 1 ); genQueryInp.maxRows = 1; generalRowInsertInp.tableName = "serverloaddigest"; for ( i = 0; i < nresc; i++ ) { memset( &genQueryInp.sqlCondInp, 0, sizeof( genQueryInp.sqlCondInp ) ); snprintf( condStr1, MAX_NAME_LEN, "= '%s'", rescList[i] ); addInxVal( &genQueryInp.sqlCondInp, COL_SL_RESC_NAME, condStr1 ); snprintf( condStr2, MAX_NAME_LEN, "= '%s'", timeList[i] ); addInxVal( &genQueryInp.sqlCondInp, COL_SL_CREATE_TIME, condStr2 ); status = rsGenQuery( rsComm, &genQueryInp, &genQueryOut ); if ( status == 0 ) { loadFactor = 0; for ( j = 0; j < genQueryOut->attriCnt; j++ ) { tResult = genQueryOut->sqlResult[j].value; loadFactor += atoi( tResult ) * weight[j]; } loadFactor = loadFactor / totalWeight; generalRowInsertInp.arg1 = rescList[i]; snprintf( loadStr, MAX_NAME_LEN, "%i", loadFactor ); generalRowInsertInp.arg2 = loadStr; rc = rsGeneralRowInsert( rsComm, &generalRowInsertInp ); if ( rc != 0 ) { rodsLog( LOG_ERROR, "msiDigestMonStat: Unable to ingest/ information into from R_SERVER_LOAD_DIGEST table" ); } }
开发者ID:dthain,项目名称:irods,代码行数:101,
示例9: myS3InitintmyS3Init (void){ int status = -1; char *tmpPtr; if (S3Initialized) return 0; S3Initialized = 1;#ifdef libs3_3_1_4 if ((status = S3_initialize ("s3", S3_INIT_ALL)) != S3StatusOK) {#else if ((status = S3_initialize ("s3", S3_INIT_ALL, NULL)) != S3StatusOK) {#endif status = myS3Error (status, S3_INIT_ERROR); } bzero (&S3Auth, sizeof (S3Auth)); if ((tmpPtr = getenv("S3_ACCESS_KEY_ID")) != NULL) { rstrcpy (S3Auth.accessKeyId, tmpPtr, MAX_NAME_LEN); if ((tmpPtr = getenv("S3_SECRET_ACCESS_KEY")) != NULL) { rstrcpy (S3Auth.secretAccessKey, tmpPtr, MAX_NAME_LEN); return 0; } } if ((status = readS3AuthInfo ()) < 0) { rodsLog (LOG_ERROR, "initHpssAuth: readHpssAuthInfo error. status = %d", status); return status; } return status;}intreadS3AuthInfo (void){ FILE *fptr; char s3AuthFile[MAX_NAME_LEN]; char inbuf[MAX_NAME_LEN]; int lineLen, bytesCopied; int linecnt = 0; snprintf (s3AuthFile, MAX_NAME_LEN, "%-s/%-s", getConfigDir(), S3_AUTH_FILE); fptr = fopen (s3AuthFile, "r"); if (fptr == NULL) { rodsLog (LOG_ERROR, "readS3AuthInfo: open S3_AUTH_FILE file %s err. ernro = %d", s3AuthFile, errno); return (SYS_CONFIG_FILE_ERR); } while ((lineLen = getLine (fptr, inbuf, MAX_NAME_LEN)) > 0) { char *inPtr = inbuf; if (linecnt == 0) { while ((bytesCopied = getStrInBuf (&inPtr, S3Auth.accessKeyId, &lineLen, LONG_NAME_LEN)) > 0) { linecnt ++; break; } } else if (linecnt == 1) { while ((bytesCopied = getStrInBuf (&inPtr, S3Auth.secretAccessKey, &lineLen, LONG_NAME_LEN)) > 0) { linecnt ++; break; } } } if (linecnt != 2) { rodsLog (LOG_ERROR, "readS3AuthInfo: read %d lines in S3_AUTH_FILE file", linecnt); return (SYS_CONFIG_FILE_ERR); } return 0;}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:81,
示例10: getListOfRescint getListOfResc( rsComm_t *rsComm, char serverList[MAX_VALUE][MAX_NAME_LEN], int nservers, monInfo_t monList[MAX_NSERVERS], int *nlist ) { /********************************************************** * search in the database, the list of resources with * * their associated server. If config file exist, restrict * * the list to serverList * ***********************************************************/ int i, j, k, index[MAX_NSERVERS], l, status; genQueryInp_t genQueryInp; genQueryOut_t *genQueryOut = NULL; char condStr[MAX_NAME_LEN]; memset( &genQueryInp, 0, sizeof( genQueryInp_t ) ); memset( &index, -1, MAX_NSERVERS * sizeof( int ) ); genQueryInp.maxRows = MAX_SQL_ROWS; //clearGenQueryInp( &genQueryInp ); addInxIval( &genQueryInp.selectInp, COL_R_LOC, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_RESC_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_TYPE_NAME, 1 ); addInxIval( &genQueryInp.selectInp, COL_R_VAULT_PATH, 1 ); addInxVal( &genQueryInp.sqlCondInp, COL_R_LOC, "!='EMPTY_RESC_HOST'" ); addInxVal( &genQueryInp.sqlCondInp, COL_R_VAULT_PATH, "!='EMPTY_RESC_PATH'" ); snprintf( condStr, MAX_NAME_LEN, "!='%s'", BUNDLE_RESC ); addInxVal( &genQueryInp.sqlCondInp, COL_R_RESC_NAME, condStr ); status = rsGenQuery( rsComm, &genQueryInp, &genQueryOut ); if ( status < 0 ) { irods::log( ERROR( status, "rsGenQuery failed." ) ); } if ( genQueryOut->rowCnt > 0 ) { l = 0; for ( i = 0; i < genQueryOut->attriCnt; i++ ) { for ( j = 0; j < genQueryOut->rowCnt; j++ ) { char *tResult; tResult = genQueryOut->sqlResult[i].value; tResult += j * genQueryOut->sqlResult[i].len; switch ( i ) { case 0: if ( nservers >= 0 ) { for ( k = 0; k < nservers; k++ ) { if ( strcmp( serverList[k], tResult ) == 0 ) { index[j] = l; l++; } } } else { index[j] = l; l++; } if ( index[j] != -1 ) { rstrcpy( monList[index[j]].serverName, tResult, LONG_NAME_LEN ); } break; case 1: if ( index[j] != -1 ) { rstrcpy( monList[index[j]].rescName, tResult, MAX_NAME_LEN ); } break; case 2: if ( index[j] != -1 ) { rstrcpy( monList[index[j]].rescType, tResult, LONG_NAME_LEN ); } break; case 3: if ( index[j] != -1 ) { rstrcpy( monList[index[j]].vaultPath, tResult, LONG_NAME_LEN ); } break; } } } ( *nlist ) = l; clearGenQueryInp( &genQueryInp ); freeGenQueryOut( &genQueryOut ); return 0; } return -1;}
开发者ID:dthain,项目名称:irods,代码行数:80,
示例11: msiServerMonPerf/** * /fn msiServerMonPerf (msParam_t *verb, msParam_t *ptime, ruleExecInfo_t *rei) * * /brief This microservice monitors the servers' activity and performance. * * /module core * * /since pre-2.1 * * /author Jean-Yves Nief * /date 2009-06 * * /note This microservice monitors the servers' activity and performance * for CPU, network, memory and more. It retrieves the list of servers * to monitor from the MON_CFG_FILE if it exists, or the iCAT if the * configuration file does not exist. * * /note The MON_PERF_SCRIPT is executed on each host. The result is put * in the OUTPUT_MON_PERF file and will also be put in the iCAT in the * near future. * * /usage See clients/icommands/test/rules3.0/ and https://wiki.irods.org/index.php/Resource_Monitoring_System * * /param[in] verb - a msParam of type STR_MS_T defining verbose mode: * /li "default" - not verbose * /li "verbose" - verbose mode * /param[in] ptime - a msParam of type STR_MS_T defining probe time * in seconds. "default" is equal to 10 seconds. * /param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * /DolVarDependence none * /DolVarModified none * /iCatAttrDependence none * /iCatAttrModified resource status flag, resource free space available, table R_SERVER_LOAD * /sideeffect none * * /return integer * /retval 0 upon success * /pre N/A * /post N/A * /sa N/A **/int msiServerMonPerf( msParam_t *verb, msParam_t *ptime, ruleExecInfo_t *rei ) { char line[MAX_VALUE], *verbosity; char serverList[MAX_VALUE][MAX_NAME_LEN]; char cmd[MAX_NAME_LEN]; /* cmd => name of the Perl script */ char probtime[LEN_SECONDS], measTime[LEN_SECONDS]; FILE *filein; /* file pointers */ const char *delim = " /n"; char valinit[MAX_NAME_LEN] = ""; char val[MAX_NAME_LEN] = ""; /* val => arguments for the script */ int check, i, indx, j, looptime, maxtime, nresc, nservers, thrCount, threadsNotfinished; const char *probtimeDef = "10"; /* default value used by the monitoring script for the amount of time for this measurement (in s) */ rsComm_t *rsComm; monInfo_t rescList[MAX_NSERVERS]; thrInp_t *thrInput; int addPathToArgv = 0; char *hintPath = ""; RE_TEST_MACRO( " Calling msiServerMonPerf" ) /* the above line is needed for loop back testing using irule -i option */ rsComm = rei->rsComm; if ( verb->inOutStruct != NULL ) { verbosity = ( char * ) verb->inOutStruct; if ( strcmp( verbosity, "verbose" ) == 0 ) { strcat( valinit, "-v " ); } } strcat( valinit, " -t " ); strncpy( probtime, ( char * ) ptime->inOutStruct, LEN_SECONDS ); if ( atoi( probtime ) > 0 ) { strcat( valinit, probtime ); strncpy( measTime, probtime, LEN_SECONDS ); } else { strcat( valinit, probtimeDef ); strncpy( measTime, probtimeDef, LEN_SECONDS ); } rstrcpy( val, "", MAX_NAME_LEN ); /* read the config file or the iCAT to know the servers list to monitor */ nresc = 0; nservers = -1; /* nservers = -1, no config file available, consider all ressources for the monitoring */ /* nservers >= 0, config file available, consider all resources hosted on the list of servers */ if ( ( filein = fopen( MON_CFG_FILE, "r" ) ) != NULL ) { i = 0; while ( fgets( line, sizeof line, filein ) != NULL ) { /* for each line of the file */ /* if begin of line = # => ignore */ if ( line[0] != '#' ) {//.........这里部分代码省略.........
开发者ID:dthain,项目名称:irods,代码行数:101,
示例12: _ifuseFileCacheWriteint _ifuseFileCacheWrite( fileCache_t *fileCache, char *buf, size_t size, off_t offset ) { int status, myError; openedDataObjInp_t dataObjWriteInp; bytesBuf_t dataObjWriteInpBBuf; iFuseConn_t *conn; bzero( &dataObjWriteInp, sizeof( dataObjWriteInp ) ); /* lseek to the right offset in case this cache is share by multiple descs */ status = _iFuseFileCacheLseek( fileCache, offset ); if ( status < 0 ) { if ( ( myError = getErrno( status ) ) > 0 ) { return -myError; } else { return -ENOENT; } } if ( fileCache->state == NO_FILE_CACHE ) { /* no file cache */ dataObjWriteInpBBuf.buf = ( void * ) buf; dataObjWriteInpBBuf.len = size; dataObjWriteInp.l1descInx = fileCache->iFd; dataObjWriteInp.len = size; conn = getAndUseConnByPath( fileCache->localPath, &status ); status = rcDataObjWrite( conn->conn, &dataObjWriteInp, &dataObjWriteInpBBuf ); unuseIFuseConn( conn ); if ( status < 0 ) { if ( ( myError = getErrno( status ) ) > 0 ) { return -myError; } else { return -ENOENT; } } else if ( status != ( int ) size ) { rodsLog( LOG_ERROR, "ifuseWrite: IFuseDesc[descInx].conn for %s is NULL", fileCache->localPath ); return -ENOENT; } fileCache->offset += status; if ( fileCache->offset > fileCache->fileSize ) { fileCache->fileSize = fileCache->offset; } } else { status = write( fileCache->iFd, buf, size ); if ( status < 0 ) { return errno ? ( -1 * errno ) : -1; } fileCache->offset += status; if ( fileCache->offset > fileCache->fileSize ) { fileCache->fileSize = fileCache->offset; } if ( fileCache->offset >= MAX_NEWLY_CREATED_CACHE_SIZE ) { _iFuseFileCacheFlush( fileCache ); fileCache->iFd = 0; /* reopen file */ dataObjInp_t dataObjOpenInp; memset( &dataObjOpenInp, 0, sizeof( dataObjOpenInp ) ); rstrcpy( dataObjOpenInp.objPath, fileCache->objPath, MAX_NAME_LEN ); dataObjOpenInp.openFlags = O_RDWR; int status; conn = getAndUseConnByPath( fileCache->localPath, &status ); status = rcDataObjOpen( conn->conn, &dataObjOpenInp ); unuseIFuseConn( conn ); if ( status < 0 ) { rodsLog( LOG_ERROR, "iFuseWrite: rcDataObjOpen of %s error. status = %d", fileCache->objPath, status ); return -ENOENT; } fileCache->iFd = status; } } return status;}
开发者ID:bpow,项目名称:irods,代码行数:80,
示例13: _findOldestCachestatic int_findOldestCache(const char *path, char *oldCachePath, struct stat *oldStatbuf) { int status; DIR *dir = NULL; char filepath[MAX_NAME_LEN]; char tempPath[MAX_NAME_LEN]; struct stat tempStatBuf; char oldestCachePath[MAX_NAME_LEN]; struct stat oldestStatBuf; struct dirent *entry; struct stat statbuf; memset(oldestCachePath, 0, MAX_NAME_LEN); memset(&oldestStatBuf, 0, sizeof(struct stat)); dir = opendir(path); if (dir != NULL) { while ((entry = readdir(dir)) != NULL) { if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { continue; } snprintf(filepath, MAX_NAME_LEN, "%s/%s", path, entry->d_name); if (!stat(filepath, &statbuf)) { // has entry if (S_ISDIR(statbuf.st_mode)) { // directory status = _findOldestCache(filepath, tempPath, &tempStatBuf); if (status == 0) { if (strlen(oldestCachePath) == 0) { // just set rstrcpy (oldestCachePath, tempPath, MAX_NAME_LEN); memcpy (&oldestStatBuf, &tempStatBuf, sizeof(struct stat)); } else { // compare if(oldestStatBuf.st_atime > tempStatBuf.st_atime) { rstrcpy (oldestCachePath, tempPath, MAX_NAME_LEN); memcpy (&oldestStatBuf, &tempStatBuf, sizeof(struct stat)); } } } } else { // file if (strlen(oldestCachePath) == 0) { // just set rstrcpy (oldestCachePath, filepath, MAX_NAME_LEN); memcpy (&oldestStatBuf, &statbuf, sizeof(struct stat)); } else { // compare if(oldestStatBuf.st_atime > statbuf.st_atime) { rstrcpy (oldestCachePath, filepath, MAX_NAME_LEN); memcpy (&oldestStatBuf, &statbuf, sizeof(struct stat)); } } } } } closedir(dir); } if (strlen(oldestCachePath) == 0) { return -1; } rstrcpy (oldCachePath, oldestCachePath, MAX_NAME_LEN); memcpy (oldStatbuf, &oldestStatBuf, sizeof(struct stat)); return (0);}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:70,
示例14: _downloadstatic int_download(const char *path, struct stat *stbufIn) { int status; rcComm_t *conn; rodsPathInp_t rodsPathInp; rErrMsg_t errMsg; char preloadCachePath[MAX_NAME_LEN]; char preloadCacheWorkPath[MAX_NAME_LEN]; // set path for getUtil status = _getCachePath(path, preloadCachePath); if(status < 0) { rodsLogError(LOG_ERROR, status, "_download: _getCachePath error."); rodsLog (LOG_ERROR, "_download: failed to get cache path - %s", path); return status; } status = _getCacheWorkPath(path, preloadCacheWorkPath); if(status < 0) { rodsLogError(LOG_ERROR, status, "_download: _getCacheWorkPath error."); rodsLog (LOG_ERROR, "_download: failed to get cache work path - %s", path); return status; } rodsLog (LOG_DEBUG, "_download: download %s to %s", path, preloadCachePath); // set src path memset( &rodsPathInp, 0, sizeof( rodsPathInp_t ) ); addSrcInPath( &rodsPathInp, (char*)path ); status = parseRodsPath (&rodsPathInp.srcPath[0], PreloadRodsEnv); if(status < 0) { rodsLogError(LOG_ERROR, status, "_download: parseRodsPath error."); return status; } // set dest path rodsPathInp.destPath = ( rodsPath_t* )malloc( sizeof( rodsPath_t ) ); memset( rodsPathInp.destPath, 0, sizeof( rodsPath_t ) ); rstrcpy( rodsPathInp.destPath->inPath, preloadCacheWorkPath, MAX_NAME_LEN ); status = parseLocalPath (rodsPathInp.destPath); if(status < 0) { rodsLogError(LOG_ERROR, status, "_download: parseLocalPath error."); return status; } // Connect conn = rcConnect (PreloadRodsEnv->rodsHost, PreloadRodsEnv->rodsPort, PreloadRodsEnv->rodsUserName, PreloadRodsEnv->rodsZone, RECONN_TIMEOUT, &errMsg); if (conn == NULL) { rodsLog (LOG_ERROR, "_download: error occurred while connecting to irods"); return -EPIPE; } // Login if (strcmp (PreloadRodsEnv->rodsUserName, PUBLIC_USER_NAME) != 0) { status = clientLogin(conn); if (status != 0) { rodsLogError(LOG_ERROR, status, "_download: ClientLogin error."); rcDisconnect(conn); return status; } } // make dir prepareDir(preloadCachePath); // Preload rodsLog (LOG_DEBUG, "_download: download %s", path); status = getUtil (&conn, PreloadRodsEnv, PreloadRodsArgs, &rodsPathInp); rodsLog (LOG_DEBUG, "_download: complete downloading %s", path); // Disconnect rcDisconnect(conn); if(status < 0) { rodsLogError(LOG_ERROR, status, "_download: getUtil error."); return status; } // be careful when using Lock LOCK(PreloadLock); status = _completeDownload(preloadCacheWorkPath, preloadCachePath, stbufIn); if(status < 0) { rodsLogError(LOG_ERROR, status, "_download: _completeDownload error."); UNLOCK(PreloadLock); return status; } UNLOCK(PreloadLock); return 0;}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:90,
示例15: rsSendXmsgintrsSendXmsg (rsComm_t *rsComm, sendXmsgInp_t *sendXmsgInp){ int status, i; ticketMsgStruct_t *ticketMsgStruct = NULL; irodsXmsg_t *irodsXmsg; char *miscInfo; status = getTicketMsgStructByTicket (sendXmsgInp->ticket.rcvTicket, &ticketMsgStruct); if (status < 0) { clearSendXmsgInfo (&sendXmsgInp->sendXmsgInfo); return status; } /* match sendTicket */ if (ticketMsgStruct->ticket.sendTicket != sendXmsgInp->ticket.sendTicket) { /* unmatched sendTicket */ rodsLog (LOG_ERROR, "rsSendXmsg: sendTicket mismatch, input %d, in cache %d", sendXmsgInp->ticket.sendTicket, ticketMsgStruct->ticket.sendTicket); return (SYS_UNMATCHED_XMSG_TICKET); } /* added by Raja Jun 30, 2010 for dropping and clearing a messageStream */ miscInfo = sendXmsgInp->sendXmsgInfo.miscInfo; if (miscInfo != NULL && strlen(miscInfo) > 0) { if(!strcmp(miscInfo,"CLEAR_STREAM")) { i = clearAllXMessages(ticketMsgStruct); return(i); } else if (!strcmp(miscInfo,"DROP_STREAM")) { if(sendXmsgInp->ticket.rcvTicket > 5) { i = clearAllXMessages(ticketMsgStruct); if (i < 0) return (i); i = rmTicketMsgStructFromHQue (ticketMsgStruct, (ticketHashQue_t *) ticketMsgStruct->ticketHashQue); return(i); } } else if (!strcmp(miscInfo,"ERASE_MESSAGE")) { /* msgNumber actually is the sequence Number in the queue*/ i = clearOneXMessage(ticketMsgStruct, sendXmsgInp->sendXmsgInfo.msgNumber); return(i); } } /* create a irodsXmsg_t */ irodsXmsg = (irodsXmsg_t*)calloc (1, sizeof (irodsXmsg_t)); irodsXmsg->sendXmsgInfo = (sendXmsgInfo_t*)calloc (1, sizeof (sendXmsgInfo_t)); *irodsXmsg->sendXmsgInfo = sendXmsgInp->sendXmsgInfo; irodsXmsg->sendTime = time (0); /* rstrcpy (irodsXmsg->sendUserName, rsComm->clientUser.userName, NAME_LEN);*/ snprintf(irodsXmsg->sendUserName,NAME_LEN,"%[email C++ rstrip函数代码示例 C++ rstr_release函数代码示例
|