summaryrefslogtreecommitdiffstats
path: root/private/nw/install/setupdll/removesz.c
blob: 00757ae6f6a0f2855aee6fc22b0fc337a33ad69d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*++
Copyright (c) 1990  Microsoft Corporation

RemoveSzFromFile() - remove a specified string from the file

--*/

#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

#include <nwcfg.hxx>


BOOL
RemoveSzFromFile( DWORD nArgs, LPSTR apszArgs[], LPSTR * ppszResult )
{
    FILE * hsrcfile;
    FILE * hdesfile;
    char * pszTempname;
    char szInput[1000];

    pszTempname = tmpnam(NULL);
    wsprintf(achBuff,"{1}");
    *ppszResult = achBuff;
    if ( nArgs != 2 )
    {
        return(FALSE);
    }
    hsrcfile = fopen(apszArgs[0],"r");
    hdesfile = fopen(pszTempname,"w");
    if (( hsrcfile != NULL ) && ( hdesfile != NULL ))
    {
        while (fgets(szInput,1000,hsrcfile))
        {
            if (_stricmp(szInput,apszArgs[1])!=0)
            {
                fputs(szInput,hdesfile);
            }
        }
    }
    if ( hsrcfile != NULL )
        fclose(hsrcfile);
    if ( hdesfile != NULL )
        fclose(hdesfile);
    if (( hsrcfile != NULL ) && ( hdesfile != NULL ))
    {
        CopyFileA(pszTempname,apszArgs[0], FALSE);
        DeleteFileA(pszTempname);
    }

    wsprintf(achBuff,"{0}");
    *ppszResult = achBuff;
    return(TRUE);
}