Changeset 61065 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- May 19, 2016 11:15:31 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp
r61062 r61065 83 83 } VBOXSERVICETOOLBOXOUTPUTFLAG; 84 84 85 85 86 /********************************************************************************************************************************* 86 87 * Prototypes * … … 93 94 static RTEXITCODE vgsvcToolboxStat(int argc, char **argv); 94 95 96 95 97 /********************************************************************************************************************************* 96 98 * Structures and Typedefs * … … 106 108 /** Main handler to be invoked to use the tool. */ 107 109 RTEXITCODE (*pfnHandler)(int argc, char **argv); 108 /** Conversion routine to convert the tool's exit code back to an IPRT rc. Optional. */ 110 /** Conversion routine to convert the tool's exit code back to an IPRT rc. Optional. 111 * 112 * @todo r=bird: You better revert this, i.e. having pfnHandler return a VBox 113 * status code and have a routine for converting it to RTEXITCODE. 114 * Unless, what you really want to do here is to get a cached status, in 115 * which case you better call it what it is. 116 */ 109 117 int (*pfnExitCodeConvertToRc)(RTEXITCODE rcExit); 110 } VBOXSERVICETOOLBOXTOOL, *PVBOXSERVICETOOLBOXTOOL; 111 112 static VBOXSERVICETOOLBOXTOOL s_aTools[] = 118 } VBOXSERVICETOOLBOXTOOL; 119 /** Pointer to a const tool definition. */ 120 typedef VBOXSERVICETOOLBOXTOOL const *PCVBOXSERVICETOOLBOXTOOL; 121 122 /** 123 * An file/directory entry. Used to cache 124 * file names/paths for later processing. 125 */ 126 typedef struct VBOXSERVICETOOLBOXPATHENTRY 127 { 128 /** Our node. */ 129 RTLISTNODE Node; 130 /** Name of the entry. */ 131 char *pszName; 132 } VBOXSERVICETOOLBOXPATHENTRY, *PVBOXSERVICETOOLBOXPATHENTRY; 133 134 typedef struct VBOXSERVICETOOLBOXDIRENTRY 135 { 136 /** Our node. */ 137 RTLISTNODE Node; 138 /** The actual entry. */ 139 RTDIRENTRYEX dirEntry; 140 } VBOXSERVICETOOLBOXDIRENTRY, *PVBOXSERVICETOOLBOXDIRENTRY; 141 142 143 /********************************************************************************************************************************* 144 * Global Variables * 145 *********************************************************************************************************************************/ 146 /** Tool definitions. */ 147 static VBOXSERVICETOOLBOXTOOL const g_aTools[] = 113 148 { 114 149 { VBOXSERVICE_TOOL_CAT, vgsvcToolboxCat , NULL }, … … 119 154 { VBOXSERVICE_TOOL_STAT, vgsvcToolboxStat , NULL } 120 155 }; 121 122 /**123 * An file/directory entry. Used to cache124 * file names/paths for later processing.125 */126 typedef struct VBOXSERVICETOOLBOXPATHENTRY127 {128 /** Our node. */129 RTLISTNODE Node;130 /** Name of the entry. */131 char *pszName;132 } VBOXSERVICETOOLBOXPATHENTRY, *PVBOXSERVICETOOLBOXPATHENTRY;133 134 typedef struct VBOXSERVICETOOLBOXDIRENTRY135 {136 /** Our node. */137 RTLISTNODE Node;138 /** The actual entry. */139 RTDIRENTRYEX dirEntry;140 } VBOXSERVICETOOLBOXDIRENTRY, *PVBOXSERVICETOOLBOXDIRENTRY;141 142 143 156 144 157 … … 1527 1540 * @param pszTool The name of the tool. 1528 1541 */ 1529 static P VBOXSERVICETOOLBOXTOOLvgsvcToolboxLookUp(const char *pszTool)1542 static PCVBOXSERVICETOOLBOXTOOL const vgsvcToolboxLookUp(const char *pszTool) 1530 1543 { 1531 1544 AssertPtrReturn(pszTool, NULL); 1532 1545 1533 1546 /* Do a linear search, since we don't have that much stuff in the table. */ 1534 for (unsigned i = 0; i < RT_ELEMENTS( s_aTools); i++)1535 if (!strcmp( s_aTools[i].pszName, pszTool))1536 return & s_aTools[i];1547 for (unsigned i = 0; i < RT_ELEMENTS(g_aTools); i++) 1548 if (!strcmp(g_aTools[i].pszName, pszTool)) 1549 return &g_aTools[i]; 1537 1550 1538 1551 return NULL; … … 1551 1564 AssertPtrReturn(pszTool, VERR_INVALID_POINTER); 1552 1565 1553 P VBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool);1566 PCVBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool); 1554 1567 if (pTool) 1555 1568 return pTool->pfnExitCodeConvertToRc(rcExit); … … 1577 1590 AssertReturn(argc > 0, false); 1578 1591 const char *pszTool = RTPathFilename(argv[0]); 1579 P VBOXSERVICETOOLBOXTOOLpTool = vgsvcToolboxLookUp(pszTool);1592 PCVBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool); 1580 1593 if (!pTool) 1581 1594 { … … 1598 1611 return true; 1599 1612 } 1600 if ( (strcmp(pszTool, "help")) && (strcmp(pszTool, "--help")) 1601 && (strcmp(pszTool, "-h"))) 1613 if ( strcmp(pszTool, "help") 1614 && strcmp(pszTool, "--help") 1615 && strcmp(pszTool, "-h")) 1602 1616 *prcExit = RTEXITCODE_SYNTAX; 1603 1617 vgsvcToolboxShowUsage();
Note:
See TracChangeset
for help on using the changeset viewer.