Commit 601d0fa3 authored by kollo's avatar kollo

version 1.15

parent 9b48224a
......@@ -17,27 +17,8 @@ In order to compile X11Basic, you will need the following:
These will suffice to get you started.
FAST INSTALL
INSTALLATION
============
just run install.sh:
sh ./install.sh
a xbasic binary will be compiled into the ./src/ directory
cd src/
make install
will copy the binary in ${HOME}/bin/
If the `install.sh' script fails, please contact me (kollo@users.sourceforge.net)
and send me the output it generated (install.log).
CONFIGURATION
=============
cd src/
X11Basic uses a "configure" script generated by Cygnus' Autoconf program in
order to determine system-dependent configuration parameters. Invoke the script
by typing
......@@ -54,6 +35,10 @@ This will generate a `Makefile'
and generate dependencies for the Makefile. It will
also generate some more sources.
Then do the compilation:
make
sudo make install
ADDITIONAL CONFIGURATION OPTIONS
......
This diff is collapsed.
......@@ -10,13 +10,13 @@
VERSION 1.13
VERSION 1.15
(C) 1997-2006 by Markus Hoffmann
(C) 1997-2010 by Markus Hoffmann
(kollo@users.sourceforge.net)
Name : X11Basic
Version : 1.13 Vendor: Markus Hoffmann
Version : 1.15 Vendor: Markus Hoffmann
Group : Development/Languages License: GPL
Packager : Markus Hoffmann <kollo@users.sourceforge.net>
URL : http://x11-basic.sourceforge.net/
......
This diff is collapsed.
......@@ -54,7 +54,7 @@ xbasic -e version
fi
AC_PROG_CC
AC_PROG_INSTALL
#AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_CPP
......@@ -340,5 +340,5 @@ AC_SUBST(libs)
AC_SUBST(xtra)
AC_SUBST(copt)
AC_SUBST(static)
AC_OUTPUT([../examples/compiler/xbc.bas Makefile],
AC_OUTPUT([examples/compiler/xbc.bas Makefile],
make depend)
......@@ -379,15 +379,46 @@ plune9$=plune9$+"@P^U0LPcP:5TW3()AO*$6[<MGWTaX&<X@\N9Eb,c]X_:*EVN`2Z52,>H8X/FNUC
plune9$=plune9$+"CDa.%aA;573ZCO7VDG9>\/7C/RK4;P;,6Ib$0)T;KB:*c*RKSMM[-E4N$4$$"
plune9_bmp$=UNCOMPRESS$(INLINE$(plune9$))
color 0
pbox 0,0,320,200
color get_color(40000,30000,0)
deftext 1
text 10,30,"MOON-Phase-Animation with X11-Basic"
do
for i=1 to 28
t$="a$=plune"+str$(i)+"_bmp$"
&t$
put 100,100,a$
text 100,150,str$(i)+" "
print i
vsync
pause 0.1
next i
loop
' nph=0 Neumond
' nph=1 1. viertel
' nph=2 Vollmond
' nph=3 letztes viertel
' Rueckgabe ist julianischer tag
function mondtag(n,nph)
local c,t,t2,as,am,jd
c=n+nph/4
t=c/1236.85
as=359.2242+29.105356*c+((1.178e-4)-(1.55e-7)*t)*t^2
am=306.0253+385.816918*c+0.010730*t^2
jd=2415020+28*n+7*nph+0.75933+1.53058868*c
if nph=0 or nph=2
add jd,(0.1734-3.93e-4*t)*sin(rad(as))-0.4068*sin(rad(am))
else if nph=1 or nph=3
add jd,(0.1721-4e-4*t)*sin(rad(as))-0.6280*sin(rad(am))
else
return 0
endif
return jd
endfunction
......@@ -23,9 +23,6 @@
#ifdef FRAMEBUFFER
#include "framebuffer.h"
#endif
#ifdef FRAMEBUFFER
int global_mousex,global_mousey,global_mousek,global_mouses;
#endif
......@@ -280,7 +277,9 @@ void c_sget(char *n) {
#endif
}
void c_getgeometry(PARAMETER *plist,int e) {
#ifndef WINDOWS
int winnr=DEFAULTWINDOW;
int d,b,x,y,w,h;
#ifndef FRAMEBUFFER
......@@ -322,8 +321,11 @@ void c_getgeometry(PARAMETER *plist,int e) {
else if(plist[1].integer==FLOATTYP) *((double *)plist[1].pointer)=(double)x;
}
} else printf("Ungltige Windownr. %d. Max: %d. Or Window not yet opened.\n",winnr,MAXWINDOWS);
#endif
}
void c_getscreensize(PARAMETER *plist,int e) {
#ifndef WINDOWS
int d,b,x,y,w,h;
#ifndef FRAMEBUFFER
Window root;
......@@ -359,10 +361,9 @@ void c_getscreensize(PARAMETER *plist,int e) {
if(plist[0].integer==INTTYP) *((int *)plist[0].pointer)=x;
else if(plist[0].integer==FLOATTYP) *((double *)plist[0].pointer)=(double)x;
}
#endif
}
void c_sput(PARAMETER *plist,int e) {
if(e) {
#ifndef WINDOWS
......
#! /bin/sh
# X11-Basic erzeugen
#
(echo "New installation of X11-Basic from " ; date) >install.log 2>&1
echo "X11-Basic will be created..."
cd src
make distclean >>../install.log 2>&1
echo "*** X11-Basic Version " >>../install.log
grep 'version="' configure >>../install.log 2>&1
(echo "*** System ist ein " ; uname -a )>>../install.log 2>&1
(echo "*** Vorhandene Dateien" ; ls -al )>>../install.log 2>&1
echo "===Running configure ..." | tee -a ../install.log | tr -d =
chmod 755 ./configure
chmod 755 ./config.guess
./configure >>../install.log 2>&1
# sucess ?
if [ $? -eq 0 ]
then
echo "===Trying to make xbasic ..." | tee -a ../install.log | tr -d =
make >>../install.log 2>&1
# sucess ?
if [ $? -eq 0 ]
then
echo "===Testing xbasic ..." | tee -a ../install.log | tr -d =
./xbasic -e "version" >>../install.log 2>&1
a=$?
echo "return value: " $a >>../install.log 2>&1
# sucess ?
if [ $a -eq 0 ]
then
echo
echo "===SUCESS, you may now start xbasic from the directory ./src" | tee -a ../install.log | tr -d =
echo "===or install it in system by typing 'cd src ; make install' (need to be root)" | tee -a ../install.log | tr -d =
echo
else
echo
echo "===FAILURE, the tests have failed" | tee -a ../install.log | tr -d =
echo "===xbasic has not been built properly !" | tee -a ../install.log | tr -d =
echo " Maybe it will work anyway. Try to execute xbasic from the directory ./src"
echo " please email error report and install.log to kollo@users.sourceforge.net"
echo
fi
else
echo
echo "===FAILURE, could not make xbasic !" | tee -a ../install.log | tr -d =
echo " please email error report and install.log to kollo@users.sourceforge.net"
echo
fi
else
echo
echo "===FAILURE, could not configure X11-Basic" | tee -a ../install.log | tr -d =
echo " please email error report and install.log to kollo@users.sourceforge.net"
echo
fi
# append config.log to install.log
echo "===config.log:" >>../install.log
cat config.log >>../install.log 2>&1
......@@ -813,6 +813,7 @@ const struct {int sf; char xf; } ioemaptable[] = {
#ifdef ENOSTR
{ ENOSTR, -60 }, /* 60: Device not a stream */
#endif
#ifdef ENOTSOCK
{ ENOTSOCK, -88 }, /* 88: Socket operation on non-socket */
{ EOPNOTSUPP, -95 }, /* 95: Operation not supported on transport endpoint */
......@@ -833,6 +834,7 @@ const struct {int sf; char xf; } ioemaptable[] = {
{ ENOTCONN, -107 }, /* 107: Transport endpoint is not connected */
{ ETIMEDOUT, -110 }, /* 110: Connection timed out */
{ ECONNREFUSED,-111 } /* 111: Connection refused */
#endif
};
const int anztabs=sizeof(ioemaptable)/sizeof(struct {int sf; char xf; });
......@@ -950,6 +952,7 @@ void c_pipe(PARAMETER *plist,int e) {
if(filenr[i] || filenr[j]) xberror(22,""); /* File schon geoeffnet */
else {
int filedes[2];
#ifndef WINDOWS
if(pipe(filedes)) io_error(errno,"PIPE");
else {
dptr[i]=fdopen(filedes[0],"r");
......@@ -959,6 +962,9 @@ void c_pipe(PARAMETER *plist,int e) {
if(dptr[j]==NULL) printf("Error with fdopen! should not happen\n");
else filenr[j]=1;
}
#else
io_error(errno,"PIPE");
#endif
}
}
}
......@@ -1404,9 +1410,12 @@ int f_ioctl(PARAMETER *plist,int e) {
fff=get_fileptr(plist[0].integer);
if(fff==NULL) {xberror(24,"");return;} /* File nicht geoeffnet */
sock=fileno(fff);
#ifndef WINDOWS
if (e==2) ret=ioctl(sock,plist[1].integer);
else ret=ioctl(sock,plist[1].integer,(void *)plist[2].integer);
if(ret==-1) io_error(errno,"ioctl");
if(ret==-1)
#endif
io_error(errno,"ioctl");
}
return(ret);
}
......
......@@ -13,6 +13,11 @@
#include <string.h>
#include <unistd.h>
#include <signal.h>
#ifdef WINDOWS
#define EX_OK 0
#else
#include <sysexits.h>
#endif
#include <ctype.h>
#include "defs.h"
#include <time.h>
......@@ -87,7 +92,8 @@ void c_spawn(char *n) {
pc2=procnr(buffer,1);
if(pc2==-1) xberror(19,buffer); /* Procedure nicht gefunden */
else {
else {
#ifndef WINDOWS
pid_t forkret=fork();
if(forkret==-1) io_error(errno,"SPAWN");
if(forkret==0) {
......@@ -101,9 +107,10 @@ void c_spawn(char *n) {
xberror(39,buffer); /* Program Error Gosub impossible */
}
programmlauf();
exit(1);
exit(EX_OK);
}
}
#endif
}
free(buffer);
}
......@@ -1436,7 +1443,7 @@ void c_shm_free(PARAMETER *plist,int e) {
}
void c_pause(PARAMETER *plist,int e) {
#ifdef WINDOWS
sleep((int)(1000*plist[0].real));
Sleep((int)(1000*plist[0].real));
#else
double zeit=plist[0].real;
int i=(int)zeit;
......
......@@ -11,6 +11,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WINDOWS
#define EX_OK 0
#else
#include <sysexits.h>
#endif
#include "defs.h"
void reset_input_mode();
......@@ -126,7 +131,7 @@ void kommandozeile(int anzahl, char *argumente[]) {
HINSTANCE hInstance;
#endif
extern char *simple_gets(char *);
main(int anzahl, char *argumente[]) {
int main(int anzahl, char *argumente[]) {
char buffer[MAXSTRLEN],*zw;
#ifdef WINDOWS
hInstance=GetModuleHandle(NULL);
......@@ -163,4 +168,5 @@ main(int anzahl, char *argumente[]) {
kommando(buffer);
}
}
return(EX_OK);
}
......@@ -76,7 +76,7 @@ void break_handler( int signum) {
#ifdef DOOCS
doocssig_handler(signum);
#endif
signal(SIGINT, obh);
signal(SIGINT, SIG_DFL);
raise(signum);
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* XBVM.C The X11-basic virtual machine. (c) Markus Hoffmann
*/
/* This file is part of X11BASIC, the basic interpreter for Unix/X
* ======================================================================
* X11BASIC is free software and comes with NO WARRANTY - read the file
* COPYING for details
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "defs.h"
#include "vtypes.h"
#include "ptypes.h"
#include "bytecode.h"
void reset_input_mode();
void x11basicStartup();
void programmlauf();
void kommando(char *);
extern char *databuffer;
extern int param_anzahl;
extern char **param_argumente;
extern const char xbasic_name[];
extern int pc,sp,err,errcont,everyflag,batch,echoflag;
const char version[]=VERSION; /* Programmversion */
const char vdate[]=VERSION_DATE;
extern const char libversion[];
extern const char libvdate[];
int loadfile=FALSE;
char ifilename[100]="b.b";
int prglen=0;
int runfile,daemonf;
int programbufferlen=0;
char *programbuffer=NULL;
char *program[MAXPRGLEN];
STRING bcpc;
int verbose=1;
void intro(){
puts("***************************************************************");
printf("* %10s V.%5s *\n",xbasic_name, version);
puts("* by Markus Hoffmann 1997-2008 (c) *");
puts("* *");
printf("* version date: %30s *\n",vdate);
printf("* library V. %s date: %30s *\n",libversion,libvdate);
puts("***************************************************************");
puts("");
}
void usage(){
puts("\n Usage:\n ------ \n");
printf(" %s [-e -h -l] [<filename>] --- run basic program [%s]\n\n",xbasic_name,ifilename);
puts("-l --- do not run the program (only load)");
puts("-e <command> --- execute basic command");
puts("--eval <exp> --- evaluate num. expression");
puts("-h --help --- Usage");
puts("-q --quiet --- be more quiet");
puts("-v --verbose --- be more verbose");
puts("--help <topic> --- Print help on topic\n");
}
void kommandozeile(int anzahl, char *argumente[]) {
int count,quitflag=0;
char buffer[100];
/* Kommandozeile bearbeiten */
runfile=TRUE;
for(count=1;count<anzahl;count++) {
if (strcmp(argumente[count],"-l")==FALSE) runfile=FALSE;
else if (strcmp(argumente[count],"--load-only")==FALSE) runfile=FALSE;
else if (strcmp(argumente[count],"--eval")==FALSE) {
printf("%.13g\n",parser(argumente[++count]));
quitflag=1;
} else if (strcmp(argumente[count],"-e")==FALSE) {
kommando(argumente[++count]);
quitflag=1;
} else if (strcmp(argumente[count],"--exec")==FALSE) {
kommando(argumente[++count]);
quitflag=1;
} else if (strcmp(argumente[count],"-v")==FALSE) {
verbose++;
} else if (strcmp(argumente[count],"-q")==FALSE) {
verbose--;
} else if (strcmp(argumente[count],"-h")==FALSE) {
intro();
usage();
quitflag=1;
} else if (strcmp(argumente[count],"--help")==FALSE) {
intro();
if(count<anzahl-1 && *argumente[count+1]!='-') {
strncpy(buffer,argumente[count+1],100);
xtrim(buffer,TRUE,buffer);
c_help(buffer);
} else usage();
quitflag=1;
} else if (strcmp(argumente[count],"--daemon")==FALSE) {
intro();
daemonf=1;
} else {
if(!loadfile) {
loadfile=TRUE;
strcpy(ifilename,argumente[count]);
}
}
}
if(quitflag) c_quit("",0);
}
void loadbcprg(char *filename) {
int len;
FILE *dptr;
clear_parameters();
programbufferlen=prglen=pc=sp=0;
dptr=fopen(filename,"r"); len=lof(dptr); fclose(dptr);
bcpc.pointer=malloc(len);
bload(filename,bcpc.pointer,len);
bcpc.len=len;
if(verbose) printf("%s loaded (%d Bytes)\n",filename,len);
/* Ueberpruefe ob ein gueltiger Header dabei ist und setze databuffer */
if(bcpc.pointer[0]==BC_BRAs && bcpc.pointer[1]==sizeof(BYTECODE_HEADER)) {
if(verbose) printf("Bytecode header found (V.%d)\n",
((BYTECODE_HEADER *)bcpc.pointer)->version);
databuffer=bcpc.pointer+((BYTECODE_HEADER *)bcpc.pointer)->textseglen+sizeof(BYTECODE_HEADER);
if(verbose) printf("Databuffer $%08x contains: <%s>\n",(long)databuffer,databuffer);
}
}
void doit() {
PARAMETER *p;
int n;
if(verbose) printf("Virtual Machine: %d Bytes\n",bcpc.len);
p=virtual_machine(bcpc,&n);
if(n) {
int j;
printf("\nAuf dem Stapel sind %d Parameter:\n",n);
for(j=0;j<n;j++) {
printf("%2d: ",j);
if(p[j].typ==PL_INT) printf(" int %d\n",p[j].integer);
else if(p[j].typ==PL_FLOAT) printf(" flt %g\n",p[j].real);
else if(p[j].typ==PL_STRING) printf(" $ <%s>\n",p[j].pointer);
else if(p[j].typ==PL_KEY) printf(" KEY <%s>\n",p[j].pointer);
else printf("%d %d %g\n",p[j].typ,p[j].integer,p[j].real);
}
}
free_pliste(n,p);
}
main(int anzahl, char *argumente[]) {
char *obcpc;
x11basicStartup(); /* initialisieren */
set_input_mode(1,0); /* Terminalmode auf noncanonical, no echo */
atexit(reset_input_mode);
param_anzahl=anzahl;
param_argumente=argumente;
if(anzahl<2) { /* Kommandomodus */
intro();
batch=0;
} else {
kommandozeile(anzahl, argumente); /* Kommandozeile bearbeiten */
if(loadfile) {
if(exist(ifilename)) {
loadbcprg(ifilename);
obcpc=bcpc.pointer;
if(runfile) doit();
free(obcpc);
} else printf("ERROR: %s not found !\n",ifilename);
}
}
}
......@@ -11,6 +11,11 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#ifdef WINDOWS
#define EX_OK 0
#else
#include <sysexits.h>
#endif
#include <sys/types.h>
......@@ -136,22 +141,14 @@ void createsem(int *sid, key_t key, int members) {
union semun semopts;
if(members > SEMMSL) {
printf("Sorry, max number of semaphores in a set is %d\n",
SEMMSL);
exit(1);
printf("Sorry, max number of semaphores in a set is %d\n",SEMMSL);
exit(EX_OSERR);
}
printf("Attempting to create new semaphore set with %d members\n",
members);
if((*sid = semget(key, members, IPC_CREAT|IPC_EXCL|0666))
== -1)
{
printf("Attempting to create new semaphore set with %d members\n",members);
if((*sid = semget(key, members, IPC_CREAT|IPC_EXCL|0666))== -1) {
fprintf(stderr, "Semaphore set already exists!\n");
exit(1);
}
exit(EX_OSERR);
}
semopts.val = SEM_RESOURCE_MAX;
......@@ -175,24 +172,17 @@ void locksem(int sid, int member)
/* Attempt to lock the semaphore set */
if(!getval(sid, member))
{
if(!getval(sid, member)) {
fprintf(stderr, "Semaphore resources exhausted (no lock)!\n");
exit(1);
exit(EX_OSERR);
}
sem_lock.sem_num = member;
if((semop(sid, &sem_lock, 1)) == -1)
{
if((semop(sid, &sem_lock, 1)) == -1) {
fprintf(stderr, "Lock failed\n");
exit(1);
}
else
printf("Semaphore resources decremented by one (locked)\n");
exit(EX_OSERR);
} else printf("Semaphore resources decremented by one (locked)\n");
dispval(sid, member);
}
......@@ -213,21 +203,16 @@ void unlocksem(int sid, int member)
semval = getval(sid, member);
if(semval == SEM_RESOURCE_MAX) {
fprintf(stderr, "Semaphore not locked!\n");
exit(1);
exit(EX_OSERR);
}
sem_unlock.sem_num = member;
/* Attempt to lock the semaphore set */
if((semop(sid, &sem_unlock, 1)) == -1)
{
if((semop(sid, &sem_unlock, 1)) == -1) {
fprintf(stderr, "Unlock failed\n");
exit(1);
}
else
printf("Semaphore resources incremented by one (unlocked)\n");
exit(EX_OSERR);
} else printf("Semaphore resources incremented by one (unlocked)\n");
dispval(sid, member);
}
......@@ -257,29 +242,20 @@ int getval(int sid, int member) {
}
void changemode(int sid, char *mode)
{
int rc;
union semun semopts;
struct semid_ds mysemds;
void changemode(int sid, char *mode) {
int rc;
union semun semopts;
struct semid_ds mysemds;
/* Get current values for internal data structure */
semopts.buf = &mysemds;
rc = semctl(sid, 0, IPC_STAT, semopts);
if (rc == -1) {
perror("semctl");
exit(1);
exit(EX_OSERR);
}
printf("Old permissions were %o\n", semopts.buf->sem_perm.mode);
......
......@@ -384,7 +384,10 @@ winbesetzt[nummer]=1;
}
return(nummer);
}
#ifndef WINDOWS
void handle_event(int,XEvent *);
#endif
void open_window(int nr) {
if(winbesetzt[nr]) {
......@@ -660,7 +663,8 @@ char *imagetoxwd(XImage *image,Visual *visual,XColor *pixc, int *len) {
void bmp2bitmap(char *data,char *fbp,int x, int bw,int bh,int depth) {
unsigned short *ptr1 = (unsigned short*)fbp;
int r,g,b,i,j,w,h,offset,ncol,d,ib,ic=0;
int r,g,b