Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3131380 By: nobody
I'm not aware of a gnuwin32 tool that will fill a file with a particular byte value, but here's one that will. I wrote it for the MSVC 6.0 environment; it should port to other compiler environments with minimal work. The part that might give trouble is the "setmode" call; you'll need this to prevent NL to CRLF translation, and to avoid misinterpretation of CTRL-Z. Enjoy, Robert Bassett /* bytegen: repeat a specified byte */ #include <stdio.h> #include <fcntl.h> unsigned interp (char *s) { if (*s == '\') switch (*++s) { case 'x': case 'X': return (unsigned char) strtoul (++s, NULL, 16); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return (unsigned char) strtoul (s, NULL, 0); case '\': return '\'; case 'a': return '\a'; case 'b': return '\b'; case 'f': return '\f'; case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; case 'v': return '\v'; } return (unsigned char) *s; } int main (int argc, char **argv) { unsigned byte, rept; if ((argc > 1) && (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help"))) { printf ("%s: usage: %s [ char [ repeat ] ]\n", argv[0], argv[0]); printf ("\nchar may be one of the following:\n"); printf (" \xhh an hexadecimal escape code\n"); printf (" \ooo an octal escape code (beginning with 0)\n"); printf (" \ddd a decimal escape code (not beginning with 0)\n"); printf (" \\ backslash\n"); printf (" \a alert (BEL)\n"); printf (" \b backspace\n"); printf (" \f form feed\n"); printf (" \n newline\n"); printf (" \r carriage return\n"); printf (" \t tab\n"); printf (" \v vertical tab\n"); printf (" c a literal character (default is a)\n"); printf ("\nrepeat is a 32-bit unsigned number, from 0 to 4294967295, inclusive.\n"); printf ("repeat may be specified in decimal, octal (with leading 0), or 0x hex.\n"); printf ("repeat defaults to 128, for no special reason.\n"); return 0; } if (argc < 2) { byte = 'a'; rept = 128; } else if (argc < 3) { byte = interp (argv[1]); rept = 128; } else { byte = interp (argv[1]); rept = strtoul (argv[2], NULL, 0); } setmode (1, _O_BINARY); while (rept--) putchar (byte); return 0; } ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=74807 ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 _______________________________________________ GnuWin32-Users mailing list GnuWin32-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gnuwin32-users