diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/softpc.new/convert | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to '')
-rw-r--r-- | private/mvdm/softpc.new/convert/convert.c | 84 | ||||
-rw-r--r-- | private/mvdm/softpc.new/convert/sources | 55 |
2 files changed, 139 insertions, 0 deletions
diff --git a/private/mvdm/softpc.new/convert/convert.c b/private/mvdm/softpc.new/convert/convert.c new file mode 100644 index 000000000..040d5f662 --- /dev/null +++ b/private/mvdm/softpc.new/convert/convert.c @@ -0,0 +1,84 @@ + +/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Include files */ + +#include "windows.h" + +#include "stdio.h" +#include "stdlib.h" + +int convert(char *buffer, char *filename); + +/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */ + +_CRTAPI1 main(int argc, char *argv[]) +{ + char *buffer = malloc(1000*1024); + int index; + + /* Validate input parameters */ + if(argc < 2) + { + printf("Invalid usage : CONVERT <filenames>\n"); + return(1); + } + + for(index = 1; index < argc; index++) + convert(buffer, argv[index]); + + return(0); +} + + +/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Convert file */ + +int convert(char *buffer, char *filename) +{ + FILE *FH; + char *ptr; + int chr; + int last_chr = -1; + + + /*.............................................. Open file to convert */ + + if((FH = fopen(filename,"r+b")) == NULL) + { + printf("Failed to open file %s\n", filename); + return(1); + } + + /*........................................... Read in and convert file */ + + ptr = buffer; + while((chr = fgetc(FH)) != EOF) + { + switch(chr) + { + case 0xa : + if(last_chr == 0xd) break; + /* Fall throught and insert CR/LF in output buffer */ + + case 0xd : + *ptr++ = 0xd; + *ptr++ = 0xa; + break; + + default: + *ptr++ = chr; + break; + } + + last_chr = chr; + } + + /* Remove Control Z from end of file */ + if(*(ptr-1) == 0x1a) + *(ptr-1) = 0; + else + *ptr = 0; /* terminate output buffer */ + + /* Write out converted file */ + fseek(FH, 0, 0); /* Reset file pointer */ + fputs(buffer, FH); + fclose(FH); +} diff --git a/private/mvdm/softpc.new/convert/sources b/private/mvdm/softpc.new/convert/sources new file mode 100644 index 000000000..188c79578 --- /dev/null +++ b/private/mvdm/softpc.new/convert/sources @@ -0,0 +1,55 @@ +!IF 0 + +!IF $(ALPHA) +GPSIZE=0 +!ELSE +GPSIZE=32 +!ENDIF + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Steve Wood (stevewo) 12-Apr-1990 + +NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl + +!ENDIF + + +MAJORCOMP=spc +MINORCOMP=convert +TARGETNAME=convert +TARGETPATH=$(SOFTPC_ROOT)\convert\obj + + + +# Pick one of the following and delete the others +TARGETTYPE=PROGRAM + +TARGETLIBS= + +SOURCES=convert.c + +LINKLIBS= $(BASEDIR)\public\sdk\lib\*\setargv.obj + + +NTTEST= + +UMTYPE=console +UMTEST= +UMAPPL= +UMBASE=0x1000000 +UMLIBS= |