Annotation of coherent/d/usr/bin/elvis/atari.c, revision 1.1.1.1

1.1       root        1: /* atari.c */
                      2: 
                      3: /* Author:
                      4:  *     Guntram Blohm
                      5:  *     Buchenstrasse 19
                      6:  *     7904 Erbach, West Germany
                      7:  *     Tel. ++49-7305-6997
                      8:  *     sorry - no regular network connection
                      9:  */
                     10: 
                     11: /*
                     12:  * This file contains the 'standard' functions which are not supported
                     13:  * by Atari/Mark Williams, and some other TOS-only requirements.
                     14:  */
                     15:  
                     16: #include "config.h"
                     17: #include "vi.h"
                     18: 
                     19: #if TOS
                     20: #include <osbind.h>
                     21: 
                     22: /* vi uses mode==0 only ... */
                     23: int access(file, mode)
                     24:        char *file;
                     25: {
                     26:        int fd=Fopen(file, 0);
                     27:        if (fd<0)
                     28:                return -1;
                     29:        Fclose(fd);
                     30:        return 0;
                     31: }
                     32: 
                     33: char *mktemp(template)
                     34:        char *template;
                     35: {
                     36:        return template;
                     37: }
                     38: 
                     39: /* read -- text mode, compress \r\n to \n
                     40:  * warning: might fail when maxlen==1 and at eol
                     41:  */
                     42: 
                     43: int tread(fd, buf, maxlen)
                     44:        int fd;
                     45:        char *buf;
                     46:        int maxlen;
                     47: {
                     48:        int i, j, nread=read(fd, buf, (unsigned)maxlen);
                     49: 
                     50:        if (nread && buf[nread-1]=='\r')
                     51:        {       nread--;
                     52:                lseek(fd, -1l, 1);
                     53:        }
                     54:        for (i=j=0; j<nread; i++,j++)
                     55:        {       if (buf[j]=='\r' && buf[j+1]=='\n')
                     56:                        j++;
                     57:                buf[i]=buf[j];
                     58:        }
                     59:        return i;
                     60: }
                     61: 
                     62: int twrite(fd, buf, maxlen)
                     63:        int fd;
                     64:        char *buf;
                     65:        int maxlen;
                     66: {
                     67:        int i, j, nwritten=0, hadnl=0;
                     68:        char writbuf[BLKSIZE];
                     69: 
                     70:        for (i=j=0; j<maxlen; )
                     71:        {
                     72:                if ((writbuf[i++]=buf[j++])=='\n')
                     73:                {       writbuf[i-1]='\r';
                     74:                        if (i<BLKSIZE)
                     75:                                writbuf[i++]='\n';
                     76:                        else
                     77:                                hadnl=1;
                     78:                }
                     79:                if (i==BLKSIZE)
                     80:                {
                     81:                        write(fd, writbuf, (unsigned)i);
                     82:                        i=0;
                     83:                }
                     84:                if (hadnl)
                     85:                {
                     86:                        writbuf[i++]='\n';
                     87:                        hadnl=0;
                     88:                }
                     89:        }
                     90:        if (i)
                     91:                write(fd, writbuf, (unsigned)i);
                     92:        return j;
                     93: }
                     94: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.