VirtualBox

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

Last change on this file since 48431 was 46694, checked in by vboxsync, 11 years ago

header fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/** $Id: VBoxReplaceDll.cpp 46694 2013-06-19 20:13:38Z 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 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#define INCL_BASE
23#include <os2.h>
24#include <stdio.h>
25#include <string.h>
26
27
28static int usage(const char *argv0)
29{
30 char *psz1 = strrchr(argv0, '\\');
31 if (psz1)
32 argv0 = psz1 + 1;
33 psz1 = strrchr(argv0, '/');
34 if (psz1)
35 argv0 = psz1 + 1;
36 psz1 = strrchr(argv0, ':');
37 if (psz1)
38 argv0 = psz1 + 1;
39
40 printf("Usage: %s <dll1> [dll2 ...[dllN]]\n"
41 "\n"
42 "Tells the kernel to cache the specified DLLs in memory and close the\n"
43 "files on disk, allowing new DLL versions to be installed.\n"
44 "\n"
45 "Copyright (C) 2013 Oracle Corporation\n",
46 argv0);
47 return 0;
48}
49
50int main(int argc, char **argv)
51{
52 int fOptions = 1;
53 int cProcessed = 0;
54 int i;
55 for (i = 1; i < argc; i++)
56 {
57 if ( fOptions
58 && argv[i][0] == '-')
59 {
60 if (!strcmp(argv[i], "--"))
61 fOptions = 0;
62 else if ( !strcmp(argv[i], "--help")
63 || !strcmp(argv[i], "-help")
64 || !strcmp(argv[i], "-h")
65 || !strcmp(argv[i], "-?") )
66 return usage(argv[0]);
67 else if ( !strcmp(argv[i], "--version")
68 || !strcmp(argv[i], "-V") )
69 {
70 printf("$Revision: 46694 $\n");
71 return 0;
72 }
73 else
74 {
75 fprintf(stderr, "syntax error: Invalid option '%s'!\n", argv[i]);
76 return 2;
77 }
78 }
79 else
80 {
81 /*
82 * Replace the specified DLL.
83 */
84 APIRET rc = DosReplaceModule((PCSZ)argv[i], NULL, NULL);
85 if (rc == NO_ERROR)
86 printf("info: Successfully cached '%s'.\n", argv[i]);
87 else
88 {
89 fprintf(stderr, "error: DosReplaceModule failed with rc=%u on '%s'.\n", rc, argv[i]);
90 return 1;
91 }
92 cProcessed++;
93 }
94 }
95
96 if (cProcessed == 0)
97 {
98 fprintf(stderr, "syntax error: No DLLs specified. (Consult --help for usage.)\n");
99 return 1;
100 }
101
102 return 0;
103}
104
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