
/*
rustic printf, for muLinux
by M. Andreoli

Support only %s and %c.

*/

#include <stdio.h>
#define BUFSIZE 1024

int main(int argc, char *argv[])
{
char *format=(char*) malloc(10000);

if ( argc==1 )
	{
	fprintf(stderr,"rustic printf\n");
	fprintf(stderr,"Usage: printf 'format' args ...\n");
	fprintf(stderr,"Usage: printf -r args ... (read format from stdin)\n");
	exit(0);
	}

if ( strcmp( argv[1], "-r") == 0 )
	read_stdin(format);
else 
	format=(char *) argv[1];


vprintf(format, argv+2);
}


int read_stdin( char* f)
{
int n;
  while ( 1 ) {
        n=read(0, f, BUFSIZE);
        if (n == 0) break;          /* EOF.  */
        if (n < 0) return -2;
        f+=n;

  }
}

