/** * Catches a stack overflow error. * * \req \req_ehandle The \program \shall catch and log errors. * * \todo Log errors. */ void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName) { lstr("\n\nvApplicationStackOverflowHook:"); lhex((unsigned int)pxTask);lstr((char*)pcTaskName);crlf(); for( ;; ); }
/** * I/O task: reads and writes the I/O. */ static void io_task(void *params) { portTickType last_wake_time; int ticks=0; #if (PART != LM3S2110) adc_setup(); #endif #if (DEBUG > 0) lprintf("io_task() running.\r\n"); #endif /* Start our periodic time starting in 3. 2. 1. NOW! */ last_wake_time = xTaskGetTickCount(); while(1) { /* forever loop */ wdt_checkin[wdt_io] = 0; #if (PART != LM3S2110) scan_proc_adc(); #endif /* * Send a char out the serial port every 10 sec. */ if (ticks>=POLL_HZ*10) { lstr("."); ticks=0; } ticks++; vTaskDelayUntil(&last_wake_time, POLL_DELAY); } }
bool CDiagStrPathMatcher::Match(const char* str) const { if ( !str ) return false; string lstr(str); size_t pos; # ifdef NCBI_OS_MSWIN // replace \ in windows path to / while ( (pos = lstr.find('\\')) != string::npos ) lstr[pos] = '/'; # endif pos = lstr.find(m_Pattern); if (pos == string::npos) return false; // check if found pattern after src/ or include/ if ( !(pos > 2 && lstr.substr(pos-3, 3) == "src" ) && !(pos > 6 && lstr.substr(pos-7, 7) == "include" ) ) return false; // if pattern ends with / check that pattern matches all dirs if (m_Pattern[m_Pattern.size()-1] != '/') return true; // '/' should not be after place we found m_Pattern return (lstr.find('/', pos + m_Pattern.size()) == string::npos); }
int main() { std::vector<std::string> l_unique; std::istream_iterator<std::string> in(std::cin), eof; std::list<std::string> lstr(in, eof); std::unique_copy(lstr.begin(), lstr.end(), back_inserter(l_unique)); for (auto str : l_unique) { std::cout << str << " "; } std::cout << std::endl; return 0; }
/* static function, throws OperationError, has no traces but optional pstate for returned value */ Value_Ptr op_strings(Sass::Operand operand, Value& lhs, Value& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed) { enum Sass_OP op = operand.operand; String_Quoted_Ptr lqstr = Cast<String_Quoted>(&lhs); String_Quoted_Ptr rqstr = Cast<String_Quoted>(&rhs); std::string lstr(lqstr ? lqstr->value() : lhs.to_string(opt)); std::string rstr(rqstr ? rqstr->value() : rhs.to_string(opt)); if (Cast<Null>(&lhs)) throw Exception::InvalidNullOperation(&lhs, &rhs, op); if (Cast<Null>(&rhs)) throw Exception::InvalidNullOperation(&lhs, &rhs, op); std::string sep; switch (op) { case Sass_OP::ADD: sep = ""; break; case Sass_OP::SUB: sep = "-"; break; case Sass_OP::DIV: sep = "/"; break; case Sass_OP::EQ: sep = "=="; break; case Sass_OP::NEQ: sep = "!="; break; case Sass_OP::LT: sep = "<"; break; case Sass_OP::GT: sep = ">"; break; case Sass_OP::LTE: sep = "<="; break; case Sass_OP::GTE: sep = ">="; break; default: throw Exception::UndefinedOperation(&lhs, &rhs, op); break; } if (op == Sass_OP::ADD) { // create string that might be quoted on output (but do not unquote what we pass) return SASS_MEMORY_NEW(String_Quoted, pstate, lstr + rstr, 0, false, true); } // add whitespace around operator // but only if result is not delayed if (sep != "" && delayed == false) { if (operand.ws_before) sep = " " + sep; if (operand.ws_after) sep = sep + " "; } if (op == Sass_OP::SUB || op == Sass_OP::DIV) { if (lqstr && lqstr->quote_mark()) lstr = quote(lstr); if (rqstr && rqstr->quote_mark()) rstr = quote(rstr); } return SASS_MEMORY_NEW(String_Constant, pstate, lstr + sep + rstr); }
// Test to see if a list of features are implemented PRBool NS_SVG_TestFeatures(const nsAString& fstr) { nsAutoString lstr(fstr); // Get an iterator on the string PRInt32 vbegin = 0; PRInt32 vlen = lstr.Length(); while (vbegin < vlen) { PRInt32 vend = lstr.FindChar(PRUnichar(' '), vbegin); if (vend == kNotFound) { vend = vlen; } if (NS_SVG_TestFeature(Substring(lstr, vbegin, vend-vbegin)) == PR_FALSE) { return PR_FALSE; } vbegin = vend+1; } return PR_TRUE; }
// Test to see if a feature is implemented PRBool NS_SVG_TestFeature(const nsAString& fstr) { if (!nsSVGUtils::SVGEnabled()) { return PR_FALSE; } nsAutoString lstr(fstr); lstr.StripWhitespace(); #ifdef DEBUG_scooter NS_ConvertUTF16toUTF8 feature(lstr); printf("NS_SVG_TestFeature: testing for %s\n", feature.get()); #endif #define SVG_SUPPORTED_FEATURE(str) if (lstr.Equals(NS_LITERAL_STRING(str).get())) return PR_TRUE; #define SVG_UNSUPPORTED_FEATURE(str) #include "nsSVGFeaturesList.h" #undef SVG_SUPPORTED_FEATURE #undef SVG_UNSUPPORTED_FEATURE return PR_FALSE; }
void CPocoLoggerTester::test_LogStream() { Poco::Logger& logger = Poco::Logger::get("test_LogStream"); Poco::LogStream lstr(logger); lstr << "This is a test" << std::endl; }
//***************************************************************************** // //! Initializes the lwIP TCP/IP stack. //! Call it from your main to initialize the lwip //! //! \param pucMAC is a pointer to a six byte array containing the MAC //! address to be used for the interface. //! \param ulIPAddr is the IP address to be used (static). //! \param ulNetMask is the network mask to be used (static). //! \param ulGWAddr is the Gateway address to be used (static). //! \param ulIPMode is the IP Address Mode. \b IPADDR_USE_STATIC will force //! static IP addressing to be used, \b IPADDR_USE_DHCP will force DHCP with //! fallback to Link Local (Auto IP), while \b IPADDR_USE_AUTOIP will force //! Link Local only. //! //! This function performs initialization of the lwIP TCP/IP stack for the //! Stellaris Ethernet MAC, including DHCP and/or AutoIP, as configured. //! //! \return None. // //***************************************************************************** void LWIPServiceTaskInit(IP_CONFIG *ipCfg) { struct ip_addr ip_addr; struct ip_addr net_mask; struct ip_addr gw_addr; LWIP_ASSERT("ipCfg != NULL", (ipCfg != NULL)); // Check the parameters. #if LWIP_DHCP && LWIP_AUTOIP ASSERT((ipCfg->IPMode == IPADDR_USE_STATIC) || (ipCfg->IPMode == IPADDR_USE_DHCP) || (ipCfg->IPMode == IPADDR_USE_AUTOIP)) #elif LWIP_DHCP ASSERT((ipCfg->IPMode == IPADDR_USE_STATIC) || (ipCfg->IPMode == IPADDR_USE_DHCP)) #elif LWIP_AUTOIP ASSERT((ipCfg->IPMode == IPADDR_USE_STATIC) || (ipCfg->IPMode == IPADDR_USE_AUTOIP)) #else ASSERT(ipCfg->IPMode == IPADDR_USE_STATIC) #endif LWIP_DEBUGF(DHCP_DEBUG, ("----- LWIP_DEBUGF calling tcpip_init -----\n")); // Start the TCP/IP thread & init stuff tcpip_init(NULL, NULL); vTaskDelay(100 / portTICK_RATE_MS); // Setup the network address values. if (ipCfg->IPMode == IPADDR_USE_STATIC) { ip_addr.addr = htonl(ipCfg->IPAddr); net_mask.addr = htonl(ipCfg->NetMask); gw_addr.addr = htonl(ipCfg->GWAddr); } else { ip_addr.addr = 0; net_mask.addr = 0; gw_addr.addr = 0; } // Create, configure and add the Ethernet controller interface with // default settings. // WARNING: This must only be run after the OS has been started. // Typically this is the case, however, if not, you must place this // in a post-OS initialization // @SEE http://lwip.wikia.com/wiki/Initialization_using_tcpip.c netif_add(&lwip_netif, &ip_addr, &net_mask, &gw_addr, NULL, ethernetif_init, tcpip_input); netif_set_default(&lwip_netif); // Start DHCP, if enabled. #if LWIP_DHCP if (ipCfg->IPMode == IPADDR_USE_DHCP) { LWIP_DEBUGF(DHCP_DEBUG, ("----- Starting DHCP client -----\n")); dhcp_start(&lwip_netif); } #endif // Start AutoIP, if enabled and DHCP is not. #if LWIP_AUTOIP if (ipCfg->IPMode == IPADDR_USE_AUTOIP) { autoip_start(&lwip_netif); } #endif if (ipCfg->IPMode == IPADDR_USE_STATIC) { // Bring the interface up. netif_set_up(&lwip_netif); } vTaskDelay(1000/portTICK_RATE_MS); while (0 == netif_is_up(&lwip_netif)) { lstr("<delay 5s>"); vTaskDelay(5000/portTICK_RATE_MS); #if LWIP_DHCP if (ipCfg->IPMode == IPADDR_USE_DHCP) { if (0 == netif_is_up(&lwip_netif)) { lstr("<dhcp_renew>"); dhcp_renew(&lwip_netif); } } #endif } /* Initialize HTTP */ #ifdef INCLUDE_HTTPD_SSI init_ssi_cgi_handlers(); #else #ifdef INCLUDE_HTTPD_CGI init_ssi_cgi_handlers(); #endif #endif httpd_init(); }
/** * Main function * * This is the traditional C main(). */ int main(void) { #if USE_PROGRAM_STARTUP program_startup(); #else char s[64]; /* sprintf string */ unsigned long why; /* Why did we get reset? Why? */ prvSetupHardware(); init_logger(); #if PART == LM3S8962 RIT128x96x4Init(1000000); #endif /* * \todo maybe this needs to be earlier or later in the code. * Enable fault handlers in addition to FaultIsr() */ NVIC_SYS_HND_CTRL_R |= NVIC_SYS_HND_CTRL_USAGE |NVIC_SYS_HND_CTRL_BUS |NVIC_SYS_HND_CTRL_MEM; #if (PART != LM3S2110) /* * Allow the following to erase the permanent configuration flash page: * * make PROTECT_PERMCFG="-D PROTECT_PERMCFG=0" \ * ERASE_PERMCFG="-D ERASE_PERMCFG=1" * * The program will continue to erase the permanent configuration structure * at every powerup, so the program must be recompiled without the * ERASE_PERMCFG=1 part and reloaded to allow a permanent configuration * record to persist through power cycles. */ #if ERASE_PERMCFG #if !PROTECT_PERMCFG if (permcfg_erase()) { #if (PART == LM3S8962) RIT128x96x4StringDraw("permcfg Blank", 0, RITLINE(10), 15); #endif } else { #if (PART == LM3S8962) RIT128x96x4StringDraw("permcfg Not Blank", 0, RITLINE(10), 15); #endif } #endif #endif config_init(); #endif /** * \req \req_id The \program \shall identify: * - The program version. * - A copyright string. * - The board identification. * - The assembly identification. * - Network configuration information. * * \todo Issue #1175 Add software build time, git hash, software * version to build. */ lstr("\r\nCRI Quickstart\r\n"); #if (PART == LM3S2110) lstr("LM3S2110 Eval Board\r\n"); #elif (PART == LM3S8962) lstr("LM3S8962 Eval Board\r\n"); #elif (PART == LM3S9B96) lstr("LM3S9B96 Eval Board\r\n"); #endif lstr("Copyright (C) 2011 Consolidated Resource Imaging\r\n"); lprintf(" Software Build Date: %s\n", buildDate); #if (PART != LM3S2110) lprintf(" Assembly Part Number: %s\n", usercfg.assy_pn); lprintf("Assembly Serial Number: %s\n", usercfg.assy_sn); lprintf(" Board Part Number: %s\n", permcfg.bd_pn); lprintf(" Board Serial Number: %s\n", permcfg.bd_sn); lprintf("Notes:\r\n %s\r\n", usercfg.notes); #endif #if (PART == LM3S8962) /* * Display our configuration on the OLED display. */ RIT128x96x4StringDraw("CRI Quickstart", 0, RITLINE(0), 15); RIT128x96x4StringDraw("LM3S8962", 0, RITLINE(1), 15); /* * Split date * 0123456789012345678901234567890 * Sun, 08 May 2011 19:05:42 -0400 * * into: * 0123456789012345678901234567890 * Sun, 08 May 2011 * * and * * 0123456789012345678901234567890 * 19:05:42 -0400 */ strcpy(s,buildDate); s[16]=0; RIT128x96x4StringDraw(s, 0, RITLINE(2), 15); RIT128x96x4StringDraw(&s[17], 0, RITLINE(3), 15); #endif /** * \req \req_id The \program \shall identify: * - The reason for the reset. */ why = SysCtlResetCauseGet(); if (why != 0) { SysCtlResetCauseClear(why); lprintf("Reset reason: "); if (why & SYSCTL_CAUSE_LDO) lprintf("LDO "); if (why & SYSCTL_CAUSE_SW) lprintf("SW "); if (why & SYSCTL_CAUSE_WDOG) lprintf("WDOG "); if (why & SYSCTL_CAUSE_BOR) lprintf("Brown-out "); if (why & SYSCTL_CAUSE_POR) lprintf("Power-on "); if (why & SYSCTL_CAUSE_EXT) lprintf("External "); lprintf("\r\n"); } io_init(); #endif util_init(); /** * \req \req_tcpip The \program \shall support TCP/IP communications. * * Create the LWIP task if running on a processor that includes a MAC * and PHY. */ #if QUICK_ETHERNET if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) ) { xTaskCreate(ethernetThread, (signed char *)"eth-init", DEFAULT_STACK_SIZE, NULL, ETH_INIT_PRIORITY, NULL); } #endif /* * Enable interrupts... */ IntMasterEnable(); vSetupHighFrequencyTimer(); vTaskStartScheduler(); DPRINTF(0,"Idle Task Create Failed."); /* * Will only get here if there was insufficient memory to create the * idle task. */ for( ;; ); return 0; }
void Plugin::handleAdd(const std::string& name, const std::string& value) { addFile(value); return; LogStream lstr(Application::instance().logger()); lstr.information() << "Checking path" << std::endl; if (!hasGitDirectory()) { lstr.error() << "This is not a git repository" << std::endl; return; } File f(value); if (!f.exists()) { lstr.error() << value << " file does not exist" << std::endl; // TODO: Remove this file from index return; } bool isGitable = true; if (f.isDirectory()) { lstr.information() << "Can't add directory" << std::endl; return; // We need to process every that is not tracked } if (f.isDevice()) { isGitable = false; } if (f.isLink()) { isGitable = false; } Poco::Pipe out, err; Process::Args args; args.push_back("status"); args.push_back(value); args.push_back("-s"); Poco::ProcessHandle* git = new Poco::ProcessHandle(Poco::Process::launch("git", args, 0, &out, &err)); PipeInputStream str(out); std::string output; Poco::StreamCopier::copyToString(str, output); StringTokenizer st(output, " "); output = trim(output); for (auto it = st.begin(); it != st.end(); it++) { if ((*it).empty()) { continue; } if ((*it) == "M") { std::cout << "Modified" << std::endl; replaceWithLink(value); // Check if file is already in index - we may want to to update binary file } else if ((*it) == "??") { std::cout << "Not indexed" << std::endl; replaceWithLink(value); } else { std::cout << (*it).c_str() << std::endl; } } }