Changeset f261cc8 in buchla-68k for libcio


Ignore:
Timestamp:
07/16/2017 12:10:45 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
1c4f9be
Parents:
0c06bc5
Message:

Minor cleanup.

Location:
libcio
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • libcio/filesys.c

    r0c06bc5 rf261cc8  
    783783   =============================================================================
    784784        _inifcb(fcp, name, ext, mode) -- initialize FCB pointed to by 'fcp'
    785         for file named 'name'.'ext' in mode 'mode'.
     785        for file named 'name'.'ext'.
    786786        Returns SUCCESS (0) if ok, FAILURE (-1) if not.
    787787   =============================================================================
    788788*/
    789789
    790 int16_t _inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, uint16_t mode)
     790int16_t _inifcb(struct fcb *fcp, int8_t *name, int8_t *ext, uint16_t flags)
    791791{
    792792        int16_t fl;
     
    800800        /* check for valid flags */
    801801
    802         if (mode & ~(O_WRONLY|O_RDWR|O_NDELAY|O_APPEND|O_CREAT|O_TRUNC|O_EXCL|O_RAW))
     802        if (flags & ~(O_WRONLY|O_RDWR|O_NDELAY|O_APPEND|O_CREAT|O_TRUNC|O_EXCL|O_RAW))
    803803                return(FAILURE);
    804804
     
    871871        /* set the flags in the FCB and exit */
    872872
    873         if (mode & O_RDONLY)
     873        if (flags & O_RDONLY)
    874874                fcp->modefl |= FC_RD;
    875875
    876         if (mode & O_WRONLY)
     876        if (flags & O_WRONLY)
    877877                fcp->modefl |= FC_WR;
    878878
    879         if (mode & O_RDWR)
     879        if (flags & O_RDWR)
    880880                fcp->modefl |= FC_RW;
    881881
    882         if (mode & O_NDELAY)
     882        if (flags & O_NDELAY)
    883883                fcp->modefl |= FC_NB;
    884884
    885         if (mode & O_APPEND)
     885        if (flags & O_APPEND)
    886886                fcp->modefl |= FC_AP;
    887887
    888         if (mode & O_CREAT)
     888        if (flags & O_CREAT)
    889889                fcp->modefl |= FC_CR;
    890890
    891         if (mode & O_TRUNC)
     891        if (flags & O_TRUNC)
    892892                fcp->modefl |= FC_TR;
    893893
    894         if (mode & O_EXCL)
     894        if (flags & O_EXCL)
    895895                fcp->modefl |= FC_EX;
    896896
    897         if (mode & O_RAW)
     897        if (flags & O_RAW)
    898898                fcp->modefl |= FC_BF;
    899899
  • libcio/fopen.c

    r0c06bc5 rf261cc8  
    88#include "ram.h"
    99
    10 FILE *_opener(int8_t *name, int8_t *mode, uint16_t rawflg)
     10FILE *_opener(int8_t *name, int8_t *mode, uint16_t raw)
    1111{
    1212        register FILE *fp;
     
    2626
    2727        case 'r':       /* read mode */
    28                 if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_RDONLY) | rawflg)) EQ -1)
     28                if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_RDONLY) | raw)) EQ -1)
    2929                        return(NULL);
    3030                break;
    3131
    3232        case 'w':       /* write mode */
    33                 if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|O_TRUNC|rawflg)) EQ -1)
     33                if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|O_TRUNC|raw)) EQ -1)
    3434                        return(NULL);
    3535
     
    3737       
    3838        case 'a':       /* append mode */
    39                 if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|rawflg)) EQ -1)
     39                if ((fp->_unit = open(name, (plusopt ? O_RDWR : O_WRONLY)|O_CREAT|raw)) EQ -1)
    4040                        return(NULL);
    4141
  • libcio/fopen.x

    r0c06bc5 rf261cc8  
    1616*/
    1717
    18 extern  FILE            *_opener(int8_t *name, int8_t *mode, uint16_t aflag);
     18extern  FILE            *_opener(int8_t *name, int8_t *mode, uint16_t raw);
    1919extern  FILE            *fopen(int8_t *name, int8_t *mode);
    2020extern  FILE            *fopena(int8_t *name, int8_t *mode);
  • libcio/fsinit.c

    r0c06bc5 rf261cc8  
    6969*/
    7070
    71 int16_t _nopo(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp)
     71int16_t _nopo(int8_t *name, uint16_t flags, struct channel *chp, struct devtabl *dp)
    7272{
    7373        (void)name;
    74         (void)flag;
     74        (void)flags;
    7575        (void)chp;
    7676        (void)dp;
  • libcio/fsinit.x

    r0c06bc5 rf261cc8  
    4646extern  int16_t         _badfio(io_arg arg, void *buff, int16_t len);
    4747extern  int16_t         _nopc(io_arg arg);
    48 extern  int16_t         _nopo(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp);
     48extern  int16_t         _nopo(int8_t *name, uint16_t flags, struct channel *chp, struct devtabl *dp);
  • libcio/open.c

    r0c06bc5 rf261cc8  
    3434*/
    3535
    36 int16_t open(int8_t *name, uint16_t flag)
     36int16_t open(int8_t *name, uint16_t flags)
    3737{
    3838        register struct devtabl *dp;
     
    5858
    5959        dev = dp->d_dev;
    60         mdmask = (flag & 3) + 1;
     60        mdmask = (flags & 3) + 1;
    6161
    6262        if (mdmask & 1) {       /* see if device is readable */
     
    8585        chp->c_close = _nopc;
    8686
    87         if ((*dev->d_open)(name, flag, chp, dp) < 0) {  /* open */
     87        if ((*dev->d_open)(name, flags, chp, dp) < 0) { /* open */
    8888
    8989                chp->c_close = _badfc;  /* couldn't open for some reason */
     
    9696/*
    9797   =============================================================================
    98         opena(name, flag, mode) -- Opens ASCII file 'name' with flags 'flag'
    99         and access mode 'mode'.  Newline translation will be done.
    100         Returns a file descriptor (small positive integer) if successful, or
    101         FAILURE (-1) if an error occurred.
    102    =============================================================================
    103 */
    104 
    105 int16_t opena(int8_t *name, uint16_t flag)
    106 {
    107         return(open(name, flag));
    108 }
    109 
    110 /*
    111    =============================================================================
    112         openb(name, flag, mode) -- Opens binary file 'name' with flags 'flag'
    113         and access mode 'mode'.  No newline translation is done.
    114         Returns a file descriptor (small positive integer) if successful, or
    115         FAILURE (-1) if an error occurred.
    116    =============================================================================
    117 */
    118 
    119 int16_t openb(int8_t *name, uint16_t flag)
    120 {
    121         return(open(name, flag|O_RAW));
    122 }
    123 
    124 /*
    125    =============================================================================
    126         creat(name, mode) -- Creates file 'name' with access mode 'mode'.
     98        opena(name, flag, mode) -- Opens ASCII file 'name' with flags 'flags'
     99        Newline translation will be done.
     100        Returns a file descriptor (small positive integer) if successful, or
     101        FAILURE (-1) if an error occurred.
     102   =============================================================================
     103*/
     104
     105int16_t opena(int8_t *name, uint16_t flags)
     106{
     107        return(open(name, flags));
     108}
     109
     110/*
     111   =============================================================================
     112        openb(name, flag, mode) -- Opens binary file 'name' with flags 'flags'.
     113        No newline translation is done.
     114        Returns a file descriptor (small positive integer) if successful, or
     115        FAILURE (-1) if an error occurred.
     116   =============================================================================
     117*/
     118
     119int16_t openb(int8_t *name, uint16_t flags)
     120{
     121        return(open(name, flags|O_RAW));
     122}
     123
     124/*
     125   =============================================================================
     126        creat(name, mode) -- Creates file 'name'.
    127127        The created file is initially open for writing only.  The file
    128         will be ASCII unless mode contains O_RAW.
     128        will be ASCII.
    129129        Returns a file descriptor (small positive integer) if successful, or
    130130        FAILURE (-1) if an error occurred.
     
    139139/*
    140140   =============================================================================
    141         creata(name, mode) -- Creates ASCII file 'name' with access mode 'mode'.
     141        creata(name, mode) -- Creates ASCII file 'name'.
    142142        The created file is initially open for writing only.
    143143        Files created with creata() do newline translations.
     
    154154/*
    155155   =============================================================================
    156         creatb(name, mode) -- create binary file 'name' with access mode 'mode'.
     156        creatb(name, mode) -- create binary file 'name'.
    157157        The created file is initially open for writing only.
    158158        Files created with creatb don't do newline translations.
     
    175175*/
    176176
    177 int16_t _fileop(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp)
     177int16_t _fileop(int8_t *name, uint16_t flags, struct channel *chp, struct devtabl *dp)
    178178{
    179179        register struct fcb *fp;
     
    195195        /* setup the initial fcb */
    196196
    197         if (_inifcb(fp, FilName(name, tmpname), FilExt(name, tmpext), flag)) {
     197        if (_inifcb(fp, FilName(name, tmpname), FilExt(name, tmpext), flags)) {
    198198
    199199                errno = EINVAL;         /* bad file name or flags */
  • libcio/open.x

    r0c06bc5 rf261cc8  
    1616*/
    1717
    18 extern  int16_t         _fileop(int8_t *name, uint16_t flag, struct channel *chp, struct devtabl *dp);
     18extern  int16_t         _fileop(int8_t *name, uint16_t flags, struct channel *chp, struct devtabl *dp);
    1919extern  int16_t         creat(int8_t *name);
    2020extern  int16_t         creata(int8_t *name);
    2121extern  int16_t         creatb(int8_t *name);
    22 extern  int16_t         open(int8_t *name, uint16_t flag);
    23 extern  int16_t         opena(int8_t *name, uint16_t flag);
    24 extern  int16_t         openb(int8_t *name, uint16_t flag);
     22extern  int16_t         open(int8_t *name, uint16_t flags);
     23extern  int16_t         opena(int8_t *name, uint16_t flags);
     24extern  int16_t         openb(int8_t *name, uint16_t flags);
  • libcio/putl.c

    r0c06bc5 rf261cc8  
    2121                return;
    2222
    23         putc((w & 0xFF), stream);
     23        putc((int16_t)(w & 0xFF), stream);
    2424}
    2525
  • libcio/putw.c

    r0c06bc5 rf261cc8  
    1212void putw(int32_t w, FILE *stream)
    1313{
    14         if (putc(((w >> 8) & 0xFF), stream) < 0 )
     14        if (putc((int16_t)((w >> 8) & 0xFF), stream) < 0 )
    1515                return;
    1616
    17         putc((w & 0xFF), stream);
     17        putc((int16_t)(w & 0xFF), stream);
    1818}
    1919
Note: See TracChangeset for help on using the changeset viewer.