#include <textmenu.h>
#include <function.h>

char isspace(char c) {
 if ((c>0x08 && c<0x0e) || c==0x20) return 1;
 return 0;
}

char isdigit(char c) {
 if (c>47 && c<58 ) return (1);
 return (0);
}

int atoi_ (MODE *s) {
 int n,sign;
 for (; isspace(*s); s++);
 sign=(*s=='-' ? -1 :1);
 if (*s=='+'||*s=='-')s++;
 for (n=0;isdigit(*s);s++) n=10*n+*s-'0';
 return (sign*n);
}

void strcpy_ (MODE *d, MODE *s) {
 while (*s) *d++=*s++;
 *d='\0';
}

int strlen_(MODE *s) {
 int l=0;
 while (*s!='\0') { l++; s++; }
 return l;
}

void strrev_(MODE *s) {
 int c; char *t;
 for (t=s+strlen_(s)-1; s<t; s++,t--) {
  c=*s; *s=*t; *t=c;
 }
}

void itoa_ (int n, MODE *s) {
 int sign;
 MODE *t=s;
 if ((sign=n)<0) n=-n;
 do {
  *s++=n%10+'0';
 } while ((n/=10)!=0);
 if (sign<0) *s++='-';
 *s='\0';
 strrev_ (t);
}

static MODE StackByte;
void Push (MODE *Ptr) { StackByte=*Ptr; *Ptr='\0'; return; }
void Pop (MODE *Ptr) { *Ptr=StackByte; return; }

