Logo
~Apps~
~Projects~
~Contact~

asexec.cpp

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <sys/types.h>
00004 #include <sys/stat.h>
00005 #include <unistd.h>
00006 #include <stdlib.h>
00007 
00008 #include "a.h"
00009 #include "Parser.h"
00010 #include "ParserIO.h"
00011 
00012 
00013 class IOC : public ParserIO
00014 {
00015 public:
00016         int read_text(char *s,int *l) {
00017                 int i;
00018 
00019                 *l = read(0, s, *l);
00020                 if (*l > -1)
00021                         s[*l] = 0;
00022                 while (strlen(s) && (s[strlen(s) - 1] == 13 || s[strlen(s) - 1] == 10))
00023                         s[strlen(s) - 1] = 0;
00024                 for (i = 0; i < (int)strlen(s); i++)
00025                         if (s[i] >= 'a' && s[i] <= 'z')
00026                                 s[i] -= 32;
00027                 return *l;
00028         }
00029         int write_text(char *s,int l) {
00030                 s[l] = 0;
00031                 printf("%s",s);
00032                 fflush(stdout);
00033                 return 0;
00034         }
00035 };
00036 
00037 
00038 int main(int argc,char *argv[])
00039 {
00040         Parser cmdline;
00041         IOC ioc;
00042         int n;
00043         char slask[200];
00044 
00045         cmdline.SetParserIO(&ioc);
00046         ioc.m_more = 1;
00047 
00048         if (argc > 1)
00049         {
00050                 sprintf(slask,"RUN %s",argv[1]);
00051                 cmdline.cmd( slask );
00052                 return 0;
00053         }
00054 
00055         printf("Welcome to asexec, the linux applesoft interpreter\n");
00056         *slask = 0;
00057         while ( strncasecmp(slask,"quit",4) )
00058         {
00059                 cmdline.flush_obuf();
00060                 printf("\n>");
00061                 fflush(stdout);
00062                 if ( (n = read(0, slask, 200)) == -1)
00063                 {
00064                         perror("read() failed");
00065                         exit(-1);
00066                 }
00067                 slask[n] = 0;
00068                 if (strncasecmp(slask,"quit",4))
00069                 {
00070                         cmdline.cmd( slask );
00071                 }
00072         }
00073         printf("Exit from asexec\n");
00074         return 0;
00075 }
00076 
Page, code, and content Copyright (C) 2005 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4