void Client::killConn() { if (socket_ == NULL) { throw std::wruntime_error("Client::killConn() - ERROR: " "Socket has not been initialized!"); } zmq_close(socket_); socket_ = NULL; num_open_connections_--; killContext(); }
int cmd_copy(char *rest) { char **argv, *p; int argc, opts, argi; int freeDestFile = 0; struct CopySource *h; /* Initialize options */ optA = optB = optV = optY = 0; /* read the parameters from env */ if ((argv = scanCmdline(getEnv("COPYCMD"), opt_copy, 0, &argc, &opts)) == 0) return 1; freep(argv); /* ignore any parameter from env var */ if((argv = scanCmdline(rest, opt_copy, 0, &argc, &opts)) == 0) return 1; /* scan the trailing '/a' and '/b' options */ while(argc > 0 && isoption(argv[argc - 1])) { p = argv[--argc]; /* argv[] must not be changed */ if(leadOptions(&p, opt_copy1, 0) != E_None) { freep(argv); return 1; } } initContext(); /* Now parse the remaining arguments into the copy file structure */ for(argi = 0; argi < argc; ++argi) if(isoption(p = argv[argi])) { /* infix /a or /b */ if(leadOptions(&p, opt_copy1, 0) != E_None) { killContext(); freep(argv); return 1; } /* Change the flags of the previous argument */ if(lastApp) lastApp->flags = cpyFlags(); } else { /* real argument */ if(*p == '+') { /* to previous argument */ appendToFile = 1; while(*++p == '+'); if(!*p) continue; } if(!addSource(p)) { killContext(); freep(argv); return 1; } } if(appendToFile) { error_trailing_plus(); killContext(); freep(argv); return 1; } if(!last) { /* Nothing to do */ error_nothing_to_do(); killContext(); freep(argv); return 1; } assert(head); /* Now test if a destination was specified */ if(head != last && !last->app) { /* Yeah */ destFile = dfnexpand(last->fnam, 0); if(!destFile) { error_out_of_memory(); goto errRet; } freeDestFile = 1; h = head; /* remove it from argument list */ while(h->nxt != last) { assert(h->nxt); h = h->nxt; } free(last); (last = h)->nxt = 0; p = strchr(destFile, '\0') - 1; if(*p == '\\' || *p == '/') /* must be a directory */ destIsDir = 1; else destIsDir = dfnstat(destFile) & DFN_DIRECTORY; } else { /* Nay */ destFile = "."; destIsDir = 1; } /* Now copy the files */ h = head; while(copyFiles(h) && (h = h->nxt) != 0); if(freeDestFile) free(destFile); errRet: killContext(); freep(argv); return 0; }