static void do_test2(ALLEGRO_COLOR src_col, ALLEGRO_COLOR dst_col, ALLEGRO_COLOR blend_col, int src_format, int dst_format, int src_mode, int dst_mode, int src_alpha, int dst_alpha, int operation) { ALLEGRO_COLOR reference, result, from_display; test_index++; if (test_only_index && test_index != test_only_index) return; reference = reference_implementation( src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation); result = test(src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation, false); if (!same_color(reference, result)) { test(src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation, true); printf("expected : "); print_color(reference); printf("\n"); printf("FAILED\n"); } else { printf(" OK"); fflush(stdout); } if (test_display) { dst_format = al_get_display_format(); from_display = al_get_pixel(al_get_backbuffer(), 0, 0); reference = reference_implementation( src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation); if (!same_color(reference, from_display)) { test(src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation, true); printf("displayed : "); print_color(from_display); printf("\n"); printf("expected : "); print_color(reference); printf("\n"); printf("(FAILED on display)\n"); } } }
void module_cpu_temp(char *s, char *conky) { // Add conditionals here int temp = atoi(conky); if(temp >= CPU_THRESHOLD) sprintf(s, "%s%s", s, print_color("FF0000")); else sprintf(s, "%s%s", s, print_color(NULL)); sprintf(s, "%s%d°C", s, temp); }
void module_wireless(char *s) { char *iw_cmd = "iwconfig wlp3s0 | awk '/Quality/{print $2}' | sed 's/.*=//' | awk -F\"/\" '{printf(\"%.0f%%\", $1/$2*100)}'"; FILE *iw_out = popen(iw_cmd, "r"); char *strength = malloc(8); strength = readsplit(&strength, iw_out, NULL); if(strcmp(strength, "") == 0) { sprintf(s, "%s%sW: down", s, print_color("FF0000")); return; } else { char *color; int strn = atoi(strength); if(strn <= WIRELESS_THRESHOLD) color = "FFFF00"; else color = "00FF00"; sprintf(s, "%s%sW: (%03d%%", s, print_color(color), strn); } FILE *ssid_out = popen("iwconfig wlp3s0 | egrep -o '\".*\"'", "r"); char **ssid = malloc(64); readsplit(ssid, ssid_out, "\""); sprintf(s, "%s at %s)", s, ssid[1]); FILE *ip_out = popen("ifconfig wlp3s0 | egrep -o 'inet ([0-9]+\\.?)*'", "r"); char **ip = malloc(64); readsplit(ip, ip_out, " "); if(*ip != NULL) sprintf(s, "%s %s", s, ip[1]); else sprintf(s, "%s aquiring...", s); pclose(iw_out); pclose(ssid_out); pclose(ip_out); free(strength); free(ssid); free(ip); }
gchar * mix_bg_fg (GtkWidget * win, const gchar * state, float alpha, float beta) { GdkColor color, bgColor, fgColor; GtkStyle *style; gchar *s; gint n; TRACE ("entering mix_bg_fg_ui"); g_return_val_if_fail (win != NULL, NULL); g_return_val_if_fail (GTK_IS_WIDGET (win), NULL); g_return_val_if_fail (GTK_WIDGET_REALIZED (win), NULL); style = get_ui_style (win); n = state_value (state); bgColor = query_color (win, style->bg[n]); fgColor = query_color (win, style->fg[n]); color = shade (mix (bgColor, fgColor, alpha), beta); s = print_color (win, color); TRACE ("mix_bg_fg[%s]=%s", state, s); return (s); }
const char* warn(const char* message) { #if defined(__is_avocados_kernel) print_color(LIGHT_BROWN, "Warning: ", message); #else #endif return message; }
const char* err(const char* message) { #if defined(__is_avocados_kernel) print_color(LIGHT_RED, "Error: ", message); #else #endif return message; }
const char* info(const char* message) { #if defined(__is_avocados_kernel) print_color(LIGHT_BLUE, "Info: ", message); #else #endif return message; }
int print_rc_colors (char *name, GdkColor *x, int n, GtkRcFlags *flags, GtkRcFlags mask) { int i; for (i = 0; i < n; i++) { if (flags[i] & mask) break; } if (i == n) return 1; printf ("(%s", name); for (i = 0; i < n; i++) { if (flags[i] & mask) { printf (" (%s . ", states[i]); print_color (x + i); printf (")"); } } printf (")\n"); return 0; }
int printcf(uint32_t color, const char *fmt, ...) { // Call vsnprintf instead of decoding here, saves function calls. if (!print_color) return -1; // guess memory size. // size_t newlen = strlen(fmt) * 2; // char *str = malloc(newlen); // FIXME: Since we don't quite have memory allocation yet, // allocate a buffer on the stack which will handle *MOST* // printf messages BUT NOT ALL! char str[(1 << 10)]; // 65536 chars va_list ap; va_start(ap, fmt); //vsnprintf(str, newlen, fmt, ap); int ret = vsnprintf(str, sizeof(str), fmt, ap); // Null-terminate str[ret] = 0; va_end(ap); // NOTE: we use ret here instead of sizeof(str) otherwise we're going // to basically start catting our kernel .text segment to the terminal // (which is nice and all but we just wanted to say hello world..) if (print_color) // print_color(str, newlen, VGAColor(COLOR_BLACK, COLOR_WHITE)); print_color(str, ret, color); return ret; // free(str); }
const char* success(const char* message) { #if defined(__is_avocados_kernel) print_color(LIGHT_GREEN, "Success: ", message); #else #endif return message; }
static gchar * print_colors (GtkWidget * win, GdkColor * x, int n) { GdkColor color; color = query_color (win, x[n]); return print_color(win, color); }
void main(void) { unsigned int eax, ebx, ecx, edx, a; char id[17]; clear_screen(); print_color("cpuid example\n", 0x09); cpuid(0, 0, &eax, &ebx, &ecx, &edx); print_num(eax); memcpy(id, &ebx, 4); memcpy(id + 4, &edx, 4); memcpy(id + 8, &ecx, 4); id[12] = 0; print(id); print("\n"); cpuid(1, 0, &eax, &ebx, &ecx, &edx); print("version: "); print_num(eax); for (a = 0x80000002; a <= 0x80000004; a++) { cpuid(a, 0, &eax, &ebx, &ecx, &edx); memcpy(id, &eax, 4); memcpy(id + 4, &ebx, 4); memcpy(id + 8, &ecx, 4); memcpy(id + 12, &edx, 4); id[16] = 0; print(id); print("\n"); } halt(); }
void module_battery(char *s, char **acpi) { if(*acpi == NULL) { sprintf(s, "%sNo battery", s); return; } char *ico = malloc(64); char *status = acpi[0]; int percent = atoi(acpi[1]); if(strcmp(acpi[0], "Discharging") == 0) { icon("bat_full_02", ico); status = "BATT"; } else if(strcmp(acpi[0], "Charging") == 0) { icon("ac", ico); status = "CHRG"; } else if(strcmp(acpi[0], "Unknown") == 0) { icon("ac", ico); status = "FULL"; } char *time = malloc(16); if(acpi[2] == NULL) time = ""; else sprintf(time, " %s", acpi[2]); if(strcmp(status, "BATT") == 0 && percent <= BATTERY_THRESHOLD) { icon("bat_low_02", ico); sprintf(s, "%s%s", s, print_color("FF0000")); } else sprintf(s, "%s%s", s, print_color(NULL)); sprintf(s, "%s%s %02d%% %s%s", s, status, percent, ico, time); free(ico); free(time); }
/* this hacky mess might use some optmizing */ void packet_print(rc_packet *packet) { int i; int def_color = 0; #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO console_info; if(GetConsoleScreenBufferInfo(console_handle, &console_info) != 0) def_color = console_info.wAttributes + 0x30; else def_color = 0x37; #endif /* colors enabled so try to handle the bukkit colors for terminal */ if(print_colors == 1) { for(i = 0; (unsigned char) packet->data[i] != 0; ++i) { if((unsigned char) packet->data[i] == 194) { continue; } // EMC if((unsigned char) packet->data[i] == 0xa7) { ++i; print_color(packet->data[i]); continue; } if(packet->data[i] == 0x0A) print_color(def_color); putchar(packet->data[i]); } print_color(def_color); /* cancel coloring */ } /* strip colors */ else { for(i = 0; (unsigned char) packet->data[i] != 0; ++i) { if((unsigned char) packet->data[i] == 0xa7) { ++i; continue; } putchar(packet->data[i]); } } /* print newline if string has no newline */ if(packet->data[i-1] != 10 && packet->data[i-1] != 13) putchar('\n'); }
void print_amb_light(t_env *e) { ft_putendl(" Ambient light ->"); ft_putstr(" intensity : "); ft_putfloat2(e->scene->amb_intensity); ft_putstr("\n color : "); print_color(e->scene->amb_color); ft_putendl(TERM_END); }
void Nwindow::print_line(string line, COLOR c){ int aspace = get_end(line); int bspace = get_start(line); //assert(bspace >= 0 && aspace >= 0); int prev_x = pos_x; move(pos_y,pos_x + bspace); print_color(line.substr(bspace,line.length() - aspace),c); move(pos_y +1,prev_x); }
int main() { char *p="1234fd3"; print_color(*p,Red); print_color_str(p,Red); printf("%d\n",str2int(p)); window_col(); int i; for(i=0;i<20;i++) printf("%d ",six_rand());}
void print_spot_light(t_light *light) { ft_putendl(" Spot light -> "); ft_putstr(" intensity : "); ft_putfloat2(light->intensity); ft_putstr("\n color : "); print_color(light->color); ft_putstr("\n position : "); print_vector(light->pos); }
void print_dir_light(t_light *light) { ft_putendl(" Directional light ->"); ft_putstr(" intensity : "); ft_putfloat2(light->intensity); ft_putstr("\n color : "); print_color(light->color); ft_putstr("\n direction : "); print_vector(light->dir); }
int main(int argc, char* argv[]) { set_key_handler(); astra_initialize(); astra_streamsetconnection_t sensor; astra_streamset_open("device/default", &sensor); astra_reader_t reader; astra_reader_create(sensor, &reader); astra_depthstream_t colorStream; astra_reader_get_colorstream(reader, &colorStream); astra_stream_start(colorStream); astra_frame_index_t lastFrameIndex = -1; do { astra_temp_update(); astra_reader_frame_t frame; astra_status_t rc = astra_reader_open_frame(reader, 0, &frame); if (rc == ASTRA_STATUS_SUCCESS) { astra_colorframe_t colorFrame; astra_frame_get_colorframe(frame, &colorFrame); astra_frame_index_t newFrameIndex; astra_colorframe_get_frameindex(colorFrame, &newFrameIndex); if (lastFrameIndex == newFrameIndex) { printf("duplicate frame index: %d\n", lastFrameIndex); } lastFrameIndex = newFrameIndex; print_color(colorFrame); astra_reader_close_frame(&frame); } } while (shouldContinue); astra_reader_destroy(&reader); astra_streamset_close(&sensor); astra_terminate(); }
void print_colors (char *name, GdkColor *x, int n) { int i; printf ("(%s", name); for (i = 0; i < n; i++) { printf (" (%s . ", states[i]); print_color (x + i); printf (")"); } printf (")\n"); }
void print_map(char **map) { int y; int x; y = 0; while (map[y]) { x = 0; while (map[y][x]) { if (map[y][x] == '0' || map[y][x] == '1' || map[y][x] == '*') print_color("\x1b[42;30m", '*'); else if (map[y][x] == 'T' || map[y][x] == 'M' || map[y][x] == 'C') print_color("\x1b[41;37m", map[y][x]); else my_putchar(map[y][x]); ++x; } my_putchar('\n'); ++y; } }
void module_volume(char *s) { char *e = "amixer get Master | egrep -o '([0-9]+%)|(on|off)]'"; FILE *amixer = popen(e, "r"); char **a = malloc(128); readsplit(a, amixer, "\n"); int level = atoi(a[0]); a[1][strlen(a[1])-1] = 0; // trim last character if(strcmp(a[1], "on") == 0) sprintf(s, "%s♪%02d%%", s, level); else sprintf(s, "%s%s♪mm%%", s, print_color("FFFF00")); free(a); pclose(amixer); }
/* print_with_color(): */ void print_with_color(const Char *filename, size_t len, Char suffix) { if (color_context_lsmF && (haderr ? (didfds ? is2atty : isdiagatty) : (didfds ? is1atty : isoutatty))) { print_color(filename, len, suffix); xprintf("%S", filename); if (0 < variables[VEnd].color.len) put_color(&variables[VEnd].color); else { put_color(&variables[VLeft].color); put_color(&variables[VNormal].color); put_color(&variables[VRight].color); } } else xprintf("%S", filename); xputwchar(suffix); }
void main(){ set_mode(); tick_duration=DEF_TICK_DURATION; tick_counter=melody_counter=0; tick_started=tick_occured=melody_started=melody_played=false; print_color("Lab 2", YELLOW); read_params(); //disable_int(); //outb(0x43, 0x36); //outb(0x40, 0xFF); //outb(0x40, 0xFF); set_int_addr_func(0x1C, (uint32_t)int1C_handler); enable_int(); while(1){ read_char(); } }
int start(t_data *data) { t_color color[2]; int n; int i; t_bunny_position pos[2]; n = -1; while (n <= data->swatch.pix2->clipable.clip_height) { i = 0; while (i <= data->swatch.pix2->clipable.clip_width) { print_color(&color[1], i); dtekpixel(data->swatch.pix2, poser(i, n, pos)[0], &color[1]); i++; } n++; } fill_swatch(data); return (0); }
int main(void) { //int x = 0, y = 0; create_fb(); //scan_screen(); fb_backgound(0, 0, fb_v.w - 1, fb_v.h - 1, 0x00996600); fb_backgound(STARTX, STARTY, STARTX + (V_NUM - 1) * SPACE, STARTY + (H_NUM - 1) * SPACE, 0x00ffcc33); fb_board(0x000000ff); print_color(); mouse_cursor(512, 384); //save_shape(300, 300); //mouse_cursor(300, 300); //restore_shape(300, 300); //mouse_cursor(512, 384); //mouse_doing(); server_op(); while(1) { //mouse_doing(); } return 0; }
std::string print( ::color::constant::base< tag_name > const& constant, std::string const& name ) { std::stringstream ss; typedef ::color::constant::base< tag_name > constant_t; ss << "<tr>" << std::endl; ss << "<td style=\"background-color:" << name << "\"> W3 -" << name << "</td>"; ss << "<td>" << print_color( "gray-" + name, ::color::rgb<std::uint8_t>( ::color::gray< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "rgb -" + name, ::color::rgb<std::uint8_t>( ::color::rgb< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "cmy -" + name, ::color::rgb<std::uint8_t>( ::color::cmy< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "cmyk-" + name, ::color::rgb<std::uint8_t>( ::color::cmyk< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "hsl -" + name, ::color::rgb<std::uint8_t>( ::color::hsl< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "hsv -" + name, ::color::rgb<std::uint8_t>( ::color::hsv< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "hsi -" + name, ::color::rgb<std::uint8_t>( ::color::hsi< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "yiq -" + name, ::color::rgb<std::uint8_t>( ::color::yiq< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "yuv -" + name, ::color::rgb<std::uint8_t>( ::color::yuv< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "YCgCo -" + name, ::color::rgb<std::uint8_t>( ::color::YCgCo< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "YDbDr -" + name, ::color::rgb<std::uint8_t>( ::color::YDbDr< double >( constant ) ) ) << "</td>"; ss << "<td>" << print_color( "YPbPr -" + name, ::color::rgb<std::uint8_t>( ::color::YPbPr< double >( constant ) ) ) << "</td>"; ss << "</tr>" << std::endl; return ss.str(); }
int main(int argc, char *argv[]) { const char *root_folder = getenv("RUNVPN_ROOT"); struct vpn *vpn = NULL; struct vpn *prev = NULL; if (root_folder == NULL) { printf("Environment variable \"RUNVPN_ROOT\" is not defined.\n"); return EXIT_FAILURE; } if (argc == 1) { /* fprintf(stdout, "%30s%s%s\n", BLUE_GRAY, "Listing VPNS", RESET); */ puts(" " BLUE_GRAY "Listing VPNS" RESET); vpn = get_vpns(root_folder); while(vpn != NULL) { //for (vpn = get_vpns(root_folder); vpn; vpn = vpn->next) { fprintf(stdout, "%25s - ", vpn->name); switch (vpn_status(vpn)) { case VPN_ERROR: return EXIT_FAILURE; case VPN_DEAD: print_color("Down", YELLOW); break; case VPN_RUNNING: print_color("Up", GREEN); break; case VPN_PERM_DENIED: print_color("Permission denied", RED); break; case VPN_STALE_PID: print_color("Down", YELLOW); vpn_delete_logfile(vpn); vpn_delete_pidfile(vpn); break; default: print_color("Unknown", RED); break; } prev = vpn; vpn = prev->next; vpn_free(prev); free(prev); } } else if (argc == 2) { struct vpn vpn; if (vpn_init(&vpn, root_folder, argv[argc - 1])) { fprintf(stderr, "Problem finding vpn: %s\n", strerror(errno)); return EXIT_FAILURE; } if (vpn_status(&vpn) == VPN_ERROR || vpn_start(&vpn, NO_DAEMON)) return EXIT_FAILURE; vpn_start(&vpn, NO_DAEMON); vpn_free(&vpn); } else if (argc == 3) { struct vpn vpn; char *name = *++argv; char *argument = *++argv; if (vpn_init(&vpn, root_folder, name) == -1) { fprintf(stderr, "Problem finding vpn: %s\n", strerror(errno)); return EXIT_FAILURE; } if (vpn_status(&vpn) == VPN_ERROR) return EXIT_FAILURE; /* Do different things depending on 2nd argument pased. */ if (strcmp(argument, "stop") == 0) { if (vpn_stop(&vpn)) return EXIT_FAILURE; } else if (strcmp(argument, "reload") == 0) { if (vpn_reload(&vpn)) return EXIT_FAILURE; } else if (strcmp(argument, "daemon") == 0) { if (vpn_start(&vpn, DAEMON)) return EXIT_FAILURE; } else if (strcmp(argument, "drestart") == 0) { if (vpn_stop(&vpn) || vpn_start(&vpn, DAEMON)) return EXIT_FAILURE; } else if (strcmp(argument, "restart") == 0) { if (vpn_stop(&vpn) || vpn_start(&vpn, NO_DAEMON)) return EXIT_FAILURE; } else if (strcmp(argument, "log") == 0) { vpn_dumplog(&vpn); } else { fprintf(stderr, "Unknown action '%s'\n", argument); } vpn_free(&vpn); } return EXIT_SUCCESS; }
void print_separator(char *s) { // another character to try, from powerline: sprintf(s, " %s| ^fg()", print_color("555555")); }