// (c) 2005-2007 Electronic Arts Inc.

#if defined(_MSC_VER)
#pragma warning(disable: 4996)  // warning C4996: 'fscanf' was declared deprecated
#endif
#if defined(__ICL)
#pragma warning(disable: 1478)  // (icl) warning #1478: function "strcpy" was declared "deprecated"
#endif

#include <stdio.h>
#include <stdlib.h>

unsigned char buf[1024*1024];

int main(int argc, char **argv)
{
    FILE *ifile;
    FILE *ofile;
    char fname[256];
    int idx=0;
    int len;

    if(argc == 3)
    {
        ofile=fopen(argv[1],"wb");
        for (;;)
        {
            sprintf(fname,"%s.%03d",argv[2],idx);
            ifile=fopen(fname,"rb");
            if(ifile)
            {
                printf("image %s\n",fname);
                for (;;)
                {
                    printf(".");
                    len=(int)fread(buf,1,1024*1024,ifile);
                    if (!len)
                    {
                        break;
                    }
                    fwrite(buf,1,len,ofile);
                }
                fclose(ifile);
                printf("\n");
            }
            else
            {
                break;
            }
            idx++;
        }
        fclose(ofile);
    }
    else
    {
        printf("Sony2Dvd v1.01 (Fromme) 2004.11.05 by Jeff Litz and FrANK G. Barchard\n"
        "sony2dvd <output image name> <base name of source files>\n");
    }
}
