Ignore:
Timestamp:
Jul 14, 2015, 12:56:28 PM (10 years ago)
Author:
Alex Taylor
Message:

Added Sys2SyncBuffer function. Updated version number to 0.1.2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rxutilex/trunk/rxutilex.c

    r24 r25  
    8484#define SZ_LIBRARY_NAME         "RXUTILEX"  // Name of this library
    8585#define SZ_ERROR_NAME           "SYS2ERR"   // REXX variable used to store error codes
    86 #define SZ_VERSION              "0.1.1"     // Current version of this library
     86#define SZ_VERSION              "0.1.2"     // Current version of this library
    8787
    8888// Maximum string lengths...
     
    130130    "Sys2Seek",
    131131    "Sys2Read",
     132    "Sys2SyncBuffer",
    132133    "Sys2Write",
    133134    "Sys2Version"
     
    171172RexxFunctionHandler Sys2Read;
    172173RexxFunctionHandler Sys2Write;
     174RexxFunctionHandler Sys2SyncBuffer;
    173175
    174176
     
    20912093
    20922094
     2095/* ------------------------------------------------------------------------- *
     2096 * Sys2SyncBuffer                                                            *
     2097 *                                                                           *
     2098 * Wrapper to DosResetBuffer: for external files, write the buffer to disk;  *
     2099 * for pipes, block until the far end of the pipe has read the contents.     *
     2100 *                                                                           *
     2101 * REXX ARGUMENTS:                                                           *
     2102 *   1. File handle (returned by Sys2Open)                        (REQUIRED) *
     2103 *                                                                           *
     2104 * REXX RETURN VALUE:                                                        *
     2105 *   1 on success, or 0 if an error occurred.                                *
     2106 * ------------------------------------------------------------------------- */
     2107ULONG APIENTRY Sys2SyncBuffer( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult )
     2108{
     2109    HFILE  hf;
     2110    APIRET rc;
     2111
     2112    // Reset the error indicator
     2113    WriteErrorCode( 0, NULL );
     2114
     2115    // Make sure we have exactly one valid argument (the file handle)
     2116    if ( argc != 1  || ( !RXVALIDSTRING(argv[0]) ))
     2117        return ( 40 );
     2118    if (( sscanf( argv[0].strptr, "%8X", &hf )) != 1 ) return ( 40 );
     2119
     2120    // Sync the buffer
     2121    rc = DosResetBuffer( hf );
     2122    if ( rc != NO_ERROR ) {
     2123        WriteErrorCode( rc, "DosResetBuffer");
     2124        MAKERXSTRING( *prsResult, "0", 1 );
     2125    }
     2126    else {
     2127        MAKERXSTRING( *prsResult, "1", 1 );
     2128    }
     2129
     2130    return ( 0 );
     2131}
     2132
     2133
     2134
    20932135// -------------------------------------------------------------------------
    20942136// INTERNAL FUNCTIONS
Note: See TracChangeset for help on using the changeset viewer.