VirtualBox

Changeset 44977 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Mar 11, 2013 11:36:51 AM (12 years ago)
Author:
vboxsync
Message:

VBoxGuestInst.cpp: coding style cleanup. ancient stuff...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/win/VBoxGuestInst.cpp

    r44528 r44977  
     1/* $Id$ */
    12/** @file
    2  *
    3  * Small tool to (un)install the VBoxGuest device driver
    4  *
     3 * Small tool to (un)install the VBoxGuest device driver.
     4 */
     5
     6/*
    57 * Copyright (C) 2006-2010 Oracle Corporation
    68 *
     
    3133
    3234
    33 int installDriver(void)
     35static int installDriver(void)
    3436{
    3537    /*
     
    5860                                       NULL, NULL, NULL, NULL);
    5961    if (!hService)
    60     {
    6162        printf("CreateService failed! lasterr=%d\n", GetLastError());
    62     } else
    63     {
     63    else
    6464        CloseServiceHandle(hService);
    65     }
    6665    CloseServiceHandle(hSMgrCreate);
    6766    return hService ? 0 : -1;
    6867}
    6968
    70 int uninstallDriver(void)
     69static int uninstallDriver(void)
    7170{
    7271    int rc = -1;
     
    9796}
    9897
     98#ifdef TESTMODE
    9999
    100 HANDLE openDriver(void)
     100static HANDLE openDriver(void)
    101101{
    102102    HANDLE hDevice;
     
    116116}
    117117
    118 int closeDriver(HANDLE hDevice)
     118static int closeDriver(HANDLE hDevice)
    119119{
    120120    CloseHandle(hDevice);
     
    122122}
    123123
    124 #ifdef TESTMODE
    125 typedef struct TESTFOO
    126 {
    127     int values[16];
    128 } TESTFOO, *PTESTFOO;
    129 
    130 int performTest(void)
     124static int performTest(void)
    131125{
    132126    int rc = 0;
     
    135129
    136130    if (hDevice != INVALID_HANDLE_VALUE)
    137     {
    138         DWORD cbReturned;
    139 
    140131        closeDriver(hDevice);
    141     } else
    142     {
     132    else
    143133        printf("openDriver failed!\n");
    144     }
    145 
    146134
    147135    return rc;
    148136}
    149 #endif
    150137
    151 void displayHelpAndExit(char *programName)
     138#endif /* TESTMODE */
     139
     140static int usage(char *programName)
    152141{
    153142    printf("error, syntax: %s [install|uninstall]\n", programName);
    154     exit(1);
     143    return 1;
    155144}
    156145
     
    163152
    164153    if (argc != 2)
    165     {
    166         displayHelpAndExit(argv[0]);
    167     }
     154        return usage(argv[0]);
     155
    168156    if (strcmp(argv[1], "install") == 0)
    169     {
    170157        installMode = true;
    171     } else
    172     if (strcmp(argv[1], "uninstall") == 0)
    173     {
     158    else if (strcmp(argv[1], "uninstall") == 0)
    174159        installMode = false;
    175     } else
    176160#ifdef TESTMODE
    177     if (strcmp(argv[1], "test") == 0)
    178     {
     161    else if (strcmp(argv[1], "test") == 0)
    179162        testMode = true;
    180     } else
    181163#endif
    182     {
    183         displayHelpAndExit(argv[0]);
    184     }
     164    else
     165        return usage(argv[0]);
     166
    185167
    186168    int rc;
    187 
    188169#ifdef TESTMODE
    189170    if (testMode)
    190     {
    191171        rc = performTest();
    192     } else
     172    else
    193173#endif
    194174    if (installMode)
    195     {
    196175        rc = installDriver();
    197     } else
    198     {
     176    else
    199177        rc = uninstallDriver();
    200     }
    201178
    202179    if (rc == 0)
    203     {
    204180        printf("operation completed successfully!\n");
    205     } else
    206     {
     181    else
    207182        printf("error: operation failed with status code %d\n", rc);
    208     }
    209183
    210184    return rc;
    211185}
     186
Note: See TracChangeset for help on using the changeset viewer.

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