VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 2 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.5 KB
Line 
1/** $Id: VBoxReplaceDll.cpp 106061 2024-09-16 14:03:52Z 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-2024 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#include <VBox/version.h>
38
39
40static int usage(const char *argv0)
41{
42 char *psz1 = strrchr(argv0, '\\');
43 if (psz1)
44 argv0 = psz1 + 1;
45 psz1 = strrchr(argv0, '/');
46 if (psz1)
47 argv0 = psz1 + 1;
48 psz1 = strrchr(argv0, ':');
49 if (psz1)
50 argv0 = psz1 + 1;
51
52 printf("Usage: %s <dll1> [dll2 ...[dllN]]\n"
53 "\n"
54 "Tells the kernel to cache the specified DLLs in memory and close the\n"
55 "files on disk, allowing new DLL versions to be installed.\n"
56 "\n"
57 "Copyright (C) 2013-" VBOX_C_YEAR " Oracle Corporation\n",
58 argv0);
59 return 0;
60}
61
62int main(int argc, char **argv)
63{
64 int fOptions = 1;
65 int cProcessed = 0;
66 int i;
67 for (i = 1; i < argc; i++)
68 {
69 if ( fOptions
70 && argv[i][0] == '-')
71 {
72 if (!strcmp(argv[i], "--"))
73 fOptions = 0;
74 else if ( !strcmp(argv[i], "--help")
75 || !strcmp(argv[i], "-help")
76 || !strcmp(argv[i], "-h")
77 || !strcmp(argv[i], "-?") )
78 return usage(argv[0]);
79 else if ( !strcmp(argv[i], "--version")
80 || !strcmp(argv[i], "-V") )
81 {
82 printf("$Revision: 106061 $\n");
83 return 0;
84 }
85 else
86 {
87 fprintf(stderr, "syntax error: Invalid option '%s'!\n", argv[i]);
88 return 2;
89 }
90 }
91 else
92 {
93 /*
94 * Replace the specified DLL.
95 */
96 APIRET rc = DosReplaceModule((PCSZ)argv[i], NULL, NULL);
97 if (rc == NO_ERROR)
98 printf("info: Successfully cached '%s'.\n", argv[i]);
99 else
100 {
101 fprintf(stderr, "error: DosReplaceModule failed with rc=%lu on '%s'.\n", rc, argv[i]);
102 return 1;
103 }
104 cProcessed++;
105 }
106 }
107
108 if (cProcessed == 0)
109 {
110 fprintf(stderr, "syntax error: No DLLs specified. (Consult --help for usage.)\n");
111 return 1;
112 }
113
114 return 0;
115}
116
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette