VirtualBox

儲存庫 vbox 的更動 16487


忽略:
時間撮記:
2009-2-3 下午01:39:37 (16 年 以前)
作者:
vboxsync
訊息:

cbinding: No $Id$ keywords in samples, just $Revision$. The keyword string goes before the @file. The file start with one sentence outlining the purpose of the file, further explanation follows in a separate paragraph. Files use *one* brace and space-before-paranthesis style, esp. sample files. Do not exit() from main(), return from it. stuff -> _stuff since the double underscore namespace is reserved the system/compiler/libc. Finally, why unconditional logging and why doing it using cout/cerr?

位置:
trunk/src/VBox/Main/cbinding
檔案:
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/cbinding/cbinding.h

    • 屬性 svn:keywordsId 變更至 Author Date Id Revision
    r16483 r16487  
     1/* $Revision$ */
    12/** @file cbinding.h
    2  *
    33 * C binding for XPCOM.
    4  *
    5  * $Id$
    64 */
    75
    8 #ifndef __cbinding_h__
    9 #define __cbinding_h__
     6#ifndef ___cbinding_h
     7#define ___cbinding_h
    108
    119/*
     
    5856#endif
    5957
    60 #endif /* __cbinding_h__ */
     58#endif /* !___cbinding_h */
     59
  • trunk/src/VBox/Main/cbinding/libXPCOMtoC.cpp

    • 屬性 svn:keywordsId 變更至 Author Date Id Revision
    r16483 r16487  
     1/* $Id$ */
    12/** @file libXPCOMtoC.cpp
    2  *
    33 * Utility functions to use with the C binding for XPCOM.
    4  *
    5  * $Id$
    64 */
    75
     
    8482void VBoxComUnallocStr(PRUnichar *str_dealloc)
    8583{
    86     if (str_dealloc) {
     84    if (str_dealloc)
     85    {
    8786        nsMemory::Free(str_dealloc);
    8887    }
     
    9190void VBoxComUnallocIID(nsIID *iid)
    9291{
    93     if (iid) {
     92    if (iid)
     93    {
    9494        nsMemory::Free(iid);
    9595    }
     
    105105    Session     = *session;
    106106    Ivirtualbox = *virtualBox;
     107
     108/** @todo r=bird: Why is cout/cerr used unconditionally here?
     109 * It would be preferred to use RTPrintf/RTStrmPrintf(g_pStdErr,..). If this is
     110 * going to be used in real life, the cout(/RTPrintf) bits should be optional,
     111 * add a flag argument and define VBOXCOMINIT_FLAG_VERBOSE for the purpose. */
    107112
    108113    // All numbers on stderr in hex prefixed with 0X.
  • trunk/src/VBox/Main/cbinding/makefile.tstLinuxC

    • 屬性 svn:keywords 設為 Author Date Id Revision
    r16483 r16487  
    1 # $Id: Makefile 42209 2009-01-29 12:22:10Z jens $
     1# $Revision$
     2## @file makefile.tstLinuxC
     3# Makefile for sample program illustrating use of C binding for XPCOM.
    24#
    3 ## @file makefile.tstLinuxC
    4 #
    5 # Makefile for sample program illustrating use of C binding for XPCOM.
    65
    76#
     
    5049        echo "env VBOX_XPCOM_HOME=$(PATH_BIN) LD_LIBRARY_PATH=$(PATH_BIN) ./tstLinuxC" > $@
    5150        chmod a+x $@
     51
  • trunk/src/VBox/Main/cbinding/tstLinuxC.c

    • 屬性 svn:keywordsId 變更至 Author Date Id Revision
    r16483 r16487  
     1/* $Revsion: $ */
    12/** @file tstLinuxC.c
    2  *
    33 * Demonstrator program to illustrate use of C bindings of Main API.
     4 *
    45 * Linux only at the moment due to shared library magic in the Makefile.
    5  *
    6  * $Id$
    76 */
    87
     
    2625#include <string.h>
    2726#include <stdlib.h>
    28 #include <iconv.h>
    2927#include "cbinding.h"
    3028
     
    7775    if (NS_FAILED(rc))
    7876    {
    79         fprintf (stderr, "could not get list of machines, rc=%08x\n",
     77        fprintf(stderr, "could not get list of machines, rc=%08x\n",
    8078            (unsigned)rc);
    8179        return;
     
    9593        printf("\tMachine #%u\n", (unsigned)i);
    9694
    97         if (!machine) {
     95        if (!machine)
     96        {
    9897            printf("\t(skipped, NULL)\n");
    9998            continue;
    10099        }
    101100
    102         machine->vtbl->GetAccessible (machine, &isAccessible);
     101        machine->vtbl->GetAccessible(machine, &isAccessible);
    103102
    104103        if (isAccessible)
     
    118117
    119118        {
    120             nsID  *iid          = nsnull;
     119            nsID  *iid = NULL;
    121120            char  *uuidString;
    122121
     
    153152                PRUnichar *typeId;
    154153                PRUnichar *osName;
    155                 IGuestOSType *osType = nsnull;
     154                IGuestOSType *osType = NULL;
    156155
    157156                machine->vtbl->GetOSTypeId(machine, &typeId);
     
    171170     */
    172171
    173     printf ("Type Machine# to start (0 - %u) or 'quit' to do nothing: ",
     172    printf("Type Machine# to start (0 - %u) or 'quit' to do nothing: ",
    174173        (unsigned)(machineCnt - 1));
    175     fflush (stdout);
    176 
    177     if (scanf ("%u", &start_id) == 1 && start_id < machineCnt) {
     174    fflush(stdout);
     175
     176    if (scanf("%u", &start_id) == 1 && start_id < machineCnt)
     177    {
    178178        IMachine *machine = machines[start_id];
    179179
    180         if (machine) {
    181             nsID  *iid = nsnull;
     180        if (machine)
     181        {
     182            nsID  *iid = NULL;
    182183
    183184            machine->vtbl->GetId(machine, &iid);
     
    192193     */
    193194
    194     for (i = 0; i < machineCnt; ++i) {
     195    for (i = 0; i < machineCnt; ++i)
     196    {
    195197        IMachine *machine = machines[i];
    196198
    197         if (machine) {
     199        if (machine)
     200        {
    198201            machine->vtbl->nsisupports.Release((void *)machine);
    199202        }
     
    220223    if (NS_FAILED(rc) || !machine)
    221224    {
    222         fprintf (stderr, "Error: Couldn't get the machine handle.\n");
     225        fprintf(stderr, "Error: Couldn't get the machine handle.\n");
    223226        return;
    224227    }
     
    237240    VBoxUtf16Free(sessionType);
    238241
    239     if (NS_FAILED (rc))
    240     {
    241         fprintf (stderr, "Error: OpenRemoteSession failed.\n");
     242    if (NS_FAILED(rc))
     243    {
     244        fprintf(stderr, "Error: OpenRemoteSession failed.\n");
    242245    }
    243246    else
     
    250253
    251254        rc = progress->vtbl->GetCompleted(progress, &completed);
    252         if (NS_FAILED (rc))
     255        if (NS_FAILED(rc))
    253256        {
    254257            fprintf (stderr, "Error: GetCompleted status failed.\n");
     
    263266            progress->vtbl->GetErrorInfo(progress, &errorInfo);
    264267            errorInfo->vtbl->GetText(errorInfo, &text);
    265             printf ("[!] Text        = %s\n", VBoxConvertPRUnichartoAscii (text));
     268            printf("[!] Text        = %s\n", VBoxConvertPRUnichartoAscii (text));
    266269        }
    267270        else
    268271        {
    269             fprintf (stderr, "Remote session has been successfully opened.\n");
     272            fprintf(stderr, "Remote session has been successfully opened.\n");
    270273        }
    271274        progress->vtbl->nsisupports.Release((void *)progress);
     
    288291
    289292    printf("Starting Main\n");
     293
    290294    /*
    291295     * VBoxComInitialize does all the necessary startup action and
     
    294298     * when done.
    295299     */
     300
    296301    VBoxComInitialize(&vbox, &session);
    297302
    298     if (vbox == NULL) {
    299         fprintf (stderr, "%s: FATAL: could not get vbox handle\n", argv[0]);
    300         exit (EXIT_FAILURE);
    301     }
    302     if (session == NULL) {
     303    if (vbox == NULL)
     304    {
     305        fprintf(stderr, "%s: FATAL: could not get vbox handle\n", argv[0]);
     306        return EXIT_FAILURE;
     307    }
     308    if (session == NULL)
     309    {
    303310        fprintf (stderr, "%s: FATAL: could not get session handle\n", argv[0]);
    304         exit (EXIT_FAILURE);
     311        return EXIT_FAILURE;
    305312    }
    306313
     
    310317     * remains easy to see how we access C++'s vtable.
    311318     */
     319
    312320    printf("----------------------------------------------------\n");
    313321
     
    361369     * Do as mom told us: always clean up after yourself.
    362370     */
     371
    363372    VBoxComUninitialize();
    364373    printf("Finished Main\n");
     
    367376}
    368377/* vim: set ts=4 sw=4 et: */
     378
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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