long outlstring(TRune *s, long n) { char buf[sizeof(TRune)]; uint c; int i; long r; if(suppress) return nstring; while(nstring & (sizeof(TRune)-1)) outstring("", 1); r = nstring; while(n > 0) { c = *s++; if(align(0, types[TCHAR], Aarg1)) { for(i = 0; i < sizeof(TRune); i++) buf[i] = c>>(8*(sizeof(TRune) - i - 1)); } else { for(i = 0; i < sizeof(TRune); i++) buf[i] = c>>(8*i); } outstring(buf, sizeof(TRune)); n -= sizeof(TRune); }
void unzip_image (void) { void memgunzip (unsigned char *dst, const unsigned char *src, unsigned int sz); outstring ("Uncompressing Linux"); memgunzip (output_data, input_data, input_data_end - input_data); outstring ("\r\nOk, booting the kernel.\r\n"); }
static void outprodgroup( PSYMBOL s ) { /* put out all rules with s on LHS */ PPRODUCTION p; PELEMENT e; PSYMBOL ss; outline(); outsymbol( s ); outchar( ' ' ); barcol = getoutcol() + 1; /* remember indent for next rule */ outstring( RULESYM ); contcol = getoutcol() + 1; /* remember indent for continuation */ /* output first production on same line */ p = s->data; outprod( p ); while (p->next != NULL) { /* output successive productions */ p = p->next; outline(); outspaces( barcol ); outstring( "| " ); outprod( p ); } if (s->starter != NULL) { /* output start set */ outline(); outchar( COMMENT ); outstring( " start set: " ); contcol = getoutcol() + 1; /* remember indent */ for (e = s->starter; e != NULL; e = e->next) { ss = e->data; outspacesym( ss, contcol, COMMENT ); outsymbol( ss ); } } if (s->follows != NULL) { /* output follow set */ outline(); outchar( COMMENT ); outstring( " follow set: " ); contcol = getoutcol() + 1; /* remember indent */ for (e = s->follows; e != NULL; e = e->next) { ss = e->data; outspacesym( ss, contcol, COMMENT ); outsymbol( ss ); } } if ((s->follows != NULL) || (s->starter != NULL)) { /* output blank line to separate from the next rule */ outline(); } }
long outlstring(Rune *s, long n) { char buf[sizeof(Rune)]; int c, i; long r; while(nstring % sizeof buf) outstring("", 1); r = nstring; while(n > 0) { c = *s++; if(align(0, types[TCHAR], Aarg1)) { for(i = sizeof buf; i > 0; c >>= 8) buf[--i] = c; } else { for(i = 0; i < sizeof buf; c >>= 8) buf[i++] = c; } outstring(buf, sizeof buf); n -= sizeof buf; }
static void run_hooks_backward(crt0_hook *list, const char *name) { (void)name; #ifdef DEBUG outstring("list (backward) "); outstring(name); outstring(" @ "); outhex32((unsigned)list); outchar('\n'); #endif list--; while (*list != (crt0_hook)~1UL) { #ifdef DEBUG outstring(" calling "); outhex32((unsigned)*list); outchar('\n'); #endif (**list)(); list--; } }
static void acpi_test(int ac, char **av) { unsigned int i; unsigned int k; unsigned int sleep_gpio_save[13]; ls1a_save_gpio_val(sleep_gpio_save); suspend_save(); i = strtoul(av[1], 0, 0); // printf ("you set %d for test !\n", i); if (i & 1) *(volatile unsigned int *)0xbfe7c004 = 1 << 8; //power button k = *(volatile unsigned int *)0xbfe7c024; k &= ~((1 << 8) | (1 << 9)); *(volatile unsigned int *)0xbfe7c024 = (i & 0x3) << 8; //[8:9]RI_EN、PME_EN // *(volatile unsigned int *)0xbfe7c008 = (1 << 13) | (5 << 10); //sleep to ram flushcache(); __asm__ volatile ( "la $2, 2f\n\t" "li $3, 0xa01ffc00\n\t" "sw $2, 0x0($3)\n\t" //save return address "li $2, 0xaffffe34\n\t" "lw $3, 0x0($2)\n\t" "or $3, 0x1\n\t" "sw $3, 0x0($2)\n\t" //enable ddr autorefresh "li $2, 0xbfe7c008\n\t" "li $3, (1<<13) | (5<<10)\n\t" "sw $3, 0x0($2)\n\t" //go to sleep "1:\n\t" "bal 1b\n\t" "nop\n\t" "2:\n\t" :: : "$2","$3","memory" // "move %0,$2\n\t" // : "=r" (p) // : "0" (p), "r" (len), "r" (1) // : "$2","$3","$4","$5" ); ls1a_restore_gpio_val(sleep_gpio_save); dc_init(); outstring("acpi resume back here !\n"); // printf ("acpi resume back here !\n"); }
long outlstring(Rune *s, long n) { char buf[UTFmax]; int c, i; long r; // if(suppress) // return nstring; while(nstring & (sizeof(Rune)-1)) outstring("", 1); r = nstring; while(n > 0) { c = *s++; if(align(0, types[TCHAR], Aarg1)) { for(i = 0; i < sizeof(Rune); i++) buf[i] = c>>8*(sizeof(Rune) - i - 1); } else { for(i = 0; i < sizeof(Rune); i++) buf[i] = c>>8*i; } outstring(buf, sizeof(Rune)); n -= sizeof(Rune); }
static void alien_thread(void) { volatile l4_msgtag_t x; while (1) { x = l4_ipc_call(0x1234 << L4_CAP_SHIFT, l4_utcb(), l4_msgtag(0, 0, 0, 0), L4_IPC_NEVER); #ifdef MEASURE l4_sleep(0); #else l4_sleep(1000); outstring("An int3 -- you should see this\n"); outnstring("345", 3); #endif } }
long outlstring(ushort *s, long n) { char buf[2]; int c; long r; while(nstring & 1) outstring("", 1); r = nstring; while(n > 0) { c = *s++; if(align(0, types[TCHAR], Aarg1)) { buf[0] = c>>8; buf[1] = c; } else {
long outlstring(TRune *s, long n) { char buf[2]; int c; long r; if(suppress) return nstring; while(nstring & 1) outstring("", 1); r = nstring; while(n > 0) { c = *s++; if(align(0, types[TCHAR], Aarg1)) { buf[0] = c>>8; buf[1] = c; } else {
void to_image(std::vector<std::vector<int>> &img, std::string filename){ size_t n = img.size(); std::vector<char> outstring (2*n*n); for(std::size_t i = 0; i < n; i++){ for(std::size_t j = 0; j < n; j++){ int index = (n-1-i)*n+j; outstring[index*2] = std::min((img[i][j]+3)/4,9) + '0'; outstring[index*2+1] = (j+1 == n) ? '\n' : ' '; } } std::string nstring = std::to_string(n); std::string header = ("P2\n" + nstring + " " + nstring + "\n" + '9' + '\n'); std::ofstream f; f.open(filename.c_str()); f.write(header.c_str(), sizeof(char)*header.size()); f.write(outstring.data(), sizeof(char)*outstring.size()); f.close(); }
void CreateList(){ std::ofstream outstring("ListOfBadChannels.txt"); outstring << "" << std::endl; outstring << "<< List of CASTOR channels >>" << std::endl; outstring << " " << std::endl; outstring << "It shows number of times that a channel was active." << std::endl; outstring << "0 = Bad Channel" << std::endl; outstring << "" << std::endl; TFile *l1 = TFile::Open("ZeroBiasA.root"); TH1F* h_1 = (TH1F*)l1->Get("diffractiveZAnalysisTTreeAfter/CastorChannelWorking"); for (int j=2; j<=225; j++){ outstring << "Channel(" << j-1 << "): "<< h_1->GetBinContent(j) << endl; } outstring.close(); }
int method_check() { int type; element_id id; int count = 0; int k,n; for ( type = VERTEX; type < FACETEDGE ; type++ ) { int meth_offset = get_meth_offset(type); FOR_ALL_ELEMENTS(type,id) { struct element *e_ptr = elptr(id); int *instlist = (int*)((char*)e_ptr + meth_offset); for ( k = 0; k < (int)e_ptr->method_count ; k++ ) for ( n = k+1; n < (int)e_ptr->method_count ; n++ ) if ( abs(instlist[k]) == abs(instlist[n]) ) { sprintf(msg,"%s %s has method %s twice.\n", typenames[type],ELNAME(id),METH_INSTANCE(abs(instlist[k]))->name); outstring(msg); count++; } } } return count; } /* end method_check() */
/* The output function for pieces of type P_UNCLAIMED, P_SECTION, * P_BYTES, or P_STRINGS. The contents are output either as a literal * string, an array of character values, or an array of hexadecimal * byte values. The last will be used if the contents contain an * excess of non-graphic, non-ASCII characters. Otherwise, one of the * first two representations will be selected based on whether or not * the contents appear to be null-terminated. */ static void outbytes(void const *ptr, long size, int ndx) { unsigned char const *bytes = ptr; long zeroes, n; long i; (void)ndx; for (zeroes = 0 ; zeroes < size && !bytes[size - zeroes - 1] ; ++zeroes) ; if (zeroes == size) { out("{ 0 }"); return; } if (zeroes < 255 || zeroes * 4 < size) zeroes = 0; zeroes &= ~7; n = outstringsize((signed char const*)bytes, size); if (n * 2 > size * 3) { beginblock(TRUE); for (i = 0 ; i < size - zeroes ; ++i) outf("0x%02X", bytes[i]); if (zeroes) outcomment(strf("0x00 x %d", zeroes)); endblock(); } else if (zeroes || bytes[size - 1]) { beginblock(TRUE); for (i = 0 ; i < size - zeroes ; ++i) outchar(bytes[i]); if (zeroes) outcomment(strf("0x00 x %ld", zeroes)); endblock(); } else { outstring((char const*)bytes, size - 1); } }
/* -------------------------------------------------------------------- */ void offhook(void) { Initport(); outstring("ATM0H1\r"); }
void printascii(const char *buf) { outstring(buf); }
void writeg() { /* write grammar structure documented in grammar.h */ PSYMBOL s; bool header; outsetup(); if (head != NULL) { /* there is a distinguished symbol */ outstring( "> " ); outsymbol( head ); } else { outchar( COMMENT ); outstring( " no distinguished symbol!" ); } if (emptypt != NULL) { /* there is an empty symbol */ outline(); outstring( "/ " ); outsymbol( emptypt ); } for (s = symlist; s != NULL; s = s->next) s->state = UNTOUCHED; if (head != NULL) { outline(); outreachable( head ); } header = false; for (s = symlist; s != NULL; s = s->next) { if ((s->data == NULL) && (s->state == TOUCHED)) { if (!header) { outline(); outline(); outchar( COMMENT ); outstring( " terminals: " ); contcol = getoutcol() + 1; /* remember indent */ header = true; } outspacesym( s, contcol, COMMENT ); outsymbol( s ); } } header = false; for (s = symlist; s != NULL; s = s->next) { if ((s->data != NULL) && (s->state == UNTOUCHED)) { if (!header) { outline(); outline(); outchar( COMMENT ); outstring( " unused productions" ); header = true; } outprodgroup( s ); } } header = false; for (s = symlist; s != NULL; s = s->next) { if ((s->data == NULL) && (s->state == UNTOUCHED)) { if (!header) { outline(); outline(); outchar( COMMENT ); outstring( " unused terminals: " ); contcol = getoutcol() + 1; /* remember indent */ header = true; } outspacesym( s, contcol, COMMENT ); outsymbol( s ); } } outline(); }
int main(int argc, char **argv) { int c; struct uplot *up; int i; while (argc > 1) { if (BU_STR_EQUAL(argv[1], "-v")) { verbose++; } else break; argc--; argv++; } if (argc == 2) { if ((fp = fopen(argv[1], "r")) == NULL) { perror("plot3stat"); bu_exit (1, NULL); } } else { fp = stdin; if (argc > 1 || isatty(fileno(stdin))) { bu_exit(1, "%s", usage); } } while ((c = getc(fp)) != EOF) { /* look it up */ if (c < 'A' || c > 'z') { up = &uerror; } else { up = &letters[ c - 'A' ]; } if (up->targ == TBAD) { fprintf(stderr, "Bad command '%c' (0x%02x)\n", c, c); continue; } counts[ c - 'A' ]++; if (up->narg > 0) { switch (up->targ) { case TNONE: break; case TSHORT: outshort(up->narg); break; case TIEEE: outfloat(up->narg); break; case TSTRING: outstring(up->narg); break; case TCHAR: outchar(up->narg); break; } } if (verbose) printf(" %s", up->desc); } /* write command usage summary */ for (i = 0; i < 'z'-'A'+1; i++) { if (counts[i] != 0) { fprintf(stderr, "%s %ld\n", letters[i].desc, counts[i]); } } return 0; }