~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-10-17 23:23:09 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20111017232309-kzm6841lzk61ranj
Tags: 4.1.4-dfsg-1
* New upstream release.
  - Fixes missing icons when using pt_BR locale. (Closes: #507188)
  - Fixes guest additions download url. (Closes: #637349; LP: #840668)
* Refresh patches.
* Drop the vboxmouse x11 driver. The mouse integration is now completely
  handled by the kernel module.
* Restrict dh_pycentral to the virtualbox binary package.
* Merge changes from the Ubuntu package but use them only when built
  on Ubuntu:
  - Add an Apport hook.
  - Add vboxguest modalias to the package control field.
* Pass KBUILD_VERBOSE=2 to kmk.
* Add 36-fix-text-mode.patch to fix text mode when using the vboxvideo driver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: VBoxServiceToolBox.cpp 38015 2011-07-18 12:49:31Z vboxsync $ */
 
1
/* $Id: VBoxServiceToolBox.cpp $ */
2
2
/** @file
3
3
 * VBoxServiceToolbox - Internal (BusyBox-like) toolbox.
4
4
 */
607
607
    int rc = RTPathAbs(pszDir, szPathAbs, sizeof(szPathAbs));
608
608
    if (RT_FAILURE(rc))
609
609
    {
610
 
        RTMsgError("Failed to retrieve absolute path of '%s', rc=%Rrc\n", pszDir, rc);
 
610
        if (!(uOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE))
 
611
            RTMsgError("Failed to retrieve absolute path of '%s', rc=%Rrc\n", pszDir, rc);
611
612
        return rc;
612
613
    }
613
614
 
615
616
    rc = RTDirOpen(&pDir, szPathAbs);
616
617
    if (RT_FAILURE(rc))
617
618
    {
618
 
        RTMsgError("Failed to open directory '%s', rc=%Rrc\n", szPathAbs, rc);
 
619
        if (!(uOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE))
 
620
            RTMsgError("Failed to open directory '%s', rc=%Rrc\n", szPathAbs, rc);
619
621
        return rc;
620
622
    }
621
623
 
649
651
    int rc2 = RTDirClose(pDir);
650
652
    if (RT_FAILURE(rc2))
651
653
    {
652
 
        RTMsgError("Failed to close dir '%s', rc=%Rrc\n",
653
 
                   pszDir, rc2);
 
654
        if (!(uOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE))
 
655
            RTMsgError("Failed to close dir '%s', rc=%Rrc\n",
 
656
                       pszDir, rc2);
654
657
        if (RT_SUCCESS(rc))
655
658
            rc = rc2;
656
659
    }
837
840
                                            RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK /* @todo Follow link? */);
838
841
                if (RT_FAILURE(rc2))
839
842
                {
840
 
                    RTMsgError("Cannot access '%s': No such file or directory\n",
841
 
                               pNodeIt->pszName);
 
843
                    if (!(fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE))
 
844
                        RTMsgError("Cannot access '%s': No such file or directory\n",
 
845
                                   pNodeIt->pszName);
842
846
                    rc = VERR_FILE_NOT_FOUND;
843
847
                    /* Do not break here -- process every element in the list
844
848
                     * and keep failing rc. */
1069
1073
                                        RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK /* @todo Follow link? */);
1070
1074
            if (RT_FAILURE(rc2))
1071
1075
            {
1072
 
                RTMsgError("Cannot stat for '%s': No such file or directory\n",
1073
 
                           pNodeIt->pszName);
 
1076
                if (!(fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE))
 
1077
                    RTMsgError("Cannot stat for '%s': No such file or directory\n",
 
1078
                               pNodeIt->pszName);
1074
1079
                rc = VERR_FILE_NOT_FOUND;
1075
1080
                /* Do not break here -- process every element in the list
1076
1081
                 * and keep failing rc. */
1179
1184
    }
1180
1185
 
1181
1186
    /*
 
1187
     * The input is ASSUMED to be in the current process codeset (NT guarantees
 
1188
     * ACP, unixy systems doesn't guarantee anything).  This loop converts all
 
1189
     * the argv[*] strings to UTF-8, which is a tad ugly but who cares.
 
1190
     * (As a rule all strings in VirtualBox are UTF-8.)
 
1191
     */
 
1192
    for (int i = 0; i < argc; i++)
 
1193
    {
 
1194
        char *pszConverted;
 
1195
        int rc = RTStrCurrentCPToUtf8(&pszConverted, argv[i]);
 
1196
        if (RT_SUCCESS(rc))
 
1197
            argv[i] = pszConverted;
 
1198
        else
 
1199
        {
 
1200
            RTMsgError("Failed to convert argument %d to UTF-8, rc=%Rrc\n",
 
1201
                       i + 1, rc);
 
1202
 
 
1203
            /* Conversion was not possible,probably due to invalid characters.
 
1204
             * Keep in mind that we do RTStrFree on the whole array below. */
 
1205
            argv[i] = RTStrDup(argv[i]);
 
1206
        }
 
1207
    }
 
1208
 
 
1209
    /*
1182
1210
     * Invoke the handler.
1183
1211
     */
1184
1212
    RTMsgSetProgName("VBoxService/%s", pszTool);
1185
1213
    *prcExit = pfnHandler(argc, argv);
 
1214
 
 
1215
    /*
 
1216
     * Free converted argument vector
 
1217
     */
 
1218
    for (int i = 0; i < argc; i++)
 
1219
    {
 
1220
        RTStrFree(argv[i]);
 
1221
        argv[i] = NULL;
 
1222
    }
1186
1223
    return true;
1187
1224
 
1188
1225
}