//--------------------------------------------------------------------- // put a local file --> remote bool Server::cmdPut(bstring const & localName, bstring const & remotePath, bool exists) { DBGPRINT(("put '%s' '%s' %b\r\n", localName.c_str(), remotePath.c_str(), exists)); bstring cmd = bstring(exists ? TEXT("reput \"") : TEXT("put \"")) + localName + TEXT("\" \"") + remotePath + TEXT("\""); if (!doCommand(cmd)) return false; FILETIME ft; HANDLE hFile = CreateFile(localName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile == (HANDLE)HFILE_ERROR) return true; // copy succeeded GetFileTime(hFile, 0, 0, &ft); long fsHigh = 0; long fsLow = SetFilePointer(hFile, 0, &fsHigh, FILE_END); CloseHandle(hFile); bstring chmod = TEXT("----"); if (defChMod.length() > 0 || exeChMod.length() > 0) { chmod = defChMod; size_t ldot = remotePath.find_last_of('.'); if (ldot != (size_t)-1) { bstring x = remotePath.substr(ldot); std::map<bstring, bstring>::iterator i = exeExtensions.find(x); if (i != exeExtensions.end()) chmod = exeChMod; } if (chmod.length() > 0) { cmd = bstring(TEXT("chmod ")) + chmod + TEXT(" \"") + remotePath + TEXT("\""); doCommand(cmd); } } // fake update the directory insertFile(remotePath, &ft, fsLow, fsHigh, '-', chmod); // we cannot set the file time if (disableMtime) return true; // if setting the mtime failes, do not try it again if (!this->cmdMtime(remotePath, &ft)) disableMtime = true; // put already succeeded. return true; }
//--------------------------------------------------------------------- // get remote content and store it into the dir cache bool Server::cmdLs(bstring const & remotePath) { Guard guard(this); if (!guard.isConnected()) return false; bstring cmd = bstring(TEXT("ls \"")) + remotePath + TEXT('"'); my_fxp_names * cds = guard.mapper->getCurrentDirStruct(); cds->nnames = 0; cds->names = 0; if (!doCommand(cmd)) return false; if (!cds->names) return false; my_fxp_names * ndir = (my_fxp_names *) malloc(sizeof(my_fxp_names)); ndir->names = (fxp_name **)malloc(sizeof(fxp_name*) * cds->nnames); ndir->nnames = cds->nnames; for (int j = 0; j < ndir->nnames; ++j) { fxp_name * fn = ndir->names[j] = (fxp_name *)malloc(sizeof(fxp_name)); fxp_name * cn = cds->names[j]; fn->attrs = cn->attrs; fn->filename = bstrdup(cn->filename); fn->longname = strdup(cn->longname); } guard.mapper->freeCurrentDirStruct(); updateDirCache(remotePath, ndir); return true; }
static void initVersion(void) { if (_version != (char *)(0)) return; switch (_phaseOfRelease) { case POR_DEVWORK: _version = bgprintf(strlen((DEV_STRARG)_workingCopy) + 64, "%s's latest development", _workingCopy); break; case POR_DEV: _version = bstring("Development"); break; case POR_MAINTWORK: _version = bgprintf(strlen((DEV_STRARG)_workingCopy) + 64, "%s's latest maintenance of Release %d", _workingCopy, _majorRelease); break; case POR_MAINT: _version = bgprintf(64, "Maintenance of Release %d", _majorRelease); break; case POR_ALPHA: _version = bgprintf(64, "Release %d alpha", _majorRelease); break; case POR_BETA: _version = bgprintf(64, "Release %d beta %0*d", _majorRelease, 100>_minorRelease?2:4, _minorRelease); break; case POR_PROD: if( strlen(_workingCopy) ) _version = bgprintf(64, "%s %d.%0*d",_workingCopy, _majorRelease, 100>_minorRelease?2:4, _minorRelease); else _version = bgprintf(64, "Release %d.%0*d", _majorRelease, 100>_minorRelease?2:4, _minorRelease); break; case POR_OFFTRACK: if (_majorRelease) _version = bgprintf(strlen((DEV_STRARG)_workingCopy) + 64, "%s's off-track version of Release %d", _workingCopy, _majorRelease); else _version = bgprintf(strlen((DEV_STRARG)_workingCopy) + 64, "%s's off-track version of Development Release", _workingCopy); break; default: Exit(1, "PHASE_OF_RELEASE == %d, which is invalid\n", _phaseOfRelease); } return; }
bstring Action::identifier () const { ::BSTR value = 0; const com::Result result = ptr()->get_Id(&value); if ( result.bad() ) { UNCHECKED_COM_ERROR(IAction, get_Id, result); } return (bstring(value)); }
//--------------------------------------------------------------------- // create a remote folder bool Server::cmdMkDir(bstring const & remotePath) { bstring cmd = bstring(TEXT("mkdir \"")) + remotePath + TEXT("\""); if (!doCommand(cmd)) return false; // fake update the directory insertFile(remotePath, 0, 0, 0, 'd'); return true; }
//--------------------------------------------------------------------- // remove a remote folder bool Server::cmdRmDir(bstring const & remotePath) { bstring path; splitPath(path, remotePath); invalidateDirContent(path); bstring cmd = bstring(TEXT("rmdir \"")) + remotePath + TEXT("\""); if (!doCommand(cmd)) return false; freeFn(removeFile(remotePath)); return true; }
static void mstring( BUFFER *bptr, ORD row, ORD col, ATTR attr, const char __FAR *string, int len ) /**************************************************************/ { SAREA area; bstring( bptr, row, col, attr, string, len ); area.row = row; area.col = col; area.height = 1; area.width = len; physupdate( &area ); }
//--------------------------------------------------------------------- // get a remote file -> local bool Server::cmdGet(bstring const & remotePath, bstring const & localName, bool exists) { DBGPRINT(("get '%s' '%s' %b\r\n", remotePath.c_str(), localName.c_str(), exists)); bstring cmd = bstring(exists ? TEXT("reget \"") : TEXT("get \"")) + remotePath + TEXT("\" \"") + localName + TEXT("\""); if (!doCommand(cmd)) return false; FILETIME ft; fxp_attrs * attr = currentMapper->getLastAttr(); if (UnixTimeToFileTime(attr->mtime, &ft)) { HANDLE hf = CreateFile(localName.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); SetFileTime(hf, &ft, &ft, &ft); CloseHandle(hf); } return true; }
static void initDefaultATREE(C *argv0) { if (_defaultATREE != (char *)(0)) return; { /* Try to set ATREE by argv[0] */ int i; C *s, *st, ss[]={"/lib/s.+"}; if(NULL == strchr(argv0,'/')) st=(C *)searchPATH(argv0); else st=strdup(argv0); s=(C *)malloc( (strlen(st)+strlen(ss)+1) * sizeof(C) ); strcpy(s,st); free(st); if ( s && s[0]=='/' ){ /* should be fully qualified */ for(i=strlen(s)-1;i;i--) {if(s[i]=='/') break;} if(0==strncmp(&s[MAX(0,i-4)],"/bin",4)) { s[MAX(0,i-4)]='\0'; strcat(s,ss); if (!unloadable(s,R_OK)){ /* Look for ATREE/lib/s.+ */ s[MAX(0,i-4)]='\0'; _defaultATREE = strdup(s); free(s); return; } } } if(s) free(s); } switch (_phaseOfRelease) { case POR_DEVWORK: case POR_DEV: case POR_MAINTWORK: case POR_MAINT: case POR_OFFTRACK: case POR_ALPHA: case POR_BETA: case POR_PROD: _defaultATREE = bstring(IMDIR); break; default: Exit(1, "PHASE_OF_RELEASE == %d, which is invalid\n", _phaseOfRelease); } return; }
//--------------------------------------------------------------------- // move a remote file to a remote file bool Server::cmdMove(bstring const & oldRemotePath, bstring const & newRemotePath) { bstring cmd = bstring(TEXT("mv \"")) + oldRemotePath + TEXT("\" \"") + newRemotePath + TEXT("\""); if (!doCommand(cmd)) return false; fxp_name * fn = removeFile(oldRemotePath); if (fn) { FILETIME ft; UnixTimeToFileTime(fn->attrs.mtime, &ft); insertFile(newRemotePath, &ft, fn->attrs.size.lo, fn->attrs.size.hi, fn->longname[0]); freeFn(fn); } else { bstring path; splitPath(path, newRemotePath); invalidateDirContent(path); } return true; }
/////////////////////////////////////////////////////////////////////////// // INIT void NoiseGen::loadSettings() { std::ifstream lfile; lfile.open("settings.txt"); //if file does not exist, save current settings to file if(!lfile.is_open()) { saveSettings(); return; } //clear terrain parameters terrainsegs.clear(); while(!lfile.eof()) { //create line buffer storage and load line into buffer char buf[200]; lfile.getline(buf,200); //if reading a line that is for comments, a return line, a space, or anything like that , just ignore currently //read line if(buf[0] == '#' || buf[0] == '\n' || buf[0] == ' ' || buf[0] == '\0') continue; //create strings to parse line commands and parameters //NOTE : a command starts with : std::string bstring(buf); std::string cmd( bstring.substr(0, bstring.find_first_of(':')) ); std::string param( bstring.substr(bstring.find_first_of(':')+1, bstring.size()-1)); //get commands, then check parameters for given command if(cmd == "IMAGE_SIZE") IMAGE_SIZE = atoi(param.c_str()); else if(cmd == "IMAGE_SCALE") IMAGE_SCALE = atoi(param.c_str()); else if(cmd == "PERSISTENCE") persistence = atof(param.c_str()); else if(cmd == "OCTAVES") octaves = atoi(param.c_str()); else if(cmd == "SCALE") scale = atof(param.c_str()); else if(cmd == "X_POS") xpos = atoi(param.c_str()); else if(cmd == "Y_POS") ypos = atoi(param.c_str()); else if(cmd == "NOISE_MODE") { if(param == "SIMPLEX") N_MODE = SIMPLEX; else if(param == "PERLIN") N_MODE = PERLIN; else N_MODE = 0; } else if(cmd == "TERRAIN_MODE") { if(param == "ON") terrainmode = true; else terrainmode = false; } else if(cmd == "TERRAIN_SEG_VAL") { segment newseg; newseg.value = atoi(param.c_str()); terrainsegs.push_back(newseg); } else if(cmd == "TERRAIN_SEG_COLOR") { //int it = 0; std::string red; std::string green; std::string blue; red = param.substr(0, param.find(',')); param.erase(0, param.find(',')+1 ); green = param.substr(0, param.find(',')); param.erase(0, param.find(',')+1); blue = param; std::cout << "RGB = " << red << "," << green << "," << blue << std::endl; terrainsegs.back().red = atoi(red.c_str()); terrainsegs.back().green = atoi(green.c_str()); terrainsegs.back().blue = atoi(blue.c_str()); } } }
VSCREEN* global uivopen( register VSCREEN *vptr ) /***********************************************/ { register char* box; register ATTR attr; register int priority; register void (_FAR *updatertn)( struct sarea, void * ); register bool okbuffer; register int len; register ORD col; register unsigned int flags; register bool covered; auto SAREA area; okarea( vptr->area ); flags = vptr->flags; area = vptr->area; if( ( flags & V_DIALOGUE ) != 0 ) { if( flags & V_LISTBOX ) { box = (char *)&UiGChar[ UI_SBOX_TOP_LEFT ]; attr = UIData->attrs[ ATTR_NORMAL ]; } else { box = (char *)&UiGChar[ UI_BOX_TOP_LEFT ]; attr = UIData->attrs[ ATTR_DIAL_FRAME ]; } priority = P_DIALOGUE; } else { flags &= ~V_UNBUFFERED; box = (char *)&UiGChar[ UI_SBOX_TOP_LEFT ]; attr = UIData->attrs[ ATTR_FRAME ]; priority = P_VSCREEN; } if( ( flags & V_UNFRAMED ) == 0 ) { (area.row)--; (area.col)--; (area.height) += 2; (area.width) += 2; okarea( area ); } if( ( flags & V_UNBUFFERED ) != 0 ) { priority = P_UNBUFFERED; bfake( &(vptr->window.type.buffer), area.row, area.col ); okbuffer = TRUE; updatertn = NULL; } else { okbuffer = balloc( &(vptr->window.type.buffer), area.height, area.width ); updatertn = (void(*)(struct sarea,void *))update; } if( okbuffer ) { vptr->window.area = area; vptr->window.priority = priority; vptr->window.update = updatertn; vptr->window.parm = vptr; covered = openwindow( &(vptr->window) ); vptr->flags = flags; if( ( flags & V_UNFRAMED ) == 0 ) { if( ( !UIData->no_blowup ) && ( covered == FALSE ) && ( ( flags & V_NO_ZOOM ) == 0 ) ) { blowup( &UIData->screen, area, box, attr ); } area.row = 0; area.col = 0; drawbox( &(vptr->window.type.buffer), area, box, attr, FALSE ); if( vptr->name != NULL ) { #if 0 do not delete this stuff col = 0; len = area.width; bstring( &(vptr->window.type.buffer), 0, col, UIData->attrs[ATTR_CURR_SELECT_DIAL], " ", len ); len = __min( strlen( vptr->name ), area.width ); col = ( area.width - len ) / 2; bstring( &(vptr->window.type.buffer), 0, col, UIData->attrs[ATTR_CURR_SELECT_DIAL], vptr->name, len ); #else len = __min( strlen( vptr->name ), area.width ); col = ( area.width - len ) / 2; bstring( &(vptr->window.type.buffer), 0, col, attr, vptr->name, len ); #endif } bframe( &(vptr->window.type.buffer ) ); } area = vptr->area; area.row = 0; area.col = 0; vptr->open = TRUE; uivfill( vptr, area, UIData->attrs[ ATTR_NORMAL ], ' ' ); uivsetcursor( vptr ); return( vptr ); } return( NULL ); }
bstring Toker::wtext(){ return bstring( &wline[curr_toke.begin],curr_toke.end-curr_toke.begin ); }