Changeset 16500 in vbox
- Timestamp:
- Feb 4, 2009 10:02:29 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Main/cbinding/tstLinuxC.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/tstLinuxC.c
r16497 r16500 80 80 } 81 81 82 if(machineCnt)83 {84 printf("VM List:\n\n");85 86 /*87 * Iterate through the collection.88 */89 90 for (i = 0; i < machineCnt; ++i)91 {92 IMachine *machine = machines[i];93 PRBool isAccessible = PR_FALSE;94 95 printf("\tMachine #%u\n", (unsigned)i);96 97 if (!machine)98 {99 printf("\t(skipped, NULL)\n");100 continue;101 }102 103 machine->vtbl->GetAccessible(machine, &isAccessible);104 105 if (isAccessible)106 {107 PRUnichar *machineName_;108 char *machineName;109 110 machine->vtbl->GetName(machine, &machineName_);111 VBoxUtf16ToUtf8(machineName_,&machineName);112 printf("\tName: %s\n", machineName);113 114 VBoxUtf8Free(machineName);115 VBoxComUnallocMem(machineName_);116 }117 else118 {119 printf("\tName: <inaccessible>\n");120 }121 122 123 {124 nsID *iid = NULL;125 char *uuidString;126 127 machine->vtbl->GetId(machine, &iid);128 uuidString = nsIDToString(iid);129 printf("\tUUID: %s\n", uuidString);130 131 free(uuidString);132 VBoxComUnallocMem(iid);133 }134 135 if (isAccessible)136 {137 {138 PRUnichar *configFile;139 char *configFile1 = calloc((size_t)64, (size_t)1);140 141 machine->vtbl->GetSettingsFilePath(machine, &configFile);142 VBoxUtf16ToUtf8(configFile, &configFile1);143 printf("\tConfig file: %s\n", configFile1);144 145 free(configFile1);146 VBoxComUnallocMem(configFile);147 }148 149 {150 PRUint32 memorySize;151 152 machine->vtbl->GetMemorySize(machine, &memorySize);153 printf("\tMemory size: %uMB\n", memorySize);154 }155 156 {157 PRUnichar *typeId;158 PRUnichar *osName_;159 char *osName;160 IGuestOSType *osType = NULL;161 162 machine->vtbl->GetOSTypeId(machine, &typeId);163 virtualBox->vtbl->GetGuestOSType(virtualBox, typeId, &osType);164 osType->vtbl->GetDescription(osType, &osName_);165 VBoxUtf16ToUtf8(osName_,&osName);166 printf("\tGuest OS: %s\n\n", osName);167 168 osType->vtbl->nsisupports.Release((void *)osType);169 VBoxUtf8Free(osName);170 VBoxComUnallocMem(osName_);171 VBoxComUnallocMem(typeId);172 }173 }174 }175 176 /*177 * Let the user chose a machine to start.178 */179 180 printf("Type Machine# to start (0 - %u) or 'quit' to do nothing: ",181 (unsigned)(machineCnt - 1));182 fflush(stdout);183 184 if (scanf("%u", &start_id) == 1 && start_id < machineCnt)185 {186 IMachine *machine = machines[start_id];187 188 if (machine)189 {190 nsID *iid = NULL;191 192 machine->vtbl->GetId(machine, &iid);193 startVM(virtualBox, session, iid);194 195 VBoxComUnallocMem(iid);196 }197 }198 199 /*200 * Don't forget to release the objects in the array.201 */202 203 for (i = 0; i < machineCnt; ++i)204 {205 IMachine *machine = machines[i];206 207 if (machine)208 {209 machine->vtbl->nsisupports.Release((void *)machine);210 }211 }212 }213 else214 {215 printf("\tNo VMs\n");216 }82 if (machineCnt) 83 { 84 printf("VM List:\n\n"); 85 86 /* 87 * Iterate through the collection. 88 */ 89 90 for (i = 0; i < machineCnt; ++i) 91 { 92 IMachine *machine = machines[i]; 93 PRBool isAccessible = PR_FALSE; 94 95 printf("\tMachine #%u\n", (unsigned)i); 96 97 if (!machine) 98 { 99 printf("\t(skipped, NULL)\n"); 100 continue; 101 } 102 103 machine->vtbl->GetAccessible(machine, &isAccessible); 104 105 if (isAccessible) 106 { 107 PRUnichar *machineName_; 108 char *machineName; 109 110 machine->vtbl->GetName(machine, &machineName_); 111 VBoxUtf16ToUtf8(machineName_,&machineName); 112 printf("\tName: %s\n", machineName); 113 114 VBoxUtf8Free(machineName); 115 VBoxComUnallocMem(machineName_); 116 } 117 else 118 { 119 printf("\tName: <inaccessible>\n"); 120 } 121 122 123 { 124 nsID *iid = NULL; 125 char *uuidString; 126 127 machine->vtbl->GetId(machine, &iid); 128 uuidString = nsIDToString(iid); 129 printf("\tUUID: %s\n", uuidString); 130 131 free(uuidString); 132 VBoxComUnallocMem(iid); 133 } 134 135 if (isAccessible) 136 { 137 { 138 PRUnichar *configFile; 139 char *configFile1 = calloc((size_t)64, (size_t)1); 140 141 machine->vtbl->GetSettingsFilePath(machine, &configFile); 142 VBoxUtf16ToUtf8(configFile, &configFile1); 143 printf("\tConfig file: %s\n", configFile1); 144 145 free(configFile1); 146 VBoxComUnallocMem(configFile); 147 } 148 149 { 150 PRUint32 memorySize; 151 152 machine->vtbl->GetMemorySize(machine, &memorySize); 153 printf("\tMemory size: %uMB\n", memorySize); 154 } 155 156 { 157 PRUnichar *typeId; 158 PRUnichar *osName_; 159 char *osName; 160 IGuestOSType *osType = NULL; 161 162 machine->vtbl->GetOSTypeId(machine, &typeId); 163 virtualBox->vtbl->GetGuestOSType(virtualBox, typeId, &osType); 164 osType->vtbl->GetDescription(osType, &osName_); 165 VBoxUtf16ToUtf8(osName_,&osName); 166 printf("\tGuest OS: %s\n\n", osName); 167 168 osType->vtbl->nsisupports.Release((void *)osType); 169 VBoxUtf8Free(osName); 170 VBoxComUnallocMem(osName_); 171 VBoxComUnallocMem(typeId); 172 } 173 } 174 } 175 176 /* 177 * Let the user chose a machine to start. 178 */ 179 180 printf("Type Machine# to start (0 - %u) or 'quit' to do nothing: ", 181 (unsigned)(machineCnt - 1)); 182 fflush(stdout); 183 184 if (scanf("%u", &start_id) == 1 && start_id < machineCnt) 185 { 186 IMachine *machine = machines[start_id]; 187 188 if (machine) 189 { 190 nsID *iid = NULL; 191 192 machine->vtbl->GetId(machine, &iid); 193 startVM(virtualBox, session, iid); 194 195 VBoxComUnallocMem(iid); 196 } 197 } 198 199 /* 200 * Don't forget to release the objects in the array. 201 */ 202 203 for (i = 0; i < machineCnt; ++i) 204 { 205 IMachine *machine = machines[i]; 206 207 if (machine) 208 { 209 machine->vtbl->nsisupports.Release((void *)machine); 210 } 211 } 212 } 213 else 214 { 215 printf("\tNo VMs\n"); 216 } 217 217 } 218 218 … … 280 280 progress->vtbl->GetErrorInfo(progress, &errorInfo); 281 281 errorInfo->vtbl->GetText(errorInfo, &text_); 282 VBoxUtf16ToUtf8(text_, &text);282 VBoxUtf16ToUtf8(text_, &text); 283 283 printf("Error: %s\n", text); 284 284 285 VBoxComUnallocMem(text_);286 VBoxUtf8Free(text);285 VBoxComUnallocMem(text_); 286 VBoxUtf8Free(text); 287 287 } 288 288 else … … 356 356 if (NS_SUCCEEDED(rc)) 357 357 { 358 char *version = NULL;359 VBoxUtf16ToUtf8(version_, &version); 358 char *version = NULL; 359 VBoxUtf16ToUtf8(version_, &version); 360 360 printf("\tVersion: %s\n", version); 361 VBoxUtf8Free(version);361 VBoxUtf8Free(version); 362 362 } 363 363 else … … 373 373 if (NS_SUCCEEDED(rc)) 374 374 { 375 char *homefolder = NULL;376 VBoxUtf16ToUtf8(homefolder_, &homefolder);377 printf("\tHomeFolder: %s\n", homefolder);378 VBoxUtf8Free(homefolder);375 char *homefolder = NULL; 376 VBoxUtf16ToUtf8(homefolder_, &homefolder); 377 printf("\tHomeFolder: %s\n", homefolder); 378 VBoxUtf8Free(homefolder); 379 379 } 380 380 else … … 400 400 } 401 401 /* vim: set ts=4 sw=4 et: */ 402
Note:
See TracChangeset
for help on using the changeset viewer.

