GMC_DCL(tp_FilHdr, OrigFilHdr) { tp_LocElm LocElm, LastLocElm; tps_FileName DestFileName; LocElm = NIL; if (!IsSource(DestFilHdr)) { SystemError("Destination of copy must be a source file or directory.\n"); goto done; }/*if*/; FilHdr_HostFN(DestFileName, DestFilHdr, FALSE); if (!IsDirectory_FileName(DestFileName)) { if (IsList(OrigFilHdr)) { SystemError("List objects can only be copied to directories.\n"); goto done; }/*if*/; LocElm = Make_CopyLocElm(OrigFilHdr, DestFilHdr, FilHdr); goto done; }/*if*/; LastLocElm = NIL; Get_CopyList(&LocElm, &LastLocElm, OrigFilHdr, DestFilHdr, FilHdr); Clr_UnionFlags(OrigFilHdr); done:; Set_LocElm(FilHdr, LocElm); }/*Exec_CopyCmd*/
void Socket::socket_receive(char *buff, size_t sz, char *delim, size_t sz_delim) { size_t read = 0; size_t total = 0; char *pos = NULL; bool received_delim = false; bool continue_recv = (total < sz); while (continue_recv){ pos = buff + total; try{ read = recv(this->fd, pos, SIZE_RECEIVE, MSG_NOSIGNAL); if (read < 0){ std::string error_desc = MSG_ERROR_RECV; error_desc += MSG_FD + this->fd; error_desc += strerror(errno); throw SystemError(error_desc, __FILE__, __LINE__); } total += read; //if (total >= sz_delim){ received_delim = (strncmp(delim, pos - sz_delim + 1, sz_delim) != 0); //} continue_recv = (received_delim) && (total < sz); }catch(std::exception &e){ std::string error_desc = MSG_ERROR_RECV; error_desc += MSG_FD + this->fd; error_desc += strerror(errno); throw SystemError(error_desc, __FILE__, __LINE__); } } }
TpSensorDriver::TpSensorDriver(std::string path) : SensorDriver(path) { std::ifstream f(path_); try { f.exceptions(f.failbit | f.badbit); int tmp; unsigned int count = 0; string skip; skip.resize(skip_prefix_.size()); f.exceptions(f.badbit); f.getline(&*skip.begin(), skip_prefix_.size()+1); f.clear(f.rdstate() & ~f.failbit); if (skip == skip_prefix_) skip_bytes_ = f.tellg(); else throw SystemError(path_ + ": Unknown file format."); while (!(f.eof() || f.fail())) { f >> tmp; if (!f.fail()) ++count; } set_num_temps(count); } catch (std::ios_base::failure &e) { string msg = std::strerror(errno); throw SystemError(MSG_SENSOR_INIT(path_) + msg); } }
PipeImpl::PipeImpl() { std::stringstream ss; ss<<"\\\\.\\pipe\\pt-" << GetCurrentProcessId() << '-' << _nameId; DWORD pflags = PIPE_ACCESS_DUPLEX; DWORD access = GENERIC_WRITE; DWORD share = 0; DWORD create = OPEN_EXISTING; DWORD flags = 0; flags = FILE_FLAG_OVERLAPPED; pflags |= FILE_FLAG_OVERLAPPED; HANDLE inputHandle = ::CreateNamedPipe(ss.str().c_str(), pflags, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 256, 256, 1000, NULL ); if (inputHandle == INVALID_HANDLE_VALUE) throw SystemError("Could not create named pipe"); HANDLE outputHandle = ::CreateFile(ss.str().c_str(), access, share, NULL, create, flags, NULL); if(outputHandle == INVALID_HANDLE_VALUE) throw SystemError("Could not open file handle"); _out.open(inputHandle); _in.open(outputHandle); InterlockedIncrement(&_nameId); }
void AtasmartSensorDriver::read_temps() const { SkBool disk_sleeping = false; if (unlikely(dnd_disk && (sk_disk_check_sleep_mode(disk_, &disk_sleeping) < 0))) { string msg = strerror(errno); throw SystemError("sk_disk_check_sleep_mode(" + path_ + "): " + msg); } if (unlikely(disk_sleeping)) { temp_state.add_temp(0); } else { uint64_t mKelvin; double tmp; if (unlikely(sk_disk_smart_read_data(disk_) < 0)) { string msg = strerror(errno); throw SystemError("sk_disk_smart_read_data(" + path_ + "): " + msg); } if (unlikely(sk_disk_smart_get_temperature(disk_, &mKelvin)) < 0) { string msg = strerror(errno); throw SystemError("sk_disk_smart_get_temperature(" + path_ + "): " + msg); } tmp = mKelvin / 1000.0f; tmp -= 273.15f; if (unlikely(tmp > std::numeric_limits<int>::max() || tmp < std::numeric_limits<int>::min())) { throw SystemError(MSG_T_GET(path_) + std::to_string(tmp) + " isn't a valid temperature."); } temp_state.add_temp(tmp); } }
TpFanDriver::TpFanDriver(const std::string &path) : FanDriver(path, 120) { bool ctrl_supported = false; std::fstream f(path_); try { f.exceptions(f.failbit | f.badbit); std::string line; line.resize(256); f.exceptions(f.badbit); while ( f.getline(&*line.begin(), 255)) { if (line.rfind("level:") != string::npos) { // remember initial level, restore it in d'tor initial_state_ = line.substr(line.find_last_of(" \t") + 1); } else if (line.rfind("commands:") != std::string::npos && line.rfind("level <level>") != std::string::npos) { ctrl_supported = true; } } } catch (std::ios_base::failure &e) { string msg = std::strerror(errno); throw SystemError(MSG_FAN_INIT(path_) + msg); } if (!ctrl_supported) throw SystemError(MSG_FAN_MODOPTS); }
///////////////////// // Initializes network bool InitNetworkSystem() { curl_global_init(CURL_GLOBAL_ALL); nlSystemUseChangeLock.startWriteAccess(); bNetworkInited = false; if(!nlInit()) { SystemError("nlInit failed"); nlSystemUseChangeLock.endWriteAccess(); return false; } if(!nlSelectNetwork(NL_IP)) { SystemError("could not select IP-based network"); nlSystemUseChangeLock.endWriteAccess(); return false; } bNetworkInited = true; dnsCache = new ThreadVar<dnsCacheT>(); #ifndef WIN32 //sigignore(SIGPIPE); signal(SIGPIPE, sigpipe_handler); #endif nlSystemUseChangeLock.endWriteAccess(); return true; }
inline void env(const Bytes& variable, const Bytes& value) { Bytes xvalue = env(variable); char* varbuffer = variable.nullstr(); char* valbuffer = value.nullstr(); char* xvalbuffer = xvalue.nullstr(); #if (QUIRINUS_FEATURE_POSIX) int state = 0; state = ::setenv(varbuffer, valbuffer, true); if (state) { state = static_cast<int>(errno); ::setenv(varbuffer, xvalbuffer, true); throw SystemError(state); } #else DWORD state = 0; state = ::SetEnvironmentVariableA(varbuffer, valbuffer); state = ((!state) ? ::GetLastError() : 0); if (state) { state = ::GetLastError(); ::SetEnvironmentVariableA(varbuffer, xvalbuffer); throw SystemError(state); } #endif delete[] varbuffer; delete[] valbuffer; delete[] xvalbuffer; }
ClockImpl::ClockImpl() { //DWORD procAffinity; //DWORD sysAffinity; DWORD_PTR cpuMask = 0x01; #ifndef _WIN32_WCE // HANDLE currentProcessHandle = GetCurrentProcess(); // if( ! GetProcessAffinityMask( currentProcessHandle, &procAffinity, &sysAffinity )) // throw SystemError( PT_ERROR_MSG("GetProcessAffinityMask failed") ); // if( ! SetProcessAffinityMask( currentProcessHandle, 0x01 ) ) // throw SystemError( PT_ERROR_MSG("SetProcessAffinityMask failed") ); DWORD_PTR threadAffinity = SetThreadAffinityMask( GetCurrentThread(), cpuMask ); if( ! threadAffinity ) throw SystemError( PT_ERROR_MSG("SetProcessAffinityMask failed") ); #endif if( ! QueryPerformanceFrequency( &_frequency ) ) throw SystemError( PT_ERROR_MSG("QueryPerformanceFrequency failed") ); #ifndef _WIN32_WCE // if( ! SetProcessAffinityMask( currentProcessHandle, procAffinity ) ) // throw SystemError( PT_ERROR_MSG("SetProcessAffinityMask failed") ); if( ! SetThreadAffinityMask( GetCurrentThread(), threadAffinity ) ) throw SystemError( PT_ERROR_MSG("SetProcessAffinityMask failed") ); #endif }
SessionKey::SessionKey() { // acquire cryptographic provider if (!CryptAcquireContextA(&m_provider.get_ref(), 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) throw SystemError(GetLastError()); // generate session key if (!CryptGenKey(m_provider.get(), CALG_RC2, 0, &m_key.get_ref())) throw SystemError(GetLastError()); }
TcpStream TcpStream::connect(const Ipv6Address& address) { Descriptor fd(socket(AF_INET6, SOCK_STREAM, 0)); if (fd < 0) { throw SystemError("IPv6 socket error"); } if (::connect(fd, address.address(), address.length()) < 0) { throw SystemError("IPv6 connect error"); } return TcpStream(std::move(fd)); }
// static TimePoint Clock::Now() { LARGE_INTEGER freq; if (QueryPerformanceFrequency(&freq) == 0) { throw SystemError("QueryPerformanceFrequency"); } double ns_per_tick = 1E+9 / freq.QuadPart; LARGE_INTEGER count; if (QueryPerformanceCounter(&count) == 0) { throw SystemError("QueryPerformanceCounter"); } return Nanoseconds(ns_per_tick * count.QuadPart); }
void Init_Env(GMC_ARG_VOID) { tps_FileName FileName; boolean Abort; size_t sz; OdinDirName = GetEnv("ODINCACHE"); FORBIDDEN(OdinDirName == NIL); if (!IsDirectory_FileName(OdinDirName)) { SystemError("Odin root <%s> does not exist.\n", OdinDirName); FATALERROR("");}/*if*/; if (OdinDirName[0] != '/') { SystemError("Odin cache pathname <%s> must be absolute.\n", OdinDirName); FATALERROR("");}/*if*/; Set_ModeMask(OdinDirName); sz = snprintf(FileName, MAX_FileName, "%s/FILES", OdinDirName); if (sz >= MAX_FileName) { (void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/FILES\n", MAX_FileName, OdinDirName); exit(1); }/*if*/; CacheDirName = Malloc_Str(FileName); MakeDirFile(&Abort, CacheDirName); if (Abort) FATALERROR("cannot create odin FILES directory"); sz = snprintf(FileName, MAX_FileName, "%s/JOBS", OdinDirName); if (sz >= MAX_FileName) { (void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/JOBS\n", MAX_FileName, OdinDirName); exit(1); }/*if*/; JobsDirName = Malloc_Str(FileName); MakeDirFile(&Abort, JobsDirName); if (Abort) FATALERROR("cannot create odin JOBS directory"); sz = snprintf(FileName, MAX_FileName, "%s/ENV", OdinDirName); if (sz >= MAX_FileName) { (void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/ENV\n", MAX_FileName, OdinDirName); exit(1); }/*if*/; Read_Env(FileName); DumpCore = (GetEnv("DUMPCORE") != NIL); RBS_Cmd = GetEnv("ODIN_RBSCMD"); FORBIDDEN(RBS_Cmd == NIL); ShortCacheNameFlag = (GetEnv("ODIN_SHORTNAMES") != NIL); LocalIPCFlag = (GetEnv("ODIN_LOCALIPC") != NIL); }/*Init_Env*/
BOOL _LoadPythonDLL(HMODULE hmod) { HRSRC hrsrc; char *pBaseAddress; int size; if (!dirname[0]) calc_dirname(hmod); // Try to locate pythonxy.dll as resource in the exe hrsrc = FindResource(hmod, MAKEINTRESOURCE(1), PYTHONDLL); if (hrsrc) { HGLOBAL hgbl = LoadResource(hmod, hrsrc); if (!_load_python(PYTHONDLL, LockResource(hgbl))) { SystemError(GetLastError(), "Could not load python dll"); return FALSE; } // dprintf("Loaded pythondll as RESOURCE\n"); return TRUE; } // try to load pythonxy.dll as bytes at the start of the zipfile pBaseAddress = MapExistingFile(libfilename, &size); if (pBaseAddress) { int res = 0; if (0 == strncmp(pBaseAddress, "<pythondll>", 11)) res = _load_python(PYTHONDLL, pBaseAddress + 11 + sizeof(int)); UnmapViewOfFile(pBaseAddress); if (res) { // dprintf("Loaded pythondll as <pythondll> from %s\n", libfilename); return TRUE; } } // try to load pythonxy.dll from the file system { char buffer[_MAX_PATH + _MAX_FNAME + _MAX_EXT]; snprintf(buffer, sizeof(buffer), "%s\\%s", dirname, PYTHONDLL); if (!_load_python(buffer, NULL)) { SystemError(GetLastError(), "LoadLibrary(pythondll) failed"); SystemError(0, buffer); return FALSE; } // dprintf("Loaded pythondll from file %s\n", buffer); } return TRUE; }
GMC_DCL(tp_FilPrm, FilPrm) { tp_FilHdr ValFilHdr; tp_FilTyp FilTyp; tp_DrvPth DrvPth, DrvPthElm; tp_PrmTypLst PrmTypLst; Writeln(FilDsc, "*?* Possible Parameters :"); Clr_PrmTypMarks(); if (FilPrm == RootFilPrm) { SetFilHdr_PrmTypMarks(FilHdr); WriteMarkedPrmTyps(FilDsc); return; }/*if*/; ValFilHdr = LocHdr_FilHdr(FilPVal_LocHdr(FilPrm_FilPVal(FilPrm))); FilTyp = FTName_FilTyp(FilHdr_Ident(ValFilHdr)); Ret_FilHdr(ValFilHdr); if (FilTyp == ERROR) { return; }/*if*/; if (FilHdr_FilTyp(FilHdr) != FilTyp) { DrvPth = Get_DrvPth(FilHdr, FilTyp); if (DrvPth == ERROR) { SystemError("Cannot derive to <%s>\n", FilTyp_FTName(FilTyp)); return; }/*if*/; for (DrvPthElm = DrvPth; DrvPthElm != NIL; DrvPthElm = DrvPth_Next(DrvPthElm)) { if (DrvPth_DPType(DrvPthElm) == DPT_Drv) { PrmTypLst = DrvPth_PrmTypLst(DrvPthElm); SetPrmTypLst_Marks(PrmTypLst); }/*if*/; }/*for*/; Ret_DrvPth(DrvPth); }/*if*/; WriteMarkedPrmTyps(FilDsc); }/*WritePrmHelp*/
GMC_DCL(tp_FilTyp, ToFilTyp) { tp_DrvPth DrvPth; if (FilHdr == ERROR || InhFilPrm == ERROR || ToFilTyp == ERROR) { Ret_FilHdr(FilHdr); return ERROR; }/*if*/; if (FilHdr_FilTyp(FilHdr) == ToFilTyp) { if (PrecFilPrm != RootFilPrm) { Do_Log("Ignoring parameters of", FilHdr, LOGLEVEL_IgnorePrm); }/*if*/; return FilHdr; }/*if*/; DrvPth = Get_DrvPth(FilHdr, ToFilTyp); if (DrvPth == ERROR) { SystemError("Cannot derive to <%s> from <%s>\n", FilTyp_FTName(ToFilTyp), FilTyp_FTName(FilHdr_FilTyp(FilHdr))); Ret_FilHdr(FilHdr); return ERROR; }/*if*/; FilHdr = Do_DrvPth(FilHdr, InhFilPrm, PrecFilPrm, DrvPth); Ret_DrvPth(DrvPth); return FilHdr; }/*Do_Deriv*/
static int UnreadStringCallback( Environment *theEnv, const char *logicalName, int ch, void *context) { struct stringRouter *head; #if MAC_XCD #pragma unused(ch) #endif head = FindStringRouter(theEnv,logicalName); if (head == NULL) { SystemError(theEnv,"ROUTER",2); ExitRouter(theEnv,EXIT_FAILURE); } if (head->readWriteType != READ_STRING) return 0; if (head->currentPosition > 0) { head->currentPosition--; } return 1; }
void ProtectData(const secure_buffer& data, std::vector<unsigned char>& prot) { DWORD dwBufferSize = data.size(); if (!CryptEncrypt(SessionKey::Instance(), 0, TRUE, 0, 0, &dwBufferSize, data.size())) throw SystemError(GetLastError()); std::vector<unsigned char> buf(dwBufferSize); // copy data to encrypt std::copy(data.begin(), data.end(), buf.begin()); dwBufferSize = data.size(); if (!CryptEncrypt(SessionKey::Instance(), 0, TRUE, 0, &buf[0], &dwBufferSize, buf.size())) throw SystemError(GetLastError()); // set result prot.swap(buf); }
/* Calculate the directory name where of the executable */ BOOL calc_dirname(HMODULE hmod) { int is_special; wchar_t *modulename_start; wchar_t *cp; // get module filename if (!GetModuleFileNameW(hmod, modulename, sizeof(modulename))) { SystemError(GetLastError(), "Retrieving module name"); return FALSE; } // get directory of modulename. Note that in some cases // (eg, ISAPI), GetModuleFileName may return a leading "\\?\" // (which is a special format you can pass to the Unicode API // to avoid MAX_PATH limitations). Python currently can't understand // such names, and as it uses the ANSI API, neither does Windows! // So fix that up here. is_special = wcslen(modulename) > 4 && wcsncmp(modulename, L"\\\\?\\", 4)==0; modulename_start = is_special ? modulename + 4 : modulename; wcscpy(dirname, modulename_start); cp = wcsrchr(dirname, L'\\'); *cp = L'\0'; return TRUE; }
int HarnessTestExecutor :: validateParameters (void) { try { _ie.tcfile = getAbsolutePath (_ie.tcfile, false); if (_ie.tcfile.empty ()) throw ConfigError (FILE_LINE_FUNCTION, ERR_CONFIG_TESTCASEFILENAME_EMPTY); if (!bfs::is_regular (_ie.tcfile)) { stringstream ss; ss << "Test case file " << _ie.tcfile << " either does not exist or is not a regular file."; throw SystemError (FILE_LINE_FUNCTION, ss.str()); } if (_ie.debugLevel < MIN_DEBUG_LEVEL || _ie.debugLevel > MAX_DEBUG_LEVEL) { stringstream ss; ss << "Invalid value specified for option --debug. Valid range is [" << MIN_DEBUG_LEVEL << "-" << MAX_DEBUG_LEVEL << "]"; throw ConfigError (FILE_LINE_FUNCTION, ss.str()); } } catch (harnessexceptions :: ConfigError &e) { PRINT_ERROR (e.what ()); return FAILURE; } return SUCCESS; }
short TcpSocket::poll(short events) const { struct pollfd fds; fds.fd = _impl->fd(); fds.events = events; int timeout = getTimeout().ceil(); log_debug("poll timeout " << timeout); #ifdef __MINGW32__ int p = WSAPoll(&fds, 1, timeout); #else int p = ::poll(&fds, 1, timeout); #endif log_debug("poll returns " << p << " revents " << fds.revents); if (p < 0) { log_error("error in poll; errno=" << errno); throw SystemError("poll"); } else if (p == 0) { log_debug("poll timeout (" << timeout << ')'); throw IOTimeout(); } return fds.revents; }
NvmlSensorDriver::~NvmlSensorDriver() { nvmlReturn_t ret; if ((ret = dl_nvmlShutdown())) throw SystemError("Failed to shutdown NVML driver. Error code (cf. nvml.h): " + std::to_string(ret)); dlclose(nvml_so_handle_); }
static int PrintString( void *theEnv, char *logicalName, char *str) { struct stringRouter *head; head = FindStringRouter(theEnv,logicalName); if (head == NULL) { SystemError(theEnv,(char*)"ROUTER",3); EnvExitRouter(theEnv,EXIT_FAILURE); } if (head->readWriteType != WRITE_STRING) return(1); if (head->maximumPosition == 0) return(1); if ((head->currentPosition + 1) >= head->maximumPosition) return(1); genstrncpy(&head->str[head->currentPosition], str,(STD_SIZE) (head->maximumPosition - head->currentPosition) - 1); head->currentPosition += strlen(str); return(1); }
static int GetcString( void *theEnv, char *logicalName) { struct stringRouter *head; int rc; head = FindStringRouter(theEnv,logicalName); if (head == NULL) { SystemError(theEnv,(char*)"ROUTER",1); EnvExitRouter(theEnv,EXIT_FAILURE); } if (head->readWriteType != READ_STRING) return(EOF); if (head->currentPosition >= head->maximumPosition) { head->currentPosition++; return(EOF); } rc = (unsigned char) head->str[head->currentPosition]; head->currentPosition++; return(rc); }
__declspec(dllexport) __stdcall char * _ExPyEval(const char *cmd, int stoken) { PyGILState_STATE state; PyObject *m=NULL, *d=NULL; check_init(); state = PyGILState_Ensure(); m = PyImport_ImportModule("__main__"); if (m) d = PyModule_GetDict(m); if (d) { PyObject *res = PyRun_String(cmd, stoken, d, d); if (! res) { PyErr_Print(); } char *rres=PyString_AsString(PyObject_Str(res)); /* Note that the count of the PyObject_Str object is not decremented here*/ Py_XDECREF(res); Py_XDECREF(m); return rres; } else { SystemError(1, "could not import __main__"); } return NULL; }
static int ReadStringCallback( Environment *theEnv, const char *logicalName, void *context) { struct stringRouter *head; int rc; head = FindStringRouter(theEnv,logicalName); if (head == NULL) { SystemError(theEnv,"ROUTER",1); ExitRouter(theEnv,EXIT_FAILURE); } if (head->readWriteType != READ_STRING) return(EOF); if (head->currentPosition >= head->maximumPosition) { head->currentPosition++; return(EOF); } rc = (unsigned char) head->readString[head->currentPosition]; head->currentPosition++; return(rc); }
globle void *RequestChunk( void *theEnv, size_t requestSize) { struct chunkInfo *chunkPtr; struct blockInfo *blockPtr; /*==================================================*/ /* Allocate initial memory pool block if it has not */ /* already been allocated. */ /*==================================================*/ if (MemoryData(theEnv)->BlockMemoryInitialized == FALSE) { if (InitializeBlockMemory(theEnv,requestSize) == 0) return(NULL); } /*====================================================*/ /* Make sure that the amount of memory requested will */ /* fall on a boundary of strictest alignment */ /*====================================================*/ requestSize = (((requestSize - 1) / STRICT_ALIGN_SIZE) + 1) * STRICT_ALIGN_SIZE; /*=====================================================*/ /* Search through the list of free memory for a block */ /* of the appropriate size. If a block is found, then */ /* allocate and return a pointer to it. */ /*=====================================================*/ blockPtr = MemoryData(theEnv)->TopMemoryBlock; while (blockPtr != NULL) { chunkPtr = blockPtr->nextFree; while (chunkPtr != NULL) { if ((chunkPtr->size == requestSize) || (chunkPtr->size > (requestSize + MemoryData(theEnv)->ChunkInfoSize))) { AllocateChunk(theEnv,blockPtr,chunkPtr,requestSize); return((void *) (((char *) chunkPtr) + MemoryData(theEnv)->ChunkInfoSize)); } chunkPtr = chunkPtr->nextFree; } if (blockPtr->nextBlock == NULL) { if (AllocateBlock(theEnv,blockPtr,requestSize) == 0) /* get another block */ { return(NULL); } } blockPtr = blockPtr->nextBlock; } SystemError(theEnv,(char*)"MEMORY",2); EnvExitRouter(theEnv,EXIT_FAILURE); return(NULL); /* Unreachable, but prevents warning. */ }
std::string TcpStream::readLine() { while (! _buffer.hasFullLine()) { if (_buffer.isEof()) { throw std::runtime_error("EOF"); } static const size_t chunkSize = 1024; char chunk[chunkSize]; ssize_t readBytes = read(_fd, chunk, chunkSize); if (readBytes < 0) { throw SystemError("read error"); } else if (readBytes == 0) { _buffer.setEof(); } else { _buffer.addData(chunk, readBytes); } } return _buffer.getFirstLine(); }
void Init_CWD(GMC_ARG_VOID) { tp_Str Home, PWD; boolean Abort; tps_Str RawCWDirName; GetWorkingDir(&Abort, RawCWDirName); if (Abort) { SystemError("Current working directory name too long.\n"); Exit(1); }/*if*/; Do_Alias(OdinDirName, FALSE); Home = GetHome(""); if (Home == NIL) Home = GetEnv("HOME"); if (Home != NIL) Do_Alias(Home, FALSE); PWD = GetEnv("PWD"); if (PWD == NIL) PWD = GetEnv("cwd"); if (PWD != NIL && strncmp(PWD, RawCWDirName, strlen(PWD)) != 0) { Do_Alias(PWD, FALSE); }/*if*/; Get_Alias(CWDirName, RawCWDirName); Set_CWD(CWDirName); }/*Init_CWD*/
static void WriteStringCallback( Environment *theEnv, const char *logicalName, const char *str, void *context) { struct stringRouter *head; head = FindStringRouter(theEnv,logicalName); if (head == NULL) { SystemError(theEnv,"ROUTER",3); ExitRouter(theEnv,EXIT_FAILURE); return; } if (head->readWriteType != WRITE_STRING) return; if (head->maximumPosition == 0) return; if ((head->currentPosition + 1) >= head->maximumPosition) return; genstrncpy(&head->writeString[head->currentPosition], str,(STD_SIZE) (head->maximumPosition - head->currentPosition) - 1); head->currentPosition += strlen(str); }