int main(void) { char s1[LEN+1]; strncpy(s1, "abcdef", 3); print_char_array(s1, sizeof(s1)); printf("\n"); strncpy(s1, "abcdef", sizeof(s1)-1); s1[sizeof(s1)-1] = '\0'; print_char_array(s1, LEN+1); return 0; }
void print_tuple( /*========*/ FILE* stream, const ib_tpl_t tpl) { int i; int n_cols = ib_tuple_get_n_cols(tpl); for (i = 0; i < n_cols; ++i) { ib_ulint_t data_len; ib_col_meta_t col_meta; data_len = ib_col_get_meta(tpl, i, &col_meta); /* Skip system columns. */ if (col_meta.type == IB_SYS) { continue; /* Nothing to print. */ } else if (data_len == IB_SQL_NULL) { fprintf(stream, "|"); continue; } else { switch (col_meta.type) { case IB_INT: { print_int_col(stream, tpl, i, &col_meta); break; } case IB_FLOAT: { float v; ib_tuple_read_float(tpl, i, &v); fprintf(stream, "%f", v); break; } case IB_DOUBLE: { double v; ib_tuple_read_double(tpl, i, &v); fprintf(stream, "%lf", v); break; } case IB_BLOB: case IB_VARCHAR: { const char* ptr; ptr = ib_col_get_value(tpl, i); fprintf(stream, "%d:", (int) data_len); print_char_array(stream, ptr, (int) data_len); break; } default: assert(IB_FALSE); break; } } fprintf(stream, "|"); } fprintf(stream, "\n"); }
int main() { const int ARRAY_SIZE = 4; int int_array[ARRAY_SIZE] = {5, 111, -86, 84}; qsort(int_array, ARRAY_SIZE, sizeof(int), compare_func); print_int_array(int_array, ARRAY_SIZE); char char_array[ARRAY_SIZE] = {'z', 'y', 'c', 't'}; qsort(char_array, ARRAY_SIZE, sizeof(char), compare_char); print_char_array(char_array, ARRAY_SIZE); float float_array[ARRAY_SIZE] = {1.2, 99.6, 3.14, 0.4751}; qsort(float_array, ARRAY_SIZE, sizeof(float), compare_float); print_float_array(float_array, ARRAY_SIZE); return 0; }
void typeArrayKlass::oop_print_on(oop obj, outputStream* st) { arrayKlass::oop_print_on(obj, st); typeArrayOop ta = typeArrayOop(obj); int print_len = MIN2((intx) ta->length(), MaxElementPrintSize); switch (element_type()) { case T_BOOLEAN: print_boolean_array(ta, print_len, st); break; case T_CHAR: print_char_array(ta, print_len, st); break; case T_FLOAT: print_float_array(ta, print_len, st); break; case T_DOUBLE: print_double_array(ta, print_len, st); break; case T_BYTE: print_byte_array(ta, print_len, st); break; case T_SHORT: print_short_array(ta, print_len, st); break; case T_INT: print_int_array(ta, print_len, st); break; case T_LONG: print_long_array(ta, print_len, st); break; default: ShouldNotReachHere(); } int remaining = ta->length() - print_len; if (remaining > 0) { tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining); } }
int main(int argc, char* argv[]) { codecs_t *cl; FILE *f1; FILE *f2; int c,d,i; int pos; int section=-1; int nr_codecs; int win32=-1; int dshow=-1; int win32ex=-1; /* * Take path to codecs.conf from command line, or fall back on * etc/codecs.conf */ if (!(nr_codecs = parse_codec_cfg((argc>1)?argv[1]:"etc/codecs.conf"))) exit(1); if (codecs_conf_release < CODEC_CFG_MIN) exit(1); if (argc > 1) { int i, j; const char* nm[2]; codecs_t* cod[2]; int nr[2]; nm[0] = "builtin_video_codecs"; cod[0] = video_codecs; nr[0] = nr_vcodecs; nm[1] = "builtin_audio_codecs"; cod[1] = audio_codecs; nr[1] = nr_acodecs; printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv[1]); printf("#include <stddef.h>\n"); printf("#include \"codec-cfg.h\"\n\n"); printf("#define CODEC_CFG_MIN %i\n\n", codecs_conf_release); for (i=0; i<2; i++) { printf("const codecs_t %s[] = {\n", nm[i]); for (j = 0; j < nr[i]; j++) { printf("{"); print_int_array(cod[i][j].fourcc, CODECS_MAX_FOURCC); printf(", /* fourcc */\n"); print_int_array(cod[i][j].fourccmap, CODECS_MAX_FOURCC); printf(", /* fourccmap */\n"); print_int_array(cod[i][j].outfmt, CODECS_MAX_OUTFMT); printf(", /* outfmt */\n"); print_char_array(cod[i][j].outflags, CODECS_MAX_OUTFMT); printf(", /* outflags */\n"); print_int_array(cod[i][j].infmt, CODECS_MAX_INFMT); printf(", /* infmt */\n"); print_char_array(cod[i][j].inflags, CODECS_MAX_INFMT); printf(", /* inflags */\n"); print_string(cod[i][j].name); printf(", /* name */\n"); print_string(cod[i][j].info); printf(", /* info */\n"); print_string(cod[i][j].comment); printf(", /* comment */\n"); print_string(cod[i][j].dll); printf(", /* dll */\n"); print_string(cod[i][j].drv); printf(", /* drv */\n"); printf("{ 0x%08lx, %hu, %hu,", cod[i][j].guid.f1, cod[i][j].guid.f2, cod[i][j].guid.f3); print_char_array(cod[i][j].guid.f4, sizeof(cod[i][j].guid.f4)); printf(" }, /* GUID */\n"); printf("%hd /* flags */, %hd /* status */, %hd /* cpuflags */ }\n", cod[i][j].flags, cod[i][j].status, cod[i][j].cpuflags); if (j < nr[i]) printf(",\n"); } printf("};\n\n"); } exit(0); } f1=fopen("DOCS/tech/codecs-in.html","rb"); if(!f1) exit(1); f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1); while((c=fgetc(f1))>=0){ if(c!='%'){ fputc(c,f2); continue; } d=fgetc(f1); if(d>='0' && d<='9'){ // begin section section=d-'0'; //printf("BEGIN %d\n",section); if(section>=5){ // audio cl = audio_codecs; nr_codecs = nr_acodecs; dshow=7;win32=4; } else { // video cl = video_codecs; nr_codecs = nr_vcodecs; dshow=4;win32=2;win32ex=6; } pos=ftell(f1); for(i=0;i<nr_codecs;i++){ fseek(f1,pos,SEEK_SET); switch(section){ case 0: case 5: if(cl[i].status==CODECS_STATUS_WORKING) // if(!(!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm"))) parsehtml(f1,f2,&cl[i]); break; #if 0 case 1: case 6: if(cl[i].status==CODECS_STATUS_WORKING) if((!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm"))) parsehtml(f1,f2,&cl[i]); break; #endif case 2: case 7: if(cl[i].status==CODECS_STATUS_PROBLEMS) parsehtml(f1,f2,&cl[i]); break; case 3: case 8: if(cl[i].status==CODECS_STATUS_NOT_WORKING) parsehtml(f1,f2,&cl[i]); break; case 4: case 9: if(cl[i].status==CODECS_STATUS_UNTESTED) parsehtml(f1,f2,&cl[i]); break; default: printf("Warning! unimplemented section: %d\n",section); } } fseek(f1,pos,SEEK_SET); skiphtml(f1); continue; } fputc(c,f2); fputc(d,f2); } fclose(f2); fclose(f1); return 0; }