int main(int argc, char* argv[]) { unsigned char encoded[1024]; char* reply = get_reply(); (void) u_xml_encode(argv[1], strlen(argv[1]), encoded); (void) u__snprintf(reply, get_reply_capacity(), U_CONSTANT_TO_PARAM("<h1>Hello %s</h1>"), encoded); return 200; }
virtual int handlerTime() { U_TRACE(0+256, "MyAlarm1::handlerTime()") // return value: // --------------- // -1 - normal // 0 - monitoring // --------------- cout.write(buffer, u__snprintf(buffer, sizeof(buffer), "MyAlarm1::handlerTime() u_now = %1D expire = %#1D\n", UEventTime::expire())); U_RETURN(-1); }
int main(int argc, char* argv[]) { unsigned char l[6]; unsigned char im[70*200]; unsigned char gif[GIF_SIZE]; unsigned char encoded[GIF_SIZE * 3]; captcha(im, l); makegif(im, gif); U_ClientImage_request_nocache = true; set_reply_capacity(1024 + GIF_SIZE * 3); (void) u__snprintf(get_reply(), get_reply_capacity(), "<img src=\"data:img/gif;base64,%.*s\">", u_base64_encode(gif, GIF_SIZE, encoded), encoded); return 200; }
void run(int argc, char* argv[], char* env[]) { U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env) UApplication::run(argc, argv, env); const char* p = argv[optind++]; UString path_of_db_file(p, strlen(p)); if (path_of_db_file.empty()) U_ERROR("missing <path_of_db_file> argument"); URDB x(path_of_db_file, false); if (x.UFile::getSuffix().equal(U_CONSTANT_TO_PARAM("jnl"))) { U_ERROR("you must avoid the jnl suffix, exiting"); } const char* method = argv[optind++]; if (method == 0) U_ERROR("<number_of_command> argument is missing"); if (u__isdigit(*method) == false) U_ERROR("<number_of_command> argument is not numeric"); int op = method[0] - '0'; if (x.open(10 * 1024 * 1024, false, op == 6, true)) // bool open(uint32_t log_size, bool btruncate, bool cdb_brdonly, bool breference) { if (method[1] == 's') x.setShared(0,0); // POSIX shared memory object (interprocess - can be used by unrelated processes) else x.resetReference(); switch (op) { case 1: // get { UString key(argv[optind]), value = x[key]; (void) UFile::writeToTmp(U_STRING_TO_PARAM(value), O_RDWR | O_TRUNC, U_CONSTANT_TO_PARAM(U_FILE_OUTPUT), 0); } break; case 2: // del { # if defined(U_STDCPP_ENABLE) && !defined(HAVE_OLD_IOSTREAM) string input = ""; cout << "Are you sure to want <DELETE> ?\n>"; getline(cin, input); cout << "You entered: " << input << endl << endl; UString key(argv[optind]); UApplication::exit_value = x.remove(key); # endif } break; case 3: // store { UString key(argv[optind]); p = argv[optind++]; UString value(p, strlen(p)); if (value.equal(U_CONSTANT_TO_PARAM(U_DIR_OUTPUT U_FILE_OUTPUT))) { p = U_DIR_OUTPUT U_FILE_OUTPUT; value = UStringExt::trim(UFile::contentOf(UString(p, strlen(p)))); } UApplication::exit_value = x.store(key, value, RDB_REPLACE); } break; case 4: // size, capacity { char buffer[64]; uint32_t sz = x.getCapacity(), n = u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("%u record(s) - capacity: %.2fM (%u bytes)\n"), x.size(), (double)sz / (1024.0 * 1024.0), sz); (void) write(1, buffer, n); } break; case 5: // dump { UString value = x.print(); if (value.empty()) (void) UFile::_unlink(U_DIR_OUTPUT U_FILE_OUTPUT); else (void) UFile::writeToTmp(U_STRING_TO_PARAM(value), O_RDWR | O_TRUNC, U_CONSTANT_TO_PARAM(U_FILE_OUTPUT), 0); } break; case 6: // compact { # if defined(U_STDCPP_ENABLE) && !defined(HAVE_OLD_IOSTREAM) string input = ""; cout << "Are you sure to want <JOURNAL COMPACTION> ?\n>"; getline(cin, input); cout << "You entered: " << input << endl << endl; UApplication::exit_value = (x.compactionJournal() == false); # endif } break; case 7: // reorganize { # if defined(U_STDCPP_ENABLE) && !defined(HAVE_OLD_IOSTREAM) string input = ""; cout << "Are you sure to want <REORGANIZE> ?\n>"; getline(cin, input); cout << "You entered: " << input << endl << endl; UApplication::exit_value = (x.closeReorganize() == false); # endif return; } default: U_ERROR("<number_of_command> argument is not valid"); break; } x.close(false); } }
} if (environment) delete environment; } void USSIPlugIn::setAlternativeRedirect(const char* fmt, ...) { U_TRACE(0, "USSIPlugIn::setAlternativeRedirect(%S)", fmt) char format[4096]; UString buffer(U_CAPACITY); va_list argp; va_start(argp, fmt); buffer.vsnprintf(format, u__snprintf(format, sizeof(format), U_CONSTANT_TO_PARAM(U_CTYPE_HTML "\r\nRefresh: 0; url=%s\r\n"), fmt), argp); va_end(argp); alternative_response = 1; U_http_info.nResponseCode = HTTP_OK; UClientImage_Base::setCloseConnection(); UHTTP::setResponse(true, buffer, U_NULLPTR); } void USSIPlugIn::setBadRequest() { U_TRACE_NO_PARAM(0, "USSIPlugIn::setBadRequest()")
ULog::ULog(const UString& path, uint32_t _size, const char* dir_log_gz) : UFile(path) { U_TRACE_REGISTER_OBJECT(0, ULog, "%.*S,%u,%S", U_STRING_TO_TRACE(path), _size, dir_log_gz) log_gzip_sz = 0; U_Log_start_stop_msg(this) = false; if (UFile::getPath().equal(U_CONSTANT_TO_PARAM("syslog"))) { lock = 0; ptr_log_data = 0; # ifdef USE_LIBZ buf_path_compress = 0; # endif U_Log_syslog(this) = true; # ifndef __MINGW32__ U_SYSCALL_VOID(openlog, "%S,%d,%d", u_progname, LOG_PID, LOG_LOCAL0); # endif return; } if (UFile::creat(O_RDWR | O_APPEND, 0664) == false) { U_ERROR("cannot creat log file %.*S", U_FILE_TO_TRACE(*this)); return; } ptr_log_data = U_MALLOC_TYPE(log_data); ptr_log_data->file_ptr = 0; if (_size) { uint32_t file_size = UFile::size(); bool bsize = (file_size != _size); U_INTERNAL_DUMP("bsize = %b", bsize) if ((bsize && UFile::ftruncate(_size) == false) || UFile::memmap(PROT_READ | PROT_WRITE) == false) { U_ERROR("cannot init log file %.*S", U_FILE_TO_TRACE(*this)); return; } if (bsize) ptr_log_data->file_ptr = file_size; // append mode else { // NB: we can have a previous crash without resizing the file or we are an other process (apache like log)... char* ptr = (char*) u_find(UFile::map, file_size, U_CONSTANT_TO_PARAM(U_MARK_END)); U_INTERNAL_DUMP("ptr = %p", ptr) if (ptr) { ptr_log_data->file_ptr = ptr - UFile::map; // NB: we can be an other process that manage this file (apache like log)... (void) memcpy(ptr, U_CONSTANT_TO_PARAM(U_MARK_END)); UFile::msync(ptr + U_CONSTANT_SIZE(U_MARK_END), UFile::map, MS_SYNC); } U_INTERNAL_ASSERT_MINOR(ptr_log_data->file_ptr, UFile::st_size) } log_file_sz = UFile::st_size; } U_INTERNAL_DUMP("ptr_log_data->file_ptr = %u UFile::st_size = %u log_gzip_sz = %u", ptr_log_data->file_ptr, UFile::st_size, log_gzip_sz) U_INTERNAL_ASSERT(ptr_log_data->file_ptr <= UFile::st_size) lock = U_NEW(ULock); U_Log_syslog(this) = false; ptr_log_data->gzip_len = 0; ptr_log_data->file_page = ptr_log_data->file_ptr; #ifdef USE_LIBZ char suffix[32]; uint32_t len_suffix = u__snprintf(suffix, sizeof(suffix), ".%4D.gz"); buf_path_compress = U_NEW(UString(MAX_FILENAME_LEN)); char* ptr = buf_path_compress->data(); if (dir_log_gz == 0) { (void) UFile::setPathFromFile(*this, ptr, suffix, len_suffix); buf_path_compress->size_adjust(); index_path_compress = (buf_path_compress->size() - len_suffix + 1); } else { UString name = UFile::getName(); uint32_t len = u__strlen(dir_log_gz, __PRETTY_FUNCTION__), sz = name.size(); U_MEMCPY(ptr, dir_log_gz, len); ptr += len; *ptr++ = '/'; buf_path_compress->size_adjust(len + 1 + sz + len_suffix); U_MEMCPY(ptr, name.data(), sz); ptr += sz; U_MEMCPY(ptr, suffix, len_suffix); index_path_compress = buf_path_compress->distance(ptr) + 1; buf_path_compress->UString::setNullTerminated(); } U_INTERNAL_DUMP("buf_path_compress(%u) = %.*S index_path_compress = %u", buf_path_compress->size(), U_STRING_TO_TRACE(*buf_path_compress), index_path_compress) #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); // manage options time_t queue_time = 0; UString outpath, result; bool include = false, bstdin = false; if (UApplication::isOptions()) { cfg_str = opt['c']; upload = opt['u']; bstdin = (opt['s'] == U_STRING_FROM_CONSTANT("1")); include = (opt['i'] == U_STRING_FROM_CONSTANT("1")); outpath = opt['o']; queue_time = opt['q'].strtol(); } // manage arg operation UString url(argv[optind++]); // manage file configuration if (cfg_str.empty()) cfg_str = U_STRING_FROM_CONSTANT(U_SYSCONFDIR "/uclient.cfg"); cfg.UFile::setPath(cfg_str); // ---------------------------------------------------------------------------------------------------------------------------------- // uclient - configuration parameters // ---------------------------------------------------------------------------------------------------------------------------------- // ENABLE_IPV6 flag to indicate use of ipv6 // SERVER host name or ip address for server // PORT port number for the server // // PID_FILE write pid on file indicated // RES_TIMEOUT timeout for response from server // // LOG_FILE locations for file log // // CERT_FILE certificate of client // KEY_FILE private key of client // PASSWORD password for private key of client // CA_FILE locations of trusted CA certificates used in the verification // CA_PATH locations of trusted CA certificates used in the verification // VERIFY_MODE mode of verification (SSL_VERIFY_NONE=0, SSL_VERIFY_PEER=1, SSL_VERIFY_FAIL_IF_NO_PEER_CERT=2, SSL_VERIFY_CLIENT_ONCE=4) // CIPHER_SUITE cipher suite model (Intermediate=0, Modern=1, Old=2) // // FOLLOW_REDIRECTS if yes manage to automatically follow redirects from server // USER if manage to follow redirects, in response to a HTTP_UNAUTHORISED response from the HTTP server: user // PASSWORD_AUTH if manage to follow redirects, in response to a HTTP_UNAUTHORISED response from the HTTP server: password // ---------------------------------------------------------------------------------------------------------------------------------- client = new UHttpClient<USSLSocket>(&cfg); user = cfg[*UString::str_USER]; password = cfg[U_STRING_FROM_CONSTANT("PASSWORD_AUTH")]; follow_redirects = cfg.readBoolean(U_STRING_FROM_CONSTANT("FOLLOW_REDIRECTS")); client->setFollowRedirects(follow_redirects); client->getResponseHeader()->setIgnoreCase(true); client->setRequestPasswordAuthentication(user, password); UApplication::exit_value = 1; loop: if (upload) { UFile file(upload); if (client->upload(url, file)) UApplication::exit_value = 0; } else if (client->connectServer(url)) { bool ok; if (bstdin == false) ok = client->sendRequest(); else { UString req(U_CAPACITY); UServices::readEOF(STDIN_FILENO, req); if (req.empty()) U_ERROR("cannot read data from <stdin>"); ok = client->sendRequest(req); } if (ok) UApplication::exit_value = 0; } result = (include ? client->getResponse() : client->getContent()); if (result) { # ifdef USE_LIBZ if (UStringExt::isGzip(result)) result = UStringExt::gunzip(result); # endif if (outpath) UFile::writeTo(outpath, result); else (void) write(1, U_STRING_TO_PARAM(result)); } if (queue_time) { UTimeVal to_sleep(queue_time / 10L); U_INTERNAL_ASSERT_EQUALS(UClient_Base::queue_dir, 0) if (result.empty() && UApplication::exit_value == 1) { to_sleep.nanosleep(); goto loop; } UFile file; char mask[100U]; uint32_t i, n, pos; UVector<UString> vec(64); UString req, name, location(U_CAPACITY); uint32_t mask_len = u__snprintf(mask, sizeof(mask), "%.*s.*", U_STRING_TO_TRACE(client->UClient_Base::host_port)); to_sleep.setSecond(to_sleep.getSecond() * 10L); U_MESSAGE("monitoring directory %.*S every %u sec - file mask: %.*S", U_STRING_TO_TRACE(*UString::str_CLIENT_QUEUE_DIR), to_sleep.getSecond(), mask_len, mask); # ifdef USE_LIBSSL client->UClient_Base::setActive(false); # endif UServer_Base::timeoutMS = client->UClient_Base::timeoutMS; UDirWalk dirwalk(*UString::str_CLIENT_QUEUE_DIR, mask, mask_len); while (true) { for (i = 0, n = dirwalk.walk(vec, U_ALPHABETIC_SORT); i < n; ++i) // NB: vec is sorted by string compare... { file.setPath(vec[i]); // ----------------------------------------------------------------------------- // NB: sometime there is a strange behaviour on openWRT (overlayfs) after unlink // ----------------------------------------------------------------------------- // wifi-aaa.comune.fi.it.090513_132007_139 -> (overlay-whiteout) // ----------------------------------------------------------------------------- req = file.getContent(); if (req) { name = file.getName(); pos = name.find_last_of('.'); U_INTERNAL_ASSERT_DIFFERS(pos, U_NOT_FOUND) location.snprintf("http://%.*s", pos, name.data()); (void) location.shrink(); if (client->connectServer(location) == false || client->sendRequest(req) == false) { break; } } (void) file._unlink(); } vec.clear(); if (client->isOpen()) client->close(); to_sleep.nanosleep(); } } client->closeLog(); }
ULog::ULog(const UString& path, uint32_t _size, const char* dir_log_gz) : UFile(path, 0) { U_TRACE_REGISTER_OBJECT(0, ULog, "%V,%u,%S", path.rep, _size, dir_log_gz) lock = 0; ptr_log_data = 0; log_file_sz = log_gzip_sz = 0; U_Log_start_stop_msg(this) = false; #ifdef USE_LIBZ buf_path_compress = 0; index_path_compress = 0; #endif if (UFile::getPath().equal(U_CONSTANT_TO_PARAM("syslog"))) { U_Log_syslog(this) = true; # ifndef _MSWINDOWS_ openlog(u_progname, LOG_PID, LOG_LOCAL0); # endif return; } if (UFile::creat(O_RDWR | O_APPEND, 0664) == false) { # ifndef U_COVERITY_FALSE_POSITIVE U_ERROR("cannot creat log file %.*S", U_FILE_TO_TRACE(*this)); # endif return; } /** * typedef struct log_data { * uint32_t file_ptr; * uint32_t file_page; * uint32_t gzip_len; * sem_t lock_shared; * char spinlock_shared[1]; * // --------------> maybe unnamed array of char for gzip compression... * } log_data; */ ptr_log_data = U_MALLOC_TYPE(log_data); ptr_log_data->file_ptr = 0; if (_size) { uint32_t file_size = UFile::size(); bool bsize = (file_size != _size); if ((bsize && UFile::ftruncate(_size) == false) || UFile::memmap(PROT_READ | PROT_WRITE) == false) { U_ERROR("cannot init log file %.*S", U_FILE_TO_TRACE(*this)); return; } if (bsize) ptr_log_data->file_ptr = file_size; // append mode else { // NB: we can have a previous crash without resizing the file or we are an other process (apache like log)... char* ptr = (char*) u_find(UFile::map, file_size, U_CONSTANT_TO_PARAM(U_MARK_END)); if (ptr) { ptr_log_data->file_ptr = ptr - UFile::map; // NB: we can be an other process that manage this file (apache like log)... u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('\n','\n','\n','\n','\n','\n','\n','\n')); u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('\n','\n','\n','\n','\n','\n','\n','\n')); u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('\n','\n','\n','\n','\n','\n','\n','\n')); UFile::msync(ptr + U_CONSTANT_SIZE(U_MARK_END), UFile::map, MS_SYNC); } U_INTERNAL_ASSERT_MINOR(ptr_log_data->file_ptr, UFile::st_size) } log_file_sz = UFile::st_size; } U_INTERNAL_ASSERT(ptr_log_data->file_ptr <= UFile::st_size) lock = U_NEW(ULock); U_Log_syslog(this) = false; ptr_log_data->gzip_len = 0; ptr_log_data->file_page = ptr_log_data->file_ptr; #ifdef USE_LIBZ char suffix[32]; uint32_t len_suffix = u__snprintf(suffix, sizeof(suffix), ".%4D.gz"); buf_path_compress = U_NEW(UString(MAX_FILENAME_LEN)); char* ptr = buf_path_compress->data(); if (dir_log_gz == 0) { # ifndef U_COVERITY_FALSE_POSITIVE // Uninitialized pointer read (UNINIT) (void) UFile::setPathFromFile(*this, ptr, suffix, len_suffix); # endif buf_path_compress->size_adjust(); index_path_compress = (buf_path_compress->size() - len_suffix + 1); } else { UString name = UFile::getName(); uint32_t len = u__strlen(dir_log_gz, __PRETTY_FUNCTION__), sz = name.size(); (void) memcpy(ptr, dir_log_gz, len); ptr += len; *ptr++ = '/'; buf_path_compress->size_adjust(len + 1 + sz + len_suffix); (void) memcpy(ptr, name.data(), sz); ptr += sz; (void) memcpy(ptr, suffix, len_suffix); index_path_compress = buf_path_compress->distance(ptr) + 1; } #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); UString riga; const char* p = argv[optind++]; UString content1 = UFile::contentOf(UString(p, strlen(p))), content2 = UFile::contentOf(UString(argv[optind])); UVector<UString> vec_entry(10), vec_ap_name(content1), // '\n'), vec_events_log(content2, '\n'); /* vec_ap_name.sort(); riga = vec_ap_name.join('\n'); (void) write(1, U_STRING_TO_PARAM(riga)); U_EXIT(1); */ // ........ // 2013/09/15 03:49:58 op: MAC_AUTH_all, uid: 60:fa:cd:7d:14:06, // ap: [email protected]:5280/wimoMichelangelo-r29587_rspro, // ip: 172.16.69.111, mac: 60:fa:cd:7d:14:06, timeout: 93, traffic: 295, policy: DAILY // ........ UString ap_entry, ap_name, ap_address1, ap_address2; for (uint32_t i = 0, n = vec_events_log.size(); i < n; ++i) { (void) vec_entry.split(vec_events_log[i], ','); ap_entry = vec_entry[2]; uint32_t pos1 = ap_entry.find_first_of('@'), pos2 = ap_entry.find_first_of('/', pos1), pos3 = pos1+1, len3 = pos2-pos1-6; ap_name = ap_entry.substr(pos2+1); ap_address1 = ap_entry.substr(pos3, len3); uint32_t pos = vec_ap_name.findSorted(ap_name, false, true); if (pos == U_NOT_FOUND) { char buffer[4096]; (void) write(2, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("NOT FOUND: %.*s %.*s %.*s\n"), U_STRING_TO_TRACE(ap_name), U_STRING_TO_TRACE(ap_address1), U_STRING_TO_TRACE(ap_address2))); } else { ap_address2 = vec_ap_name[pos+1]; if (ap_address1 != ap_address2) { char buffer[4096]; (void) write(2, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("ERROR: %.*s %.*s %.*s\n"), U_STRING_TO_TRACE(ap_name), U_STRING_TO_TRACE(ap_address1), U_STRING_TO_TRACE(ap_address2))); } vec_entry.replace(2, ap_entry.replace(pos3, len3, ap_address2)); } riga = vec_entry.join(','); (void) write(1, U_STRING_TO_PARAM(riga)); (void) write(1, U_CONSTANT_TO_PARAM("\n")); vec_entry.clear(); } }
void run(int argc, char* argv[], char* env[]) { U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env) UApplication::run(argc, argv, env); // LDAP attribute for devices // manage arg operation // manage file configuration // manage options // login to LDAP # include "common1.cpp" if (UApplication::isOptions()) { value = opt['b']; if (value.empty() == false) DN_filter = value; } // get filter attribute from LDAP int i, n = ldap.search(DN_filter.c_str(), LDAP_SCOPE_BASE, (char**)filter_attr_name); if (n != 1) U_ERROR("cannot get filter attribute from LDAP..."); ULDAPEntry filter_entry(FILTER_NUM_ATTR, filter_attr_name); ldap.get(filter_entry); // dato filtro avvio ricerca policy usando valore attributo filtro <tnetLrpFilterRule> const char* filtro = filter_entry.getCStr(FILTER_ATTR_CN_POS); const char* rule = filter_entry.getCStr(FILTER_ATTR_RULE_POS); U_INTERNAL_DUMP("RULE = %S FILTRO = %S", rule, filtro) // get policy attribute from LDAP ULDAP ldap_url; char first_char = rule[0]; bool policy_by_url = (first_char != '('); if (policy_by_url) { if (first_char == '/') { static char url[1024]; (void) snprintf(url, sizeof(url), "ldap://%s%s", LDAP_host.c_str(), rule); rule = url; } if (ldap_url.init(rule) == false || ldap_url.set_protocol() == false || ldap_url.simple_bind() == false) { U_ERROR("login to LDAP with URL failed..."); } n = ldap_url.search(); } else { n = ldap.search("o=Policies,o=tnet", LDAP_SCOPE_SUBTREE, (char**)policy_attr_name, rule); } if (n <= 0) U_ERROR("cannot find policy from LDAP..."); ULDAPEntry policy_entry(POLICY_NUM_ATTR, policy_attr_name, n); if (policy_by_url) ldap_url.get(policy_entry); else ldap.get(policy_entry); // init log const char* log_name = filtro; # include "common2.cpp" // loop for every policy int j, k; char ipmask[64]; const char* ptr; const char* policy; const char* ip_mask; const char* ip_device; char request_buffer[4096 * 4]; const char* binddn_device = LDAP_binddn_device.c_str(); for (i = 0; i < n; ++i) { policy = policy_entry.getCStr(POLICY_ATTR_CN_POS, i); U_INTERNAL_DUMP("POLICY = %S %S", policy_entry[i], policy) // data policy avvio ricerca lista device usando valore attributo policy <tnetLrpIpNetworkNumber> ip_mask = policy_entry.getCStr(POLICY_ATTR_IPMASK_POS, i); (void) snprintf(ipmask, sizeof(ipmask), "(tnetLrpIpHostNumber=%s*)", ip_mask); j = ldap.search(binddn_device, LDAP_SCOPE_SUBTREE, (char**)device_attr_name, ipmask); if (j <= 0) continue; ptr = policy_entry.getCStr(POLICY_ATTR_POLICY_POS, i); // check if to skip xml header... if (U_STRNEQ(ptr, "<?xml")) { ptr += 5; while (*ptr++ != '\n'); } // build request static const char* request_tmpl = \ // "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE REQUEST SYSTEM \"lrp_request.dtd\">" "<REQUEST sid=\"sid1\" version=\"1\"><IMPORT-POLICYLABEL name=\"%s\">%s</IMPORT-POLICYLABEL></REQUEST>" "<REQUEST sid=\"sid2\" version=\"1\"><EXECUTE-POLICYLABEL name=\"%s\" command=\"%s\"/></REQUEST>"; request_size = u__snprintf(request_buffer, sizeof(request_buffer), request_tmpl, policy, ptr, policy, operation); request = UString(request_buffer, request_size); // write request to file # include "common3.cpp" // set devices attribute for LDAP ULDAPEntry device_entry(DEVICE_NUM_ATTR, device_attr_name, j); // get devices attribute from LDAP // loop for every device // fork: child // send request to device // write response to file # include "common4.cpp" // parent } exit_value = proc.waitAll(); log.close(); }