.


CircFileRead.c
/* CircFileRead.c */

/* Copyright(c) 1991-2006 by Motion Engineering, Inc.  All rights reserved.
 *
 * This software  contains proprietary and  confidential information  of
 * Motion Engineering Inc., and its suppliers.  Except as may be set forth
 * in the license agreement under which  this software is supplied, use,
 * disclosure, or  reproduction is prohibited without the prior express
 * written consent of Motion Engineering, Inc.
 */

#if defined(ARG_MAIN_RENAME)
#define main    CircFileReadMain
argMainRENAME(main, CircFileRead)
#endif

/*

:Read and display the contents of a circular file

This application reads and displays the contents of a circular file.  To
 convert a file from circular file format to normal format, type at the
 command line:

    CircFileRead inputfile > outputfile

 This application requires the files CircFile.c and CircFile.h.

Warning!  This is a sample program to assist in the integration of the
 XMP motion controller with your application.  It may not contain all
 of the logic and safety features that your application requires.

*/

#include <stdio.h>

#include "CircFile.h"


/* Display the contents of a circular file using C functions */
int main(int argc, char* argv[])
{
    CircFilePtr file;

    char    buffer[4096];

    if (argc < 2)
    {
        fprintf(stderr, "Usage: %s fileToRead\n", argv[0]);
        return -1;
    }

    file = circFileOpenForRead(argv[1]);

    if (file == NULL)
    {
        fprintf(stderr, "Could not open file %s\n", argv[1]);
        return -1;
    }

    printf("Line length:   %d\n", circFileLineLength(file));
    printf("Line count:    %d\n", circFileLineCount(file));

    while (!circFileEof(file))
    {
        circFileGets(file, buffer, sizeof(buffer));
        printf("%s", buffer);
    }

    circFileClose(file);

    return 0;
}


       Legal Notice  |  Tech Email  |  Feedback
      
Copyright ©
2001-2021 Motion Engineering