本文整理汇总了C++中rcDisconnect函数的典型用法代码示例。如果您正苦于以下问题:C++ rcDisconnect函数的具体用法?C++ rcDisconnect怎么用?C++ rcDisconnect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rcDisconnect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rcReconnect
int
rcReconnect( rcComm_t **conn, char *newHost, rodsEnv *myEnv, int reconnFlag ) {
int status;
rcComm_t *newConn = NULL;
rErrMsg_t errMsg;
bzero( &errMsg, sizeof( errMsg ) );
newConn = rcConnect( newHost, myEnv->rodsPort, myEnv->rodsUserName,
myEnv->rodsZone, reconnFlag, &errMsg );
if ( newConn != NULL ) {
status = clientLogin( newConn );
if ( status != 0 ) {
rcDisconnect( newConn );
return status;
}
rcDisconnect( *conn );
*conn = newConn;
return 0;
}
else {
return errMsg.status;
}
}
示例2: choose_server
void choose_server(rcComm_t **cn, char *host, rodsEnv *env, int verb) {
if (verb) {
fprintf(stderr, "Chosen server is: %s\n", host);
}
if (host && strcmp(host, THIS_ADDRESS)) {
int stat;
rErrMsg_t err_msg;
rcComm_t *new_cn = NULL;
new_cn = rcConnect(host, env->rodsPort, env->rodsUserName,
env->rodsZone, 0, &err_msg);
if (!new_cn) {
fprintf(stderr, "Error: rcReconnect failed with status %d. Continuing with original server.\n", err_msg.status);
return;
}
#if IRODS_VERSION_INTEGER && IRODS_VERSION_INTEGER >= 4001008
stat = clientLogin(new_cn, "", "");
#else
stat = clientLogin(new_cn);
#endif
if (stat < 0) {
rcDisconnect(new_cn);
error_and_exit(*cn, "Error: clientLogin failed with status %d:%s\n", stat, get_irods_error_name(stat, verb));
} else {
rcDisconnect(*cn);
*cn = new_cn;
}
}
}
示例3: main
int main () {
rodsEnv myEnv;
int status = getRodsEnv( &myEnv );
if ( status != 0 ) {
printf( "getRodsEnv failed.\n" );
return -1;
}
rErrMsg_t errMsg;
rcComm_t* conn = rcConnect( myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 1, &errMsg );
/* Test that irods errors are compile time constants in c */
switch (0) {
case SYS_NO_HANDLER_REPLY_MSG: break;
default: break;
}
if ( ! conn ) {
printf( "rcConnect failed\n");
return -1;
}
else {
printf( "Success!\n");
rcDisconnect( conn );
}
return 0;
}
示例4: cleanUpAndExit
int
cleanUpAndExit() {
sendXmsgInp_t sendXmsgInp;
xmsgTicketInfo_t xmsgTicketInfo;
int status;
char buf[] = "QUIT";
memset( &xmsgTicketInfo, 0, sizeof( xmsgTicketInfo ) );
memset( &sendXmsgInp, 0, sizeof( sendXmsgInp ) );
xmsgTicketInfo.sendTicket = 4;
xmsgTicketInfo.rcvTicket = 4;
xmsgTicketInfo.flag = 1;
sendXmsgInp.ticket = xmsgTicketInfo;
snprintf( sendXmsgInp.sendAddr, NAME_LEN, "%s:%i", myHostName, getpid() );
sendXmsgInp.sendXmsgInfo.numRcv = 1;
strcpy( sendXmsgInp.sendXmsgInfo.msgType, "QUIT" );
sendXmsgInp.sendXmsgInfo.msg = buf;
sendXmsgInp.sendXmsgInfo.msgNumber = myMNum;
sendXmsgInp.sendXmsgInfo.miscInfo = strdup( "ERASE_MESSAGE" );
status = rcSendXmsg( conn, &sendXmsgInp );
if ( status < 0 ) {
fprintf( stderr, "rsSendXmsg error for 4. status = %d\n", status );
}
sendIDebugCommand( "quit", "CMSG:QUIT" );
rcDisconnect( conn );
exit( 0 );
}
示例5: ifuseConnect
int
ifuseConnect( iFuseConn_t *iFuseConn, rodsEnv *myRodsEnv ) {
int status = 0;
LOCK_STRUCT( *iFuseConn );
if ( iFuseConn->conn == NULL ) {
rErrMsg_t errMsg;
iFuseConn->conn = rcConnect( myRodsEnv->rodsHost, myRodsEnv->rodsPort,
myRodsEnv->rodsUserName, myRodsEnv->rodsZone, NO_RECONN, &errMsg );
if ( iFuseConn->conn == NULL ) {
/* try one more */
iFuseConn->conn = rcConnect( myRodsEnv->rodsHost, myRodsEnv->rodsPort,
myRodsEnv->rodsUserName, myRodsEnv->rodsZone, NO_RECONN, &errMsg );
if ( iFuseConn->conn == NULL ) {
rodsLogError( LOG_ERROR, errMsg.status,
"ifuseConnect: rcConnect failure %s", errMsg.msg );
UNLOCK_STRUCT( *iFuseConn );
if ( errMsg.status < 0 ) {
return errMsg.status;
}
else {
return -1;
}
}
}
status = clientLogin( iFuseConn->conn );
if ( status != 0 ) {
rcDisconnect( iFuseConn->conn );
iFuseConn->conn = NULL;
}
}
UNLOCK_STRUCT( *iFuseConn );
return status;
}
示例6: return
int RodsConnection::login()
{
int status = 0;
// first of all, we must be connected
if (!this->rodsCommPtr)
return (status);
// login only if not already logged in
if (!this->isReady())
{
this->mutexLock();
// try to authenticate client to the iRODS server
if ((status = clientLogin (this->rodsCommPtr)) != 0)
{
rcDisconnect(this->rodsCommPtr);
this->rodsCommPtr = NULL;
}
this->mutexUnlock();
}
return (status);
}
示例7: disconnRcatHost
int
disconnRcatHost( int rcatType, const char *rcatZoneHint ) {
int status;
rodsServerHost_t *rodsServerHost = NULL;
status = getRcatHost( rcatType, rcatZoneHint, &rodsServerHost );
if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
return status;
}
if ( ( rodsServerHost )->localFlag == LOCAL_HOST ) {
return LOCAL_HOST;
}
if ( rodsServerHost->conn != NULL ) { /* a connection exists */
status = rcDisconnect( rodsServerHost->conn );
rodsServerHost->conn = NULL;
}
if ( status >= 0 ) {
return REMOTE_HOST;
}
else {
return status;
}
}
示例8: testLogin
int testLogin(rsComm_t *rsComm, char *User, char *pw, char *pw1) {
int status, stat2;
rcComm_t *Conn;
rErrMsg_t errMsg;
Conn = rcConnect (myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName,
myEnv.rodsZone, 0, &errMsg);
if (Conn == NULL) {
printf("rcConnect failure");
return -1;
}
#if 0
Conn->clientUser.authInfo.authFlag = 0;
Conn->proxyUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
rstrcpy (Conn->clientUser.userName, privUser, NAME_LEN);
#endif
status = clientLoginWithPassword(Conn, pw1); /* first login as self */
if (status ==0) {
rstrcpy (Conn->clientUser.userName, User,
sizeof Conn->clientUser.userName);
rstrcpy (Conn->clientUser.rodsZone, myEnv.rodsZone,
sizeof Conn->clientUser.rodsZone); /* default to our zone */
status = clientLoginWithPassword(Conn, pw); /* then try other user */
}
stat2 = rcDisconnect(Conn);
return(status);
}
示例9: irodsexit
int
irodsexit(int exitValue) {
int status;
if (debug) printf("irodsexit: %d\n", exitValue);
if (setupFlag>0) {
status = rcDisconnect(Comm);
}
exit(exitValue);
}
示例10: irods_disconnect_
int
irods_disconnect_() {
int status;
if ( debug ) {
printf( "irods_disconnect_" );
}
status = 0;
if ( setupFlag > 0 ) {
status = rcDisconnect( Comm );
}
return status;
}
示例11: error_and_exit
void error_and_exit(rcComm_t *c, const char *msg, ...) {
va_list argp;
va_start(argp, msg);
vfprintf(stderr, msg, argp);
va_end(argp);
if (c) {
rcDisconnect(c);
}
exit(EXIT_FAILURE);
}
示例12: connectToRemoteiRODS
static
int connectToRemoteiRODS(
char* inStr,
rcComm_t** rcComm ) {
rErrMsg_t errMsg;
/*inStr of form: //irods:host[:port][:user[@zone][:pass]]/remotePath
if port is not given default port 1247 is used
if [email protected] is not given ANONYMOUS_USER is used
if pass is not given ANONYMOUS_USER is used
*/
const std::string input( inStr );
boost::smatch matches;
boost::regex expression( "irods:([^:/]+)(:([0-9]+))?" // irods:host[:port]
"(:([^:/@]+)(@([^:/]+))?(:([^/]+))?)?" // [:user[@zone][:pass]]
"/(.*)" ); // /remotePath
try {
const bool matched = boost::regex_match( input, matches, expression );
if ( !matched ) {
return USER_INPUT_FORMAT_ERR;
}
std::string host = matches.str( 1 );
int port = 1247;
if ( !matches.str( 3 ).empty() ) {
port = boost::lexical_cast<int>( matches.str( 3 ) );
}
std::string user( ANONYMOUS_USER );
if ( !matches.str( 5 ).empty() ) {
user = matches.str( 5 );
}
std::string zone = matches.str( 7 );
printf( "MM: host=%s,port=%i,user=%s\n", host.c_str(), port, user.c_str() );
*rcComm = rcConnect( host.c_str(), port, user.c_str(), zone.c_str(), 0, &errMsg );
if ( *rcComm == NULL ) {
return REMOTE_IRODS_CONNECT_ERR;
}
int status = clientLogin( *rcComm );
if ( status != 0 ) {
rcDisconnect( *rcComm );
}
return status;
}
catch ( const boost::bad_lexical_cast& ) {
return INVALID_LEXICAL_CAST;
}
catch ( const boost::exception& ) {
return SYS_INTERNAL_ERR;
}
}
示例13: rsPamAuthRequest
int
rsPamAuthRequest (rsComm_t *rsComm, pamAuthRequestInp_t *pamAuthRequestInp,
pamAuthRequestOut_t **pamAuthRequestOut)
{
rodsServerHost_t *rodsServerHost;
int status;
status = getAndConnRcatHost(rsComm, MASTER_RCAT,
rsComm->clientUser.rodsZone, &rodsServerHost);
if (status < 0) {
return(status);
}
if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
status = _rsPamAuthRequest(rsComm, pamAuthRequestInp,
pamAuthRequestOut);
#else
status = SYS_NO_RCAT_SERVER_ERR;
#endif
}
else {
#ifdef USE_SSL
/* protect the PAM plain text password by
using an SSL connection to the remote ICAT */
status = sslStart(rodsServerHost->conn);
if (status) {
rodsLog(LOG_NOTICE, "rsPamAuthRequest: could not establish SSL connection, status %d",
status);
return(status);
}
#else
rodsLog(LOG_ERROR, "iRODS doesn't include SSL support, required for PAM authentication.");
return SSL_NOT_BUILT_INTO_SERVER;
#endif /* USE_SSL */
status = rcPamAuthRequest(rodsServerHost->conn, pamAuthRequestInp,
pamAuthRequestOut);
#ifdef USE_SSL
sslEnd(rodsServerHost->conn);
#endif
rcDisconnect(rodsServerHost->conn);
rodsServerHost->conn = NULL;
if (status < 0) {
rodsLog(LOG_NOTICE, "rsPamAuthRequest: rcPamAuthRequest to remote server failed, status %d",
status);
}
}
return (status);
}
示例14: irods_init
static int irods_init()
{
kstring_t useragent = { 0, 0, NULL };
struct sigaction pipehandler;
rErrMsg_t err;
int ret, pipehandler_ret;
if (hts_verbose >= 5) rodsLogLevel(hts_verbose);
ret = getRodsEnv(&irods.env);
if (ret < 0) goto error;
// Set iRODS User-Agent, if our caller hasn't already done so.
kputs("htslib/", &useragent);
kputs(hts_version(), &useragent);
(void) setenv(SP_OPTION, useragent.s, 0);
free(useragent.s);
// Prior to iRODS 4.1, rcConnect() (even if it fails) installs its own
// SIGPIPE handler, which just prints a message and otherwise ignores the
// signal. Most actual SIGPIPEs encountered will pertain to e.g. stdout
// rather than iRODS's connection, so we save and restore the existing
// state (by default, termination; or as already set by our caller).
pipehandler_ret = sigaction(SIGPIPE, NULL, &pipehandler);
irods.conn = rcConnect(irods.env.rodsHost, irods.env.rodsPort,
irods.env.rodsUserName, irods.env.rodsZone,
NO_RECONN, &err);
if (pipehandler_ret == 0) sigaction(SIGPIPE, &pipehandler, NULL);
if (irods.conn == NULL) { ret = err.status; goto error; }
if (strcmp(irods.env.rodsUserName, PUBLIC_USER_NAME) != 0) {
#if defined IRODS_VERSION_INTEGER && IRODS_VERSION_INTEGER >= 4000000
ret = clientLogin(irods.conn, NULL, NULL);
#else
ret = clientLogin(irods.conn);
#endif
if (ret != 0) goto error;
}
return 0;
error:
if (irods.conn) { (void) rcDisconnect(irods.conn); }
irods.conn = NULL;
set_errno(ret);
return -1;
}
示例15: disconnectAllSvrToSvrConn
int
disconnectAllSvrToSvrConn() {
rodsServerHost_t *tmpRodsServerHost;
/* check if host exist */
tmpRodsServerHost = ServerHostHead;
while ( tmpRodsServerHost != NULL ) {
if ( tmpRodsServerHost->conn != NULL ) {
rcDisconnect( tmpRodsServerHost->conn );
tmpRodsServerHost->conn = NULL;
}
tmpRodsServerHost = tmpRodsServerHost->next;
}
return 0;
}