VOID EmitWrite(THREADID threadid, UINT32 size) { assert(size <= 100); char bytes[101]; struct timeval tv; VOID *ea = WriteEa[threadid]; if(MemregionTracker::address_mapped(ea)) { gettimeofday(&tv, NULL); PIN_SafeCopy(&bytes[0], static_cast<char *>(ea), size); bytes[size] = '\0'; m_dump_bytes(bytes, size); if(mwrite_tracker[threadid].next_location == ea && time_diff(tv, mwrite_tracker[threadid].last_time) < coalesce_microsecs) { mwrite_tracker[threadid].size += size; } else { flush_mwrite(threadid); PrintTime(&tv); output_stacktrace(); if(print_chars) { char tmp[100]; printable_string(bytes, tmp, 100); mprintf("mwrite(%p, \"%s\"..., ", ea, tmp); } else { mprintf("mwrite(%p, \"\"..., ", ea); } mwrite_tracker[threadid].size = size; } mwrite_tracker[threadid].next_location = (UINT8 *)ea + size; mwrite_tracker[threadid].last_time = tv; } }
static void unexpand(FILE *file, unsigned tab_size, unsigned opt) { char *line; while ((line = xmalloc_fgets(file)) != NULL) { char *ptr = line; unsigned column = 0; while (*ptr) { unsigned n; unsigned len = 0; while (*ptr == ' ') { ptr++; len++; } column += len; if (*ptr == '\t') { column += tab_size - (column % tab_size); ptr++; continue; } n = column / tab_size; if (n) { len = column = column % tab_size; while (n--) putchar('\t'); } if ((opt & OPT_INITIAL) && ptr != line) { printf("%*s%s", len, "", ptr); break; } n = strcspn(ptr, "\t "); printf("%*s%.*s", len, "", n, ptr); # if ENABLE_UNICODE_SUPPORT { char c; uni_stat_t uni_stat; c = ptr[n]; ptr[n] = '\0'; printable_string(&uni_stat, ptr); len = uni_stat.unicode_width; ptr[n] = c; } # else len = n; # endif ptr += n; column = (column + len) % tab_size; } free(line); } }
void viewBatteryLevels(void){ char Buffer[11]; PString printable_string(Buffer, sizeof(Buffer)); clearLCD(); // display only battery voltage goToLine(2); LCDprint("Battery Voltages:"); do{ goToLine(3); printable_string = "- Board: "; printable_string += tempBat; printable_string += "V"; LCDprintConst(printable_string); goToLine(4); printable_string = "- ECG: "; printable_string += tempECGBat; printable_string += "V"; LCDprintConst(printable_string); if(LEFT_BUTTON_PRESSED){ break; } #ifdef ConnectedUSB // Echo data from the VDIP back to the host if conected to a PC processVdipBuffer(); #endif // test buttons test_buttons(); sendSensorValues(); #ifdef EnableLogging FillUSBBuffers(); if(BuffersFull == 1){ printUSBBUffer(); } #endif }while(1); }
static void expand(FILE *file, unsigned tab_size, unsigned opt) { char *line; while ((line = xmalloc_fgets(file)) != NULL) { unsigned char c; char *ptr; char *ptr_strbeg; ptr = ptr_strbeg = line; while ((c = *ptr) != '\0') { if ((opt & OPT_INITIAL) && !isblank(c)) { /* not space or tab */ break; } if (c == '\t') { unsigned len; *ptr = '\0'; # if ENABLE_UNICODE_SUPPORT { uni_stat_t uni_stat; printable_string(&uni_stat, ptr_strbeg); len = uni_stat.unicode_width; } # else len = ptr - ptr_strbeg; # endif len = tab_size - (len % tab_size); /*while (ptr[1] == '\t') { ptr++; len += tab_size; } - can handle many tabs at once */ printf("%s%*s", ptr_strbeg, len, ""); ptr_strbeg = ptr + 1; } ptr++; } fputs(ptr_strbeg, stdout); free(line); } }
int main(int argc, char *argv[]) { globus_url_t url; int i; int result; globus_bool_t ok; int num_successful = 0; int rc; globus_module_activate(GLOBUS_COMMON_MODULE); globus_libc_printf("Testing globus_url_parse()\n"); if(argc > 1) { globus_libc_printf("Bypassing standard tests, parsing command line arguments\n"); for(i = 1; i < argc; i++) { globus_libc_printf("Parsing \"%s\"\n", argv[i]); result = globus_url_parse(argv[i], &url); globus_libc_printf("Parse returned %d\n", result); if(result == GLOBUS_SUCCESS) { #define printable_string(x) (x==GLOBUS_NULL ? "NULL" : x) globus_libc_printf("url_scheme = \"%s\"\n" "url_scheme_type = %d\n" "user = \"%s\"\n" "password = \"%s\"\n" "host = \"%s\"\n" "port = %u\n" "url_path = \"%s\"\n" "dn = \"%s\"\n" "attributes = \"%s\"\n" "scope = \"%s\"\n" "filter = \"%s\"\n" "url_specific_part = \"%s\"\n", printable_string(url.scheme), url.scheme_type, printable_string(url.user), printable_string(url.password), printable_string(url.host), url.port, printable_string(url.url_path), printable_string(url.dn), printable_string(url.attributes), printable_string(url.scope), printable_string(url.filter), printable_string(url.url_specific_part)); result = globus_url_destroy(&url); globus_libc_printf("globus_url_destroy returned %d\n", result); } } globus_module_deactivate_all(); return 0; } for(i = 0; i < NUM_TESTS; i++) { ok = GLOBUS_TRUE; result = globus_url_parse(test_urls[i].url, &url); if(result != test_urls[i].result) { globus_libc_printf( "test %d: FAILED (url=%s, expected %d, parse returned %d)\n", i+1, test_urls[i].url, test_urls[i].result, result); ok = GLOBUS_FALSE; } if(test_urls[i].result == GLOBUS_SUCCESS) { /* Verify that parse did what we wanted it to do */ if(!compare_strings(url.scheme, test_urls[i].url_result.scheme, i+1, "scheme")) { ok = GLOBUS_FALSE; } if(!compare_ints(url.scheme_type, test_urls[i].url_result.scheme_type, i+1, "scheme_type")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.user, test_urls[i].url_result.user, i+1, "user")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.password, test_urls[i].url_result.password, i+1, "password")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.host, test_urls[i].url_result.host, i+1, "host")) { ok = GLOBUS_FALSE; } if(!compare_ints((int) url.port, (int) test_urls[i].url_result.port, i+1, "port")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.url_path, test_urls[i].url_result.url_path, i+1, "url_path")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.dn, test_urls[i].url_result.dn, i+1, "dn")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.attributes, test_urls[i].url_result.attributes, i+1, "attributes")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.scope, test_urls[i].url_result.scope, i+1, "scope")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.filter, test_urls[i].url_result.filter, i+1, "filter")) { ok = GLOBUS_FALSE; } if(!compare_strings(url.url_specific_part, test_urls[i].url_result.url_specific_part, i+1, "url_specific_part")) { ok = GLOBUS_FALSE; } result = globus_url_destroy(&url); if(result != GLOBUS_SUCCESS) { globus_libc_printf( "test %d: FAILED (could not destroy parsed url)\n", i+1); ok = GLOBUS_FALSE; } } if(ok) { num_successful++; } } globus_libc_printf("------------------------------------\n"); if(num_successful == i) { globus_libc_printf("ALL TESTS SUCCESSFUL\n"); } else { globus_libc_printf("%d OF %d TESTS FAILED\n", i - num_successful, i); } globus_libc_printf("------------------------------------\n"); rc = (num_successful == i) ? 0 : 1; globus_module_deactivate_all(); return rc; }