VirtualBox

source: vbox/trunk/src/VBox/Additions/os2/VBoxReplaceDll.cpp@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/** $Id: VBoxReplaceDll.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBoxReplaceDll - helper for replacing a dll when it's in use by the system
4 */
5
6/*
7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define INCL_BASE
33#include <os2.h>
34#include <stdio.h>
35#include <string.h>
36
37
38static int usage(const char *argv0)
39{
40 char *psz1 = strrchr(argv0, '\\');
41 if (psz1)
42 argv0 = psz1 + 1;
43 psz1 = strrchr(argv0, '/');
44 if (psz1)
45 argv0 = psz1 + 1;
46 psz1 = strrchr(argv0, ':');
47 if (psz1)
48 argv0 = psz1 + 1;
49
50 printf("Usage: %s <dll1> [dll2 ...[dllN]]\n"
51 "\n"
52 "Tells the kernel to cache the specified DLLs in memory and close the\n"
53 "files on disk, allowing new DLL versions to be installed.\n"
54 "\n"
55 "Copyright (C) 2013-2020 Oracle Corporation\n",
56 argv0);
57 return 0;
58}
59
60int main(int argc, char **argv)
61{
62 int fOptions = 1;
63 int cProcessed = 0;
64 int i;
65 for (i = 1; i < argc; i++)
66 {
67 if ( fOptions
68 && argv[i][0] == '-')
69 {
70 if (!strcmp(argv[i], "--"))
71 fOptions = 0;
72 else if ( !strcmp(argv[i], "--help")
73 || !strcmp(argv[i], "-help")
74 || !strcmp(argv[i], "-h")
75 || !strcmp(argv[i], "-?") )
76 return usage(argv[0]);
77 else if ( !strcmp(argv[i], "--version")
78 || !strcmp(argv[i], "-V") )
79 {
80 printf("$Revision: 98103 $\n");
81 return 0;
82 }
83 else
84 {
85 fprintf(stderr, "syntax error: Invalid option '%s'!\n", argv[i]);
86 return 2;
87 }
88 }
89 else
90 {
91 /*
92 * Replace the specified DLL.
93 */
94 APIRET rc = DosReplaceModule((PCSZ)argv[i], NULL, NULL);
95 if (rc == NO_ERROR)
96 printf("info: Successfully cached '%s'.\n", argv[i]);
97 else
98 {
99 fprintf(stderr, "error: DosReplaceModule failed with rc=%lu on '%s'.\n", rc, argv[i]);
100 return 1;
101 }
102 cProcessed++;
103 }
104 }
105
106 if (cProcessed == 0)
107 {
108 fprintf(stderr, "syntax error: No DLLs specified. (Consult --help for usage.)\n");
109 return 1;
110 }
111
112 return 0;
113}
114
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use