Ejemplo n.º 1
0
Archivo: save.c Proyecto: Azizou/XaoS
static void save_float(struct uih_context *uih, number_t number)
{
    if (!first)
	myputc(' ');
    else
	first = 0;
#ifdef HAVE_LONG_DOUBLE
    /*20 should be enought to specify 64digit number :) */
#ifdef USE_XLDIO
    x_ldout((long double) number, 20, uih->savec->file);
#else
    {
	char s[256];
	sprintf(s, "%.20LG", (long double) number);
	myputs(s);
    }
#endif
#else
    {
	char s[256];
	sprintf(s, "%.20G", (double) number);
	myputs(s);
    }
#endif
}
Ejemplo n.º 2
0
Archivo: lib.c Proyecto: yuanyiyixi/arm
int myprintf(const char *format,...)
{
	char c;
	va_list ap;
	char c_val;
	int i_val;
	char * p_val;
	char buf[10];

	va_start(ap,format);	//ap is format's address
	while((c = *format) != '\0')
	{
		if (c == '%')
		{
			c = *++format;
			switch(c)
			{
				case 's':
					p_val = va_arg(ap, char *);
					myputs(p_val);
					break;
				case 'c':
					c_val = va_arg(ap, int);
					myputchar(c_val);
					break;
				case 'd':
					i_val = va_arg(ap, int);
					itoa(i_val, buf);
					myputs(buf);
					break;
				default:
					break;
			}
		}
		else 
Ejemplo n.º 3
0
Archivo: save.c Proyecto: Azizou/XaoS
static void
save_float2(struct uih_context *uih, number_t number, int places)
{
    char fs[10];
    if (!first)
	myputc(' ');
    else
	first = 0;
    if (places < 0)
	places = 0;
    if (places > 20)
	places = 20;
#ifdef HAVE_LONG_DOUBLE
#ifdef USE_XLDIO
    fs[0] = 0;			/* Avoid warning */
    x_ldout((long double) number, places, uih->savec->file);
#else
    {
	char s[256];
	sprintf(fs, "%%.%iLG", places);
	sprintf(s, fs, (long double) number);
	myputs(s);
    }
#endif
#else
    {
	char s[256];
	sprintf(fs, "%%.%iG", places);
	sprintf(s, fs, (double) number);
	myputs(s);
    }
#endif
}
Ejemplo n.º 4
0
void send_impulses(transmit_modes tx_mode) {
	/*
	 * Send all saved impulses via the given transmit mode
	 */
	if (tx_mode == uart) {
		unsigned int i;
		for (i = 0; i < current_impulse; i++) {
//			myputc((impulseData[i].year >> 12) + 0x30);  // Send BCD as ASCII
//			myputc(((impulseData[i].year >> 8) & 0xf) + 0x30);
			myputs("20");
			myputc(((impulseData[i].year >> 4) & 0xf) + 0x30);
			myputc((impulseData[i].year & 0xf) + 0x30);
			myputc((impulseData[i].mon >> 4) + 0x30);
			myputc((impulseData[i].mon & 0xf) + 0x30);
			myputc((impulseData[i].day >> 4) + 0x30);
			myputc((impulseData[i].day & 0xf) + 0x30);
//			myputc((impulseData[i].dow >> 4) + 0x30);
//			myputc((impulseData[i].dow & 0xf) + 0x30);
			myputc((impulseData[i].hour >> 4) + 0x30);
			myputc((impulseData[i].hour & 0xf) + 0x30);
			myputc((impulseData[i].min >> 4) + 0x30);
			myputc((impulseData[i].min & 0xf) + 0x30);
			myputc((impulseData[i].sec >> 4) + 0x30);
			myputc((impulseData[i].sec & 0xf) + 0x30);
			myputs("\r\n");
		}
	} else if (tx_mode == cc2500) {
Ejemplo n.º 5
0
Archivo: save.c Proyecto: Azizou/XaoS
static void start_save(struct uih_context *uih, const char *name)
{
    if (!changed && !uih->savec->firsttime) {
	char s[256];
	sprintf(s, "\n(usleep %i)\n", tl_lookup_timer(uih->savec->timer));
	myputs(s);
	tl_reset_timer(uih->savec->timer);
    }
    changed = 1;
    myputc('(');
    myputs(name);
    first = 0;
}
Ejemplo n.º 6
0
 void show()
 {
     int i,j;
     for(i=0;i<4;i++)
     {
         locate(10+i,10);
         for(j=0;j<4;j++)
         {
             if(s[i][j])
                 myputs("%c ",s[i][j]-1+'A');
             else
                 myputs("%c ",' ');
         }
     }
     locate(14,12);myputs("rem=%3d",pnum);
 }
Ejemplo n.º 7
0
main()
{
   char string[80];
   FH *in,*out;
   
#ifdef AMIGA
   out=(FH *)Output();
#else
   out = stdout;
#endif

#ifdef AMIGA
   if((in=(FH *)Open("test.dat",MODE_OLDFILE))==NULL)
#else
   if((in=(FH *)fopen("test.dat","r"))==NULL)
#endif
   {
      printf("Unable to open test.dat\n");
      exit(1);
   }

   while(mygets(in,string,80))
      myputs(out,string);
      
#ifdef AMIGA
   Close(in);
#else
   fclose(in);
#endif
}
Ejemplo n.º 8
0
int choice(int sfd,packet* pk,int* fd)
{
		switch(pk->type)
	    {
		case 0:
			get(pk,fd);
			break;
		case 1:
			mycd(pk);
			break;
		case 2:
			myls(pk);
			break;
		case 3:
			myputs(sfd,pk);
			break;
		case 4:
			mygets(pk,fd);
			break;
		case 5:
			myremove(pk);
			break;
		case 6:
			mypwd(pk);
			break;
		case 7:
			getend(fd);
			break;
		default:
			break;
		}
		return 0;
}
Ejemplo n.º 9
0
int main(void)
{
	const char *helloworld="Hello world\n";
	myputs(*helloworld);
	while(1);
	return(0);
}
Ejemplo n.º 10
0
Archivo: wcsort.c Proyecto: Anat37/akos
int main(int argc, char* argv[])
{
    char** data = NULL;
    char* buf;
    int strcnt = 0;
    size_t strsize = 10;
    int i, j;
    FILE* inf;
    FILE* outf;
    int ret = 0;
    if (argc < 3)
    {
        printf("Few args");
        return 0;
    }
    inf = fopen(argv[1], "r");
    outf = fopen(argv[2], "w");
    if (outf == NULL || inf == NULL)
    {
        printf("Invalid file names");
        return 0;
    }
    data = malloc(10 * sizeof(char*));
    data[strcnt] = NULL;
    ret = safe_gets(inf, &data[strcnt]);
    while (ret == 0)
    {
        strcnt++;
        if (strcnt + 1 == strsize)
        {   
            strsize += 10;
            data = realloc(data, strsize * sizeof(char*));
            if (data == NULL)
            printf("whats up?");
        }
        /*printf("%s", data[strcnt - 1]);*/
        data[strcnt] = NULL;
        ret = safe_gets(inf, &data[strcnt]);
        
    }
    
    for (i = 0; i < strcnt; ++i)
        for (j = i + 1; j < strcnt; ++j)
        if (mycmp(data[i], data[j]) >= 0) {
            buf = data[j];
            data[j] = data[i];
            data[i] = buf;
        }
    printf("Words: %ld\n", words);
    for (i = 0; i < strcnt; ++i){
        myputs(outf, data[i]);
        free(data[i]);
    } 
    free(data[i]);   
    free(data);
    fclose(inf);
    fclose(outf);    
    return 0;    
}
Ejemplo n.º 11
0
Archivo: save.c Proyecto: Azizou/XaoS
static void save_keyword(struct uih_context *uih, const char *name)
{
    if (!first)
	myputc(' ');
    else
	first = 0;
    myputs(name);
}
Ejemplo n.º 12
0
Archivo: save.c Proyecto: Azizou/XaoS
static void save_onoff(struct uih_context *uih, int number)
{
    if (!first)
	myputc(' ');
    else
	first = 0;
    myputs(number ? "#t" : "#f");
}
Ejemplo n.º 13
0
int main(void)
{
 	const char *helloworld="Hello world\n";
	*NVIC_CCR=*NVIC_CCR|0x200;
	myputs(*helloworld);
	while(1);
	return (0);
}
Ejemplo n.º 14
0
Archivo: save.c Proyecto: kidaa/gmerlin
static void save_keystring (struct uih_context *uih, CONST char *name)
{
    if (!first)
        myputc (' ');
    else
        first = 0;
    myputc ('\'');
    myputs (name);
}
Ejemplo n.º 15
0
static void
comm_comout(			/* print string to command line */
	char	*str
)
{
	putc(COM_COMOUT, devout);
	myputs(str, devout);
	if (str[strlen(str)-1] == '\n')
		fflush(devout);
}
Ejemplo n.º 16
0
Archivo: save.c Proyecto: Azizou/XaoS
static void save_int(struct uih_context *uih, int number)
{
    char s[256];
    if (!first)
	myputc(' ');
    else
	first = 0;
    sprintf(s, "%i", number);
    myputs(s);
}
Ejemplo n.º 17
0
Archivo: m1.c Proyecto: pengkh/proton
int main(void)
{
	myputs(xxx);
	_print("yyy");
	json_key("yyy");

	const char *list = "xxx, yyy, zzz";
	json_list(LIST);

}
Ejemplo n.º 18
0
int printf(const char *format, ...)
{
    char buf[1024];
    va_list ap;
    int rv;

    va_start(ap, format);
    rv = vsnprintf(buf, sizeof buf, format, ap);
    va_end(ap);

    myputs(buf);

    return rv;

}
Ejemplo n.º 19
0
int main()
{
	uart_init();

	myputc('1');
	myputc('2');
	myputc('3');
	myputc('4');
	myputc('5');
	myputc('6');
	
	myputs("hello world!\n");
	
	led_test();

	return 0;
}
Ejemplo n.º 20
0
static void
comm_comin(			/* read string from command line */
	char	*buf,
	char	*prompt
)
{
	putc(COM_COMIN, devout);
	if (prompt == NULL)
		putc(0, devout);
	else {
		putc(1, devout);
		myputs(prompt, devout);
	}
	fflush(devout);
	if (getc(devin) != COM_COMIN)
		reply_error("comin");
	mygets(buf, devin);
	getstate();
}
Ejemplo n.º 21
0
/*
 *选择:0<往链接写报文>/1<cd>/2<myls>/3<打开文件>/4<读取服务端文件内容并发给客户端>
 *******5<移除文件>/6<获取当前路径>/7<关闭链接>/8<退出循环>
 * */
int choice(node* n,packet* pk,int* running,char *filedir)
{
		switch(pk->type)
		{
				case 0:
						put(pk,n->put_fd);
						break;
				case 1:
						mycd(pk,n->curdir);
						send_pk(n->accept_fd,pk);
						break;
				case 2:
						myls(pk,n->curdir);
						send_pk(n->accept_fd,pk);
						break;
				case 3:
						myputs(pk,&(n->put_fd),filedir);
						send_pk(n->accept_fd,pk);
						break;
				case 4:
						mygets(n->accept_fd,pk,n->curdir);
						break;
				case 5:
						myremove(pk,n->curdir);
						send_pk(n->accept_fd,pk);
						break;
				case 6: 
						mypwd(pk,n->curdir);
						send_pk(n->accept_fd,pk);
						break;
				case 7:
						putend(&(n->put_fd));
						break;
				case 8:
						*running=0;
						break;
				default:break;
		}
		return 0;
}
int main(){
	char c[]="daisy duke";
	myputs(c);
	return 0;
}
Ejemplo n.º 23
0
Archivo: save.c Proyecto: Azizou/XaoS
int uih_save_enable(struct uih_context *uih, xio_file f, int mode)
{
    struct uih_savedcontext *s;
    int i;
    last = 0;
    if (uih->save) {
	uih_error(uih, "Recording is already enabled");
	return 0;
    }
    s = (struct uih_savedcontext *) calloc(1, sizeof(*s));
    if (f == NULL || s == NULL) {
	uih_error(uih, "File could not be opended or out of memory");
	return 0;
    }
    uih->savec = s;
    s->fcontext =
	make_fractalc(1, uih->image->pixelwidth * uih->image->width,
		      uih->image->pixelheight * uih->image->height);
    if (s->fcontext == NULL) {
	uih_error(uih, "File could not be opended or out of memory");
	return 0;
    }
    s->mode = mode;
    /*Invalidate context to force save everything first */
    s->speedup = STEP;
    s->maxstep = MAXSTEP;
    s->xcenter = INT_MAX;
    s->fastmode = 2;
    s->juliamode = 0;
    s->cycling = 0;
    for (i = 0; i < uih_nfilters; i++)
	s->filter[i] = 0;
    s->pressed = 0;
    s->firsttime = 1;
    uih->palettechanged = 1;
    s->cyclingspeed = 30;
    s->fcontext->pre = s->fcontext->pim = 0;
    s->fcontext->bre = s->fcontext->bim = 0;
    s->fcontext->currentformula = NULL;
    s->fcontext->periodicity = 1;
    s->fcontext->maxiter = 170;
    s->fcontext->bailout = 4;
    s->fcontext->coloringmode = 0;
    s->fcontext->incoloringmode = 0;
    s->fcontext->outtcolor = 0;
    s->fcontext->intcolor = 0;
    s->fcontext->mandelbrot = 1;
    s->fcontext->plane = 0;
    s->fcontext->range = 3;
    s->fcontext->angle = 0;
    s->rotatepressed = 0;
    s->autorotate = 0;
    s->fastrotate = 0;
    s->rotationspeed = 10;
    s->clearscreen = 0;
    s->color = 0;
    s->xtextpos = 1;
    s->ytextpos = 1;
    s->file = f;
    s->timer = tl_create_timer();
    s->synctimer = tl_create_timer();
    uih->viewchanged = 1;
    uih->palettechanged = 1;
    uih->save = 1;
    uih_emulatetimers(uih);
    tl_reset_timer(s->timer);
    uih->moved = 0;
#ifndef _plan9_
    if (mode == UIH_SAVEANIMATION)
	myputs(";Animation file automatically generated by XaoS "
	       XaoS_VERSION "\n"
	       ";  - a realtime interactive fractal zoomer\n"
	       ";Use xaos -play <filename> to replay it\n");
    else if (mode == UIH_SAVEPOS)
	myputs(";Position file automatically generated by XaoS "
	       XaoS_VERSION "\n"
	       ";  - a realtime interactive fractal zoomer\n"
	       ";Use xaos -load <filename> to display it\n");
#endif
    uih_saveframe(uih);
    uih_updatemenus(uih, "save");
    xio_putc('\n', f);
    return 1;
}
Ejemplo n.º 24
0
static void vprint(printer *p, const char *format, va_list ap)
{
     char buf[BSZ];
     const char *s = format;
     char c;
     int i;

     for (i = 0; i < p->indent; ++i)
          p->putchr(p, ' ');

     while ((c = *s++)) {
          switch (c) {
	      case '%':
		   switch ((c = *s++)) {
		       case 'M': {
			    /* md5 value */
			    md5uint x = va_arg(ap, md5uint);
			    x = 0xffffffffUL & x;
			    sprintf(buf, "%8.8lx", (unsigned long)x);
			    goto putbuf;
		       }
		       case 'c': {
			    int x = va_arg(ap, int);
			    p->putchr(p, x);
			    break;
		       }
		       case 's': {
			    char *x = va_arg(ap, char *);
			    if (x)
				 myputs(p, x);
			    else
				 goto putnull;
			    break;
		       }
		       case 'd': {
			    int x = va_arg(ap, int);
			    sprintf(buf, "%d", x);
			    goto putbuf;
		       }
		       case 't': {
			    ptrdiff_t x;
			    A(*s == 'd');
			    s += 1;
			    x = va_arg(ap, ptrdiff_t);
			    /* should use C99 %td here, but
			       this is not yet widespread enough */
			    sprintf(buf, "%ld", (long) x);
			    goto putbuf;
		       }
		       case 'f': case 'e': case 'g': {
			    char fmt[3] = "%x";
			    double x = va_arg(ap, double);
			    fmt[1] = c;
			    sprintf(buf, fmt, x);
			    goto putbuf;
		       }
		       case 'v': {
			    /* print optional vector length */
			    int x = va_arg(ap, int);
			    if (x > 1) {
				 sprintf(buf, "-x%d", x);
				 goto putbuf;
			    }
			    break;
		       }
		       case 'o': {
			    /* integer option.  Usage: %oNAME= */
			    int x = va_arg(ap, int);
			    if (x)
				 p->putchr(p, '/');
			    while ((c = *s++) != '=')
				 if (x)
				      p->putchr(p, c);
			    if (x) {
				 sprintf(buf, "=%d", x);
				 goto putbuf;
			    }
			    break;
		       }
		       case 'u': {
			    unsigned x = va_arg(ap, unsigned);
			    sprintf(buf, "%u", x);
			    goto putbuf;
		       }
		       case 'x': {
			    unsigned x = va_arg(ap, unsigned);
			    sprintf(buf, "%x", x);
			    goto putbuf;
		       }
		       case '(': {
			    /* newline, augment indent level */
			    p->putchr(p, '\n');
			    p->indent += p->indent_incr;
			    break;
		       }
		       case ')': {
			    /* decrement indent level */
			    p->indent -= p->indent_incr;
			    break;
		       }
		       case 'p': {  /* note difference from C's %p */
			    /* print plan */
			    plan *x = va_arg(ap, plan *);
			    if (x) 
				 x->adt->print(x, p);
			    else 
				 goto putnull;
			    break;
		       }
		       case 'P': {
			    /* print problem */
			    problem *x = va_arg(ap, problem *);
			    if (x)
				 x->adt->print(x, p);
			    else
				 goto putnull;
			    break;
		       }
		       case 'T': {
			    /* print tensor */
			    tensor *x = va_arg(ap, tensor *);
			    if (x)
				 X(tensor_print)(x, p);
			    else
				 goto putnull;
			    break;
		       }
		       default:
			    A(0 /* unknown format */);
			    break;

		   putbuf:
			    myputs(p, buf);
			    break;
		   putnull:
			    myputs(p, "(null)");
			    break;
		   }
		   break;
	      default:
		   p->putchr(p, c);
		   break;
          }
     }
}
Ejemplo n.º 25
0
static void vprint(printer *p, const char *format, va_list ap)
{
     const char *s = format;
     char c;
     INT ival;

     while ((c = *s++)) {
          switch (c) {
	      case '%':
		   switch ((c = *s++)) {
		       case 'M': {
			    /* md5 value */
			    md5uint x = va_arg(ap, md5uint);
			    putulong(p, (unsigned long)(0xffffffffUL & x),
				     16, 8);
			    break;
		       }
		       case 'c': {
			    int x = va_arg(ap, int);
			    p->putchr(p, x);
			    break;
		       }
		       case 's': {
			    char *x = va_arg(ap, char *);
			    if (x)
				 myputs(p, x);
			    else
				 goto putnull;
			    break;
		       }
		       case 'd': {
			    int x = va_arg(ap, int);
			    ival = (INT)x;
			    goto putival;
		       }
		       case 'D': {
			    ival = va_arg(ap, INT);
			    goto putival;
		       }
		       case 'v': {
			    /* print optional vector length */
			    ival = va_arg(ap, INT);
			    if (ival > 1) {
				 myputs(p, "-x");
				 goto putival;
			    }
			    break;
		       }
		       case 'o': {
			    /* integer option.  Usage: %oNAME= */
			    ival = va_arg(ap, INT);
			    if (ival)
				 p->putchr(p, '/');
			    while ((c = *s++) != '=')
				 if (ival)
				      p->putchr(p, c);
			    if (ival) {
				 p->putchr(p, '=');
				 goto putival;
			    }
			    break;
		       }
		       case 'u': {
			    unsigned x = va_arg(ap, unsigned);
			    putulong(p, (unsigned long)x, 10, 0);
			    break;
		       }
		       case 'x': {
			    unsigned x = va_arg(ap, unsigned);
			    putulong(p, (unsigned long)x, 16, 0);
			    break;
		       }
		       case '(': {
			    /* newline, augment indent level */
			    p->indent += p->indent_incr;
			    newline(p);
			    break;
		       }
		       case ')': {
			    /* decrement indent level */
			    p->indent -= p->indent_incr;
			    break;
		       }
		       case 'p': {  /* note difference from C's %p */
			    /* print plan */
			    plan *x = va_arg(ap, plan *);
			    if (x) 
				 x->adt->print(x, p);
			    else 
				 goto putnull;
			    break;
		       }
		       case 'P': {
			    /* print problem */
			    problem *x = va_arg(ap, problem *);
			    if (x)
				 x->adt->print(x, p);
			    else
				 goto putnull;
			    break;
		       }
		       case 'T': {
			    /* print tensor */
			    tensor *x = va_arg(ap, tensor *);
			    if (x)
				 X(tensor_print)(x, p);
			    else
				 goto putnull;
			    break;
		       }
		       default:
			    A(0 /* unknown format */);
			    break;

		   putnull:
			    myputs(p, "(null)");
			    break;

		   putival:
			    putint(p, ival);
			    break;
		   }
		   break;
	      default:
		   p->putchr(p, c);
		   break;
          }
     }
}