UDBI::UDBI(const char* driverdir, const char* drivername) { U_TRACE_REGISTER_OBJECT(0, UDBI, "%S,%S", driverdir, drivername) query_in = 0; query_in_len = 0; complete = ready_for_input = false; pos_read = pos_input = pos_size = 0; #if LIBDBI_LIB_CURRENT <= 1 int ndrivers = U_SYSCALL(dbi_initialize, "%S", driverdir); #else int ndrivers = U_SYSCALL(dbi_initialize_r, "%S,%p", driverdir, &pinst); #endif U_VAR_UNUSED(ndrivers) U_INTERNAL_ASSERT_MAJOR(ndrivers, 0) #if LIBDBI_LIB_CURRENT <= 1 conn = U_SYSCALL(dbi_conn_new, "%S", drivername); #else conn = U_SYSCALL(dbi_conn_new_r, "%S,%p", drivername, pinst); #endif affected_rows = 0; U_INTERNAL_ASSERT_POINTER_MSG(conn, "DBI: failed to load backend...") (void) U_SYSCALL(dbi_conn_set_option, "%p,%S,%S", conn, "driver", drivername); }
X509_REQ* UPKCS10::readPKCS10(const UString& x, const char* format) { U_TRACE(1, "UPKCS10::readPKCS10(%.*S,%S)", U_STRING_TO_TRACE(x), format) BIO* in; UString tmp = x; X509_REQ* _request = 0; if (format == 0) format = (x.isBinary() ? "DER" : "PEM"); if (U_STREQ(format, "PEM") && U_STRNCMP(x.data(), "-----BEGIN CERTIFICATE REQUEST-----")) { unsigned length = x.size(); UString buffer(length); if (UBase64::decode(x.data(), length, buffer) == false) goto next; tmp = buffer; format = "DER"; } next: in = (BIO*) U_SYSCALL(BIO_new_mem_buf, "%p,%d", U_STRING_TO_PARAM(tmp)); _request = (X509_REQ*) (U_STREQ(format, "PEM") ? U_SYSCALL(PEM_read_bio_X509_REQ, "%p,%p,%p,%p", in, 0, 0, 0) : U_SYSCALL(d2i_X509_REQ_bio, "%p,%p", in, 0)); (void) U_SYSCALL(BIO_free, "%p", in); U_RETURN_POINTER(_request, X509_REQ); }
bool UMagic::init(int flags) { U_TRACE(1, "UMagic::init(%d)", flags) U_INTERNAL_ASSERT_EQUALS(magic, U_NULLPTR) magic = (magic_t) U_SYSCALL(magic_open, "%d", flags); bool ok = (magic && U_SYSCALL(magic_load, "%p,%S", magic, U_NULLPTR) != -1); U_DUMP("ok = %b status = %.*S", ok, 512, getError()) U_RETURN(ok); }
void* UDynamic::operator[](const char* _sym) { U_TRACE(0, "UDynamic::operator[](%S)", _sym) U_CHECK_MEMORY U_INTERNAL_ASSERT_POINTER(handle) #if defined(_MSWINDOWS_) addr = (void*) ::GetProcAddress(handle, _sym); #else addr = U_SYSCALL(dlsym, "%p,%S", handle, _sym); #endif if (addr == 0) { # if defined(_MSWINDOWS_) err = "symbol missing"; # else err = ::dlerror(); # endif U_WARNING("UDynamic::operator[](%S) failed: %.*S", _sym, 256, err); } U_RETURN(addr); }
UTranformInputURI::UTranformInputURI(const char* uri) { U_TRACE_CTOR(0, UTranformInputURI, "%S", uri) clbks = U_NULLPTR; clbksCtx = U_NULLPTR; /* * Try to find one of the input accept method accepting that scheme * Go in reverse to give precedence to user defined handlers. * try with an unescaped version of the uri */ char* unescaped = U_SYSCALL(xmlURIUnescapeString, "%S,%d,%S", uri, 0, U_NULLPTR); if (unescaped != U_NULLPTR) { clbks = find(unescaped); if (clbks) clbksCtx = clbks->opencallback(unescaped); U_SYSCALL_VOID(xmlFree, "%p", unescaped); } // If this failed try with a non-escaped uri this may be a strange filename if (clbks == U_NULLPTR) { clbks = find(uri); if (clbks) clbksCtx = clbks->opencallback(uri); } }
bool UREDISClient_Base::connect(const char* phost, unsigned int _port) { U_TRACE(0, "UREDISClient_Base::connect(%S,%u)", phost, _port) UString host; if (phost) (void) host.assign(phost); else { const char* env_redis_host = (const char*) U_SYSCALL(getenv, "%S", "REDIS_HOST"); if (env_redis_host == 0) { UClient_Base::response.snprintf("connection disabled"); U_RETURN(false); } (void) host.assign(env_redis_host, u__strlen(env_redis_host, __PRETTY_FUNCTION__)); const char* env_redis_port = (const char*) U_SYSCALL(getenv, "%S", "REDIS_PORT"); if (env_redis_port) _port = atoi(env_redis_port); } if (UClient_Base::setHostPort(host, _port) && UClient_Base::connect()) { UClient_Base::iovcnt = 4; UClient_Base::iov[1].iov_base = UClient_Base::iov[4].iov_base = (caddr_t)" "; UClient_Base::iov[1].iov_len = UClient_Base::iov[4].iov_len = 1; UClient_Base::iov[3].iov_base = UClient_Base::iov[5].iov_base = (caddr_t)U_CRLF; UClient_Base::iov[3].iov_len = UClient_Base::iov[5].iov_len = 2; U_DUMP("getRedisVersion() = %V", getRedisVersion().rep) U_RETURN(true); } U_RETURN(false); }
static void set_alarm() { U_TRACE(4, "set_alarm()") UInterrupt::setHandlerForSignal(SIGALRM, (sighandler_t)&manage_alarm); (void) U_SYSCALL(setitimer,"%d,%p,%p",ITIMER_REAL,&timeval,0); }
void UProcess::setProcessGroup(pid_t pid, pid_t pgid) { U_TRACE(1, "UProcess::setProcessGroup(%d,%d)", pid, pgid) #ifndef __MINGW32__ (void) U_SYSCALL(setpgid, "%d,%d", pid, pgid); #endif }
void USemaphore::init(sem_t* ptr, unsigned resource) { U_TRACE(1, "USemaphore::init(%p,%u)", ptr, resource) U_CHECK_MEMORY #ifdef __MINGW32__ sem = ::CreateSemaphore((LPSECURITY_ATTRIBUTES)NULL, (LONG)resource, MAX_SEM_VALUE, (LPCTSTR)NULL); #elif defined(U_LOCKFILE) (void) tmp.mkTemp(); #else if (ptr) { sem = ptr; bmmap = false; } else { bmmap = true; sem = (sem_t*) UFile::mmap(sizeof(sem_t)); } /* initialize semaphore object sem to value, share it with other processes */ broken = (U_SYSCALL(sem_init, "%p,%d,%u", sem, 1, resource) == -1); // 1 -> semaphore is shared between processes # ifdef U_MAYBE_BROKEN_SEM_IMPL if (broken) { (void) U_SYSCALL(pthread_mutexattr_init, "%p", &mutex_attr); (void) U_SYSCALL(pthread_mutexattr_setpshared, "%p,%p", &mutex_attr, PTHREAD_PROCESS_SHARED); (void) U_SYSCALL(pthread_mutex_init, "%p,%p", &mutex, &mutex_attr); return; } # endif if (ptr) { next = first; first = this; U_INTERNAL_DUMP("first = %p next = %p", first, next) } #endif }
USemaphore::~USemaphore() { U_TRACE_UNREGISTER_OBJECT(0, USemaphore) #ifdef __MINGW32__ ::CloseHandle(sem); #elif defined(U_LOCKFILE) (void) tmp.close(); #else # ifdef U_MAYBE_BROKEN_SEM_IMPL if (broken) (void) U_SYSCALL(pthread_mutex_destroy, "%p", &mutex); else # endif /* Free resources associated with semaphore object sem */ (void) U_SYSCALL(sem_destroy, "%p", sem); if (bmmap) UFile::munmap(sem, sizeof(sem_t)); #endif }
// Check for memory error U_MEMORY_TEST // Allocator e Deallocator U_MEMORY_ALLOCATOR U_MEMORY_DEALLOCATOR UThreadImpl(bool suspendEnable, bool joinEnable) { U_TRACE(0, "UThreadImpl::UThreadImpl(%b,%b)", suspendEnable, joinEnable) _tid = 0; _signal = 0; _cancel = 0; _suspendCount = 0; _suspendEnable = suspendEnable; (void) U_SYSCALL(pthread_attr_init, "%p", &_attr); (void) U_SYSCALL(pthread_attr_setdetachstate, "%p,%d", &_attr, (joinEnable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED)); }
void UThread::yield() { U_TRACE_NO_PARAM(1, "UThread::yield()") // Yields the current thread's CPU time slice to allow another thread to begin immediate execution U_INTERNAL_DUMP("cancel = %d", cancel) #ifdef HAVE_PTHREAD_CANCEL U_SYSCALL_VOID_NO_PARAM(pthread_testcancel); #elif !defined(_MSWINDOWS_) && !defined(__UNIKERNEL__) sigset_t old = 0; if (cancel != cancelInitial && cancel != cancelDisabled) { sigset_t scancel; # ifdef sigemptyset sigemptyset(&scancel); # else (void) U_SYSCALL(sigemptyset, "%p", &scancel); # endif # ifdef sigaddset sigaddset(&scancel, U_SIG_THREAD_CANCEL); # else (void) U_SYSCALL(sigaddset, "%p,%d", &scancel, U_SIG_THREAD_CANCEL); # endif (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_UNBLOCK, &scancel, &old); } #endif #ifdef HAVE_PTHREAD_YIELD (void) U_SYSCALL_NO_PARAM(pthread_yield); #endif #if !defined(HAVE_PTHREAD_CANCEL) && !defined(_MSWINDOWS_) && !defined(__UNIKERNEL__) if (old) (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_SETMASK, &old, 0); #endif }
void UInterrupt::erase(int signo) { U_TRACE(1, "UInterrupt::erase(%d)", signo) U_INTERNAL_ASSERT_RANGE(1, signo, NSIG) U_INTERNAL_ASSERT_POINTER(handler_signal[signo]) handler_signal[signo] = 0; (void) U_SYSCALL(sigaction, "%d,%p,%p", signo, old + signo, 0); }
UString UPKCS10::getSubject(X509_REQ* _request) { U_TRACE(1, "UPKCS10::getSubject(%p)", _request) U_INTERNAL_ASSERT_POINTER(_request) X509_NAME* name = X509_REQ_get_subject_name(_request); unsigned len = U_SYSCALL(i2d_X509_NAME, "%p,%p", name, 0); UString subject(len); char* ptr = subject.data(); (void) U_SYSCALL(X509_NAME_oneline, "%p,%p,%d", name, ptr, subject.capacity()); len = u__strlen(ptr, __PRETTY_FUNCTION__); subject.size_adjust(len); U_RETURN_STRING(subject); }
void UInterrupt::insert(int signo, sighandler_t handler) { U_TRACE(1, "UInterrupt::insert(%d,%p)", signo, handler) U_INTERNAL_ASSERT_RANGE(1, signo, NSIG) handler_signal[signo] = handler; act.sa_handler = handlerEventSignal; (void) U_SYSCALL(sigaction, "%d,%p,%p", signo, &act, old + signo); }
void UCDB::init_internal(int ignore_case) { U_TRACE(0, "UCDB::init_internal(%d)", ignore_case) (void) U_SYSCALL(memset, "%p,%d,%d", &key, 0, sizeof(datum)); (void) U_SYSCALL(memset, "%p,%d,%d", &data, 0, sizeof(datum)); hr = 0; slot = 0; hp = 0; pattern = 0; pbuffer = 0; ptr_vector = 0; function_to_call = 0; filter_function_to_call = functionCall; // when mmap not available we use this storage... (void) U_SYSCALL(memset, "%p,%d,%d", &hp_buf, 0, sizeof(hp_buf)); (void) U_SYSCALL(memset, "%p,%d,%d", &hr_buf, 0, sizeof(cdb_record_header)); (void) U_SYSCALL(memset, "%p,%d,%d", &slot_buf, 0, sizeof(cdb_hash_table_slot)); loop = nslot = khash = nrecord = offset = start_hash_table_slot = 0; union uucdb_flag { unsigned char* pc; uint32_t* pi; }; union uucdb_flag u = { (unsigned char*)&flag }; *u.pi = 0x00000000; U_cdb_ignore_case(this) = ignore_case; flag[1] = flag[2] = flag[3] = 0; }
UString UMagic::getType(const char* buffer, uint32_t buffer_len) { U_TRACE(1, "UMagic::getType(%.*S,%u)", buffer_len, buffer, buffer_len) U_INTERNAL_ASSERT_POINTER(magic) UString str; const char* result = (const char*) U_SYSCALL(magic_buffer, "%p,%p,%u", magic, buffer, buffer_len); if (result) (void) str.assign(result); else (void) str.assign(U_CONSTANT_TO_PARAM("application/octet-stream")); U_RETURN_STRING(str); }
void run(int argc, char* argv[], char* env[]) { U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env) Action::run(argc, argv, env); // read stdin and scanf Action::processInputData(2); // -------------------------------------------------------------------------------------------------------------- // configuration parameters // -------------------------------------------------------------------------------------------------------------- // SUBJECT_TEMPLATE scanf form to extract data from mail header Subject: // SEARCH_ENGINE_FOLDER_SEARCH_URL url to do query to search engine // -------------------------------------------------------------------------------------------------------------- UString subj_tmpl = cfg[U_STRING_FROM_CONSTANT("SUBJECT_TEMPLATE")], url = cfg[U_STRING_FROM_CONSTANT("SEARCH_ENGINE_FOLDER_SEARCH_URL")]; uint32_t subject = U_STRING_FIND(request, 0, "Subject: "); if (subject == U_NOT_FOUND) U_ERROR("cannot find mail header subject on input data..."); // scanf mail header Subject: from request // ---------------------------------------------------------------------------------------------------------------------------- // "Subject: %*[^"]\"%[^"]\", %*[^"]\"%[^"]\", %*[^"]\"%[^"]\"" // ---------------------------------------------------------------------------------------------------------------------------- // Subject: Re: TUnwired processo di registrazione utente residenziale con CPE: // notifica produzione CPE cliente "workflow test", indirizzo installazione "Via Volturno, 12 50100 Firenze (FI)", // UID "37723e2d-d052-4c13-a1e9-134563eb9666" // ---------------------------------------------------------------------------------------------------------------------------- int n = U_SYSCALL(sscanf, "%S,%S,%p,%p,%p,%p", request.c_pointer(subject), subj_tmpl.data(), customer, installation, uid); if (n != 3) U_ERROR("scanf error on mail header subject..."); U_INTERNAL_DUMP("sscanf() customer = %S installation = %S uid = %S", customer, installation, uid) // query to Search Engine UString body(10U + u__strlen(uid)); body.snprintf("query=%s", uid); bool ok = Action::sendHttpPostRequest(url, body, "application/x-www-form-urlencoded", "1\n"); Action::writeToSTDOUT(ok, ok); }
UXPathData::UXPathData(int data_type, int _nodeSetType, const char* _expr) { U_TRACE_REGISTER_OBJECT(0, UXPathData, "%d,%d,%S", data_type, _nodeSetType, _expr) ctx = U_NULLPTR; expr = _expr; type = data_type; nodeSetOp = UNodeSet::INTERSECTION; nodeSetType = _nodeSetType; /* create xpath or xpointer context */ switch (type) { case XPATH: case XPATH2: ctx = (xmlXPathContextPtr) U_SYSCALL(xmlXPathNewContext, "%p", U_NULLPTR); /* we'll set doc in the context later */ break; case XPOINTER: ctx = (xmlXPathContextPtr) U_SYSCALL(xmlXPtrNewContext, "%p,%p,%p", U_NULLPTR, U_NULLPTR, U_NULLPTR); /* we'll set doc in the context later */ break; } }
X509* UCertificate::readX509(const UString& x, const char* format) { U_TRACE(1, "UCertificate::readX509(%V,%S)", x.rep, format) BIO* in; X509* _x509 = 0; UString tmp = x; if (format == 0) format = (x.isBinary() ? "DER" : "PEM"); if (strncmp(format, U_CONSTANT_TO_PARAM("PEM")) == 0 && strncmp(x.data(), U_CONSTANT_TO_PARAM("-----BEGIN CERTIFICATE-----")) != 0) { unsigned length = x.size(); UString buffer(length); UBase64::decode(x.data(), length, buffer); if (buffer && u_base64_errors == 0) { tmp = buffer; format = "DER"; } } in = (BIO*) U_SYSCALL(BIO_new_mem_buf, "%p,%d", U_STRING_TO_PARAM(tmp)); _x509 = (X509*) (strncmp(format, U_CONSTANT_TO_PARAM("PEM")) == 0 ? U_SYSCALL(PEM_read_bio_X509, "%p,%p,%p,%p", in, 0, 0, 0) : U_SYSCALL(d2i_X509_bio, "%p,%p", in, 0)); (void) U_SYSCALL(BIO_free, "%p", in); U_RETURN_POINTER(_x509, X509); }
UXML2Document::UXML2Document(const UString& _data) : data(_data) { U_TRACE_REGISTER_OBJECT(0, UXML2Document, "%V", _data.rep) if (binit == false) init(); // impl_ = (xmlDocPtr) U_SYSCALL(xmlParseMemory, "%p,%d", U_STRING_TO_PARAM(_data)); /* Enum xmlParserOption { XML_PARSE_RECOVER = 1 : recover on errors XML_PARSE_NOENT = 2 : substitute entities XML_PARSE_DTDLOAD = 4 : load the external subset XML_PARSE_DTDATTR = 8 : default DTD attributes XML_PARSE_DTDVALID = 16 : validate with the DTD XML_PARSE_NOERROR = 32 : suppress error reports XML_PARSE_NOWARNING = 64 : suppress warning reports XML_PARSE_PEDANTIC = 128 : pedantic error reporting XML_PARSE_NOBLANKS = 256 : remove blank nodes XML_PARSE_SAX1 = 512 : use the SAX1 interface internally XML_PARSE_XINCLUDE = 1024 : Implement XInclude substitition XML_PARSE_NONET = 2048 : Forbid network access XML_PARSE_NODICT = 4096 : Do not reuse the context dictionnary XML_PARSE_NSCLEAN = 8192 : remove redundant namespaces declarations XML_PARSE_NOCDATA = 16384 : merge CDATA as text nodes XML_PARSE_NOXINCNODE = 32768 : do not generate XINCLUDE START/END nodes XML_PARSE_COMPACT = 65536 : compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify tree) XML_PARSE_OLD10 = 131072 : parse using XML-1.0 before update 5 XML_PARSE_NOBASEFIX = 262144 : do not fixup XINCLUDE xml:base uris XML_PARSE_HUGE = 524288 : relax any hardcoded limit from the parser XML_PARSE_OLDSAX = 1048576 : parse using SAX2 interface from before 2.7.0 } */ impl_ = (xmlDocPtr) U_SYSCALL(xmlReadMemory, "%p,%d,%S,%S,%d", U_STRING_TO_PARAM(_data), 0, 0, XML_PARSE_COMPACT); if (impl_ == NULL) { U_ERROR("unable to parse xml document"); } /* * Check the document is of the right kind */ if (getRootNode() == NULL) U_ERROR("empty xml document"); }
void UDynamic::close() { U_TRACE(0, "UDynamic::close()") U_CHECK_MEMORY U_INTERNAL_ASSERT_POINTER(handle) #if defined(_MSWINDOWS_) ::FreeLibrary(handle); #else (void) U_SYSCALL(dlclose, "%p", handle); #endif err = 0; addr = 0; handle = 0; }
bool UDynamic::load(const char* pathname) { U_TRACE(0, "UDynamic::load(%S)", pathname) U_CHECK_MEMORY U_INTERNAL_ASSERT_EQUALS(handle, 0) #ifdef _MSWINDOWS_ handle = ::LoadLibrary(pathname); #else /** * -------------------------------------------------------------------- * Perform lazy binding * -------------------------------------------------------------------- * Only resolve symbols as the code that references them is executed. * If the symbol is never referenced, then it is never resolved. * Lazy binding is only performed for function references; references * to variables are always immediately bound when the library is loaded * -------------------------------------------------------------------- */ handle = U_SYSCALL(dlopen, "%S,%d", pathname, RTLD_LAZY); // RTLD_NOW #endif if (handle == 0) { # if defined(_MSWINDOWS_) err = "load failed"; # else err = ::dlerror(); # endif U_WARNING("UDynamic::load(%S) failed: %.*S", pathname, 256, err); U_RETURN(false); } #ifndef _MSWINDOWS_ (void) ::dlerror(); /* Clear any existing error */ #endif U_RETURN(true); }
int U_EXPORT main (int argc, char* argv[]) { U_ULIB_INIT(argv); U_TRACE(5,"main(%d)",argc) U_ASSERT_EQUALS( UServices::dosMatchWithOR(U_CONSTANT_TO_PARAM("www.sito1.com"), U_CONSTANT_TO_PARAM("SSI|benchmark|www.sito1.com|www.sito2.com"), FNM_INVERT), false) UString buffer(2000); u_base64_max_columns = 72; UBase64::encode(U_CONSTANT_TO_PARAM(TESTOA), buffer); U_INTERNAL_DUMP("buffer = %#.*S", U_STRING_TO_TRACE(buffer)) U_ASSERT( buffer == U_STRING_FROM_CONSTANT(TESTOB) ) UBase64::decode( U_CONSTANT_TO_PARAM(TESTOB), buffer); U_ASSERT( buffer == U_STRING_FROM_CONSTANT(TESTOA) ) UString cmd, result1, result2; int fd_stderr = U_SYSCALL(open, "%S,%d", "err/services.err", O_WRONLY); cmd = U_STRING_FROM_CONSTANT("ls test_services.cpp"); result1 = UCommand::outputCommand(cmd); // U_ASSERT( result1 == U_STRING_FROM_CONSTANT("test_services.cpp\n") ) buffer = UServices::getUUID(); U_INTERNAL_DUMP("buffer = %#.*S", U_STRING_TO_TRACE(buffer)) cmd = U_STRING_FROM_CONSTANT("cat test_services.cpp"); result2 = UCommand::outputCommand(cmd, 0, -1, fd_stderr); U_ASSERT( result2.empty() == false ) cout.write(result2.data(), result2.size()); }
void ULog::startup() { U_TRACE(0, "ULog::startup()") U_INTERNAL_ASSERT_POINTER(fmt) log(fmt, "STARTUP", sizeof(void*) * 8); log("Building Environment: " PLATFORM_VAR " (" __DATE__ ")\n", 0); #ifndef __MINGW32__ struct utsname u; (void) U_SYSCALL(uname, "%p", &u); log("Current Operating System: %s %s v%s %s\n", u.sysname, u.machine, u.version, u.release); #endif #if defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) log("Big endian arch detected\n", 0); #endif }
void run(int argc, char* argv[], char* env[]) { U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env) UApplication::run(argc, argv, env); U_ASSERT( num_args == 2 ) U_ASSERT( opt[(uint32_t)0U] == U_STRING_FROM_CONSTANT("1") ) U_ASSERT( opt[(uint32_t)1U] == U_STRING_FROM_CONSTANT("pippo") ) U_ASSERT( opt[(uint32_t)2U] == U_STRING_FROM_CONSTANT("Hello") ) U_ASSERT( opt[(uint32_t)3U] == U_STRING_FROM_CONSTANT("1") ) U_ASSERT( opt[(uint32_t)4U] == U_STRING_FROM_CONSTANT("Bucaiolo_a_te") ) U_ASSERT( opt['a'] == U_STRING_FROM_CONSTANT("1") ) U_ASSERT( opt['b'] == U_STRING_FROM_CONSTANT("pippo") ) U_ASSERT( opt['c'] == U_STRING_FROM_CONSTANT("Hello") ) U_ASSERT( opt[U_STRING_FROM_CONSTANT("option_with_no_short_1")] == U_STRING_FROM_CONSTANT("1") ) U_ASSERT( opt[U_STRING_FROM_CONSTANT("option_with_no_short_2")] == U_STRING_FROM_CONSTANT("Bucaiolo_a_te") ) U_ASSERT( strcmp(argv[optind], "argument_1") == 0 ) ++optind; U_ASSERT( strcmp(argv[optind], "argument_2") == 0 ) u_atexit(reset); (void) write(STDOUT_FILENO, U_CONSTANT_TO_PARAM("AutoSending SIGTERM...\n")); # ifndef DEBUG UInterrupt::act.sa_flags = 0; UInterrupt::act.sa_handler = UInterrupt::handlerInterrupt; (void) U_SYSCALL(sigaction, "%d,%p,%p", SIGTERM, &UInterrupt::act, 0); // 15 # endif UInterrupt::sendSignal(SIGTERM, u_pid); }
BIO* bio = (BIO*) U_SYSCALL(BIO_new, "%p", BIO_s_mem()); int res = U_SYSCALL(X509_NAME_print_ex, "%p,%p,%d,%ld", bio, n, 0, XN_FLAG_COMPAT); if (res == -1) (void) U_SYSCALL(BIO_free, "%p", bio); else { UString name = UStringExt::BIOtoString(bio); U_RETURN_STRING(name); } return UString::getStringNull(); } unsigned len = U_SYSCALL(i2d_X509_NAME, "%p,%p", n, 0); UString name(len); char* ptr = name.data(); (void) U_SYSCALL(X509_NAME_oneline, "%p,%p,%d", n, ptr, name.capacity()); len = u__strlen(ptr, __PRETTY_FUNCTION__); name.size_adjust(len); U_RETURN_STRING(name); } bool UCertificate::isIssued(const UCertificate& ca) const {
U_NO_EXPORT void UProcess::setStdInOutErr(bool fd_stdin, bool fd_stdout, bool fd_stderr) { U_TRACE(1, "UProcess::setStdInOutErr(%b,%b,%b)", fd_stdin, fd_stdout, fd_stderr) #ifdef __MINGW32__ HANDLE hProcess = GetCurrentProcess(); #endif // check if we write to STDIN if (fd_stdin) { # ifdef __MINGW32__ if (hFile[1]) // Created parent-output pipe... { hChildIn = hFile[0]; // Duplicating as inheritable child-input pipe // ------------------------------------------- // (void) U_SYSCALL(DuplicateHandle, "%p,%p,%p,%p,%lu,%b,%lu", hProcess, hFile[0], hProcess, &hChildIn, 0, TRUE, DUPLICATE_SAME_ACCESS); // (void) U_SYSCALL( CloseHandle, "%p", hFile[0]); } else { hChildIn = (HANDLE)_get_osfhandle(filedes[0]); } # else U_INTERNAL_ASSERT_MAJOR(filedes[0],STDERR_FILENO) (void) U_SYSCALL(dup2, "%d,%d", filedes[0], STDIN_FILENO); U_INTERNAL_ASSERT_EQUALS(::fcntl(STDIN_FILENO,F_GETFD,FD_CLOEXEC), 0) # endif } // check if we read from STDOUT if (fd_stdout) { # ifdef __MINGW32__ if (hFile[2]) // Created parent-input pipe... { hChildOut = hFile[3]; // Duplicating as inheritable child-output pipe // ------------------------------------------- // (void) U_SYSCALL(DuplicateHandle, "%p,%p,%p,%p,%lu,%b,%lu", hProcess, hFile[3], hProcess, &hChildOut, 0, TRUE, DUPLICATE_SAME_ACCESS); // (void) U_SYSCALL( CloseHandle, "%p", hFile[3]); } else { hChildOut = (HANDLE)_get_osfhandle(filedes[3]); } # else U_INTERNAL_ASSERT_MAJOR(filedes[3],STDOUT_FILENO) (void) U_SYSCALL(dup2, "%d,%d", filedes[3], STDOUT_FILENO); U_INTERNAL_ASSERT_EQUALS(::fcntl(STDOUT_FILENO,F_GETFD,FD_CLOEXEC), 0) # endif } // check if we read from STDERR if (fd_stderr) { # ifdef __MINGW32__ if (hFile[4]) // Created parent-input pipe... { hChildErr = hFile[5]; // Duplicating as inheritable child-output pipe // ------------------------------------------- // (void) U_SYSCALL(DuplicateHandle, "%p,%p,%p,%p,%lu,%b,%lu", hProcess, hFile[5], hProcess, &hChildErr, 0, TRUE, DUPLICATE_SAME_ACCESS); // (void) U_SYSCALL( CloseHandle, "%p", hFile[5]); } else { hChildErr = (HANDLE)_get_osfhandle(filedes[5]); } # else U_INTERNAL_ASSERT(filedes[5] >= STDOUT_FILENO) (void) U_SYSCALL(dup2, "%d,%d", filedes[5], STDERR_FILENO); U_INTERNAL_ASSERT_EQUALS(::fcntl(STDERR_FILENO,F_GETFD,FD_CLOEXEC), 0) # endif } #ifdef __MINGW32__ CloseHandle(hProcess); #else if (fd_stdin) { U_INTERNAL_DUMP("filedes[0,1] = { %d, %d }", filedes[0], filedes[1]) (void) U_SYSCALL(close, "%d", filedes[0]); if (filedes[1] > STDERR_FILENO) (void) U_SYSCALL(close, "%d", filedes[1]); } if (fd_stdout) { U_INTERNAL_DUMP("filedes[2,3] = { %d, %d }", filedes[2], filedes[3]) (void) U_SYSCALL(close, "%d", filedes[3]); if (filedes[2] > STDERR_FILENO) (void) U_SYSCALL(close, "%d", filedes[2]); } if (fd_stderr) { U_INTERNAL_DUMP("filedes[4,5] = { %d, %d }", filedes[4], filedes[5]) (void) U_SYSCALL(close, "%d", filedes[5]); if (filedes[4] > STDERR_FILENO) (void) U_SYSCALL(close, "%d", filedes[4]); } #endif }
void UProcess::nice(int inc) { U_TRACE(1, "UProcess::nice(%d)", inc) (void) U_SYSCALL(nice, "%d", inc); }
void UProcess::kill(pid_t pid, int sig) { U_TRACE(1, "UProcess::kill(%d,%d)", pid, sig) (void) U_SYSCALL(kill, "%d,%d", pid, sig); }