From: <to...@us...> - 2004-01-20 17:08:52
|
Update of /cvsroot/ro-oslib/OSLib/!OsLib/Tools/oslib/unix In directory sc8-pr-cvs1:/tmp/cvs-serv10228/OSLib/!OsLib/Tools/oslib/unix Modified Files: Tag: unix-build os.c osfile.c Log Message: Unix Build Index: os.c =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/oslib/unix/Attic/os.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** os.c 14 Jan 2004 13:33:16 -0000 1.1.2.1 --- os.c 20 Jan 2004 17:08:48 -0000 1.1.2.2 *************** *** 10,14 **** #include "oslib/os.h" ! //#include "support/unix.h" #include <signal.h> --- 10,17 ---- #include "oslib/os.h" ! #include "support/kernel.h" ! #include "support/riscos.h" ! //#include "support/trace.h" ! #include <signal.h> *************** *** 396,400 **** ! const os_error *_kernel_last_oserror(void) { if (errno == 0) { --- 399,403 ---- ! const os_error *(os_error *)_kernel_last_oserror(void) { if (errno == 0) { *************** *** 548,551 **** --- 551,577 ---- /* ------------------------------------------------------------------------ + * Function: os_writec() + * + * Description: Writes a character to all of the active output streams + * + * Input: c - value of R0 on entry + * + * Other notes: Calls SWI 0x0. + */ + + extern os_error *xos_writec (char c) + { + if( putchar( c ) == c ) + return 0; + else + return (os_error *)_kernel_last_oserror(); + } + + void os_writec (char c) + { + xos_writec( c ); + } + + /* ------------------------------------------------------------------------ * Function: os_writen() * *************** *** 568,572 **** *(temp + size) = '\0'; ! fprintf( stderr, "%s\n", temp ); free( temp ); --- 594,598 ---- *(temp + size) = '\0'; ! fprintf( stderr, "%s", temp ); free( temp ); *************** *** 614,615 **** --- 640,733 ---- xos_pretty_print( string, arg1, arg2 ); } + + /* ------------------------------------------------------------------------ + * Function: os_write0() + * + * Description: Writes a string to all of the active output streams + * + * Input: s - value of R0 on entry + * + * Other notes: Calls SWI 0x2. + */ + + extern os_error *xos_write0 (char const *s) + { + os_error *err = 0; + + if( s ) + { + int len = riscos_strlen( s ); + char* temp = malloc( len + 1 ); + riscos_strcpy( temp, s ); + if( fputs( temp, stdout ) < 0 ) + err = (os_error *)_kernel_last_oserror(); + free ( temp ); + } + return err; + } + + void os_write0 (char const *s) + { + xos_write0( s ); + } + + /* ------------------------------------------------------------------------ + * Function: os_new_line() + * + * Description: Writes a line feed followed by a carriage return to all + * of the active output streams + * + * Other notes: Calls SWI 0x3. + */ + + extern os_error *xos_new_line (void) + { + if( fputs( "\n\r", stdout ) > 0 ) + return 0; + else + return (os_error *)_kernel_last_oserror(); + } + + void os_new_line (void) + { + xos_new_line(); + } + + /* ------------------------------------------------------------------------ + * Function: os_readc() + * + * Description: Reads a character from the input stream + * + * Output: c - value of R0 on exit + * psr - processor status register on exit (X version only) + * + * Returns: psr (non-X version only) + * + * Other notes: Calls SWI 0x4. + */ + + extern os_error *xos_readc (char *c, bits *psr) + { + int chr; + chr = getchar( ); + + if( chr > 0 ) + { + *psr = 0; + *c = (char)chr; + return 0; + } + else + { + *psr = _V; + return (os_error *)_kernel_last_oserror(); + } + } + + extern bits os_readc (char *c) + { + bits psr; + xos_readc( c, &psr ); + return psr; + } + Index: osfile.c =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/oslib/unix/Attic/osfile.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** osfile.c 14 Jan 2004 13:33:16 -0000 1.1.2.1 --- osfile.c 20 Jan 2004 17:08:48 -0000 1.1.2.2 *************** *** 3,6 **** --- 3,13 ---- */ + //#define DEBUG + + #ifdef DEBUG + # undef DEBUG + # define DEBUG 1 + #endif + #include <stdlib.h> #include <stdio.h> *************** *** 13,19 **** # define mkdir _mkdir #elif defined (UNIX) ! # include <sys/stat.h> /* for mkdir */ #endif #include "oslib/osfile.h" --- 20,27 ---- # define mkdir _mkdir #elif defined (UNIX) ! # include <sys/stat.h> /* for mkdir */ #endif + #include "support/trace.h" #include "oslib/osfile.h" *************** *** 64,72 **** NOT_USED(entry_count); #if defined (UNIX) ! if ( mkdir( uname(dir_name,0,0), ! S_IRUSR | S_IWUSR | S_IXUSR | S_IROTH | S_IWOTH | S_IXOTH ! ) !=0 && errno!=17 ! ) #else if(mkdir(uname(dir_name,0,0))!=0 && errno!=17) --- 72,84 ---- NOT_USED(entry_count); + tracef( "xosfile_create_dir \"%s\"\n" _ dir_name ); + + #if DEBUG + fprintf( stderr, "xosfile_create_dir \"%s\"\n" , dir_name ); + #endif + #if defined (UNIX) ! if ( mkdir( dir_name, S_IRUSR | S_IWUSR | S_IXUSR | S_IROTH | S_IWOTH | S_IXOTH ) ! !=0 && errno!=17 ) #else if(mkdir(uname(dir_name,0,0))!=0 && errno!=17) *************** *** 74,78 **** { oserr.errnum = 0x10001; ! sprintf(oserr.errmess, "Mkdir error %d", errno); return &oserr; } --- 86,90 ---- { oserr.errnum = 0x10001; ! sprintf(oserr.errmess, "osfile_create_dir [%d]: %s", errno, strerror(errno)); return &oserr; } |