~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.raring-precise.backport

« back to all changes in this revision

Viewing changes to libvmtools/stdLogger.c

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************
2
 
 * Copyright (C) 2010 VMware, Inc. All rights reserved.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify it
5
 
 * under the terms of the GNU Lesser General Public License as published
6
 
 * by the Free Software Foundation version 2.1 and no later version.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
11
 
 * License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program; if not, write to the Free Software Foundation, Inc.,
15
 
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
16
 
 *
17
 
 *********************************************************/
18
 
 
19
 
/**
20
 
 * @file stdLogger.c
21
 
 *
22
 
 * A very simplified version of a file logger that uses the standard output
23
 
 * streams (stdout / stderr).
24
 
 */
25
 
 
26
 
#include "vmtoolsInt.h"
27
 
#include <stdio.h>
28
 
 
29
 
#if defined(_WIN32)
30
 
static GStaticMutex gConsoleLock = G_STATIC_MUTEX_INIT;
31
 
static gint gRefCount = 0;
32
 
#endif
33
 
 
34
 
typedef struct StdLoggerData {
35
 
   LogHandlerData    handler;
36
 
#if defined(_WIN32)
37
 
   gboolean          attached;
38
 
#endif
39
 
} StdLoggerData;
40
 
 
41
 
 
42
 
/*
43
 
 ******************************************************************************
44
 
 * VMStdLoggerLog --                                                    */ /**
45
 
 *
46
 
 * Logs a message to stdout or stderr depending on its severity.
47
 
 *
48
 
 * @param[in] domain    Unused.
49
 
 * @param[in] level     Log level.
50
 
 * @param[in] message   Message to log.
51
 
 * @param[in] data      Logger data.
52
 
 * @param[in] errfn     Unused.
53
 
 *
54
 
 * @return TRUE.
55
 
 *
56
 
 ******************************************************************************
57
 
 */
58
 
 
59
 
static gboolean
60
 
VMStdLoggerLog(const gchar *domain,
61
 
               GLogLevelFlags level,
62
 
               const gchar *message,
63
 
               LogHandlerData *data,
64
 
               LogErrorFn errfn)
65
 
{
66
 
   FILE *dest = (level < G_LOG_LEVEL_MESSAGE) ? stderr : stdout;
67
 
 
68
 
#if defined(_WIN32)
69
 
   StdLoggerData *sdata = (StdLoggerData *) data;
70
 
 
71
 
   if (!sdata->attached) {
72
 
      g_static_mutex_lock(&gConsoleLock);
73
 
      if (gRefCount != 0 || VMTools_AttachConsole()) {
74
 
         gRefCount++;
75
 
         sdata->attached = TRUE;
76
 
      }
77
 
      g_static_mutex_unlock(&gConsoleLock);
78
 
   }
79
 
 
80
 
   if (!sdata->attached) {
81
 
      return FALSE;
82
 
   }
83
 
#endif
84
 
 
85
 
   fputs(message, dest);
86
 
   return TRUE;
87
 
}
88
 
 
89
 
 
90
 
/*
91
 
 *******************************************************************************
92
 
 * VMStdLoggerDestroy --                                                  */ /**
93
 
 *
94
 
 * Cleans up the internal state of the logger.
95
 
 *
96
 
 * @param[in] data   Logger data.
97
 
 *
98
 
 *******************************************************************************
99
 
 */
100
 
 
101
 
static void
102
 
VMStdLoggerDestroy(LogHandlerData *data)
103
 
{
104
 
#if defined(_WIN32)
105
 
   StdLoggerData *sdata = (StdLoggerData *) data;
106
 
   g_static_mutex_lock(&gConsoleLock);
107
 
   if (sdata->attached && --gRefCount == 0) {
108
 
      FreeConsole();
109
 
   }
110
 
   g_static_mutex_unlock(&gConsoleLock);
111
 
#endif
112
 
   g_free(data);
113
 
}
114
 
 
115
 
 
116
 
/*
117
 
 ******************************************************************************
118
 
 * VMStdLoggerConfig --                                                 */ /**
119
 
 *
120
 
 * Configures a new std logger.
121
 
 *
122
 
 * @param[in] defaultDomain   Unused.
123
 
 * @param[in] domain          Name of log domain.
124
 
 * @param[in] name            Name of log handler.
125
 
 * @param[in] cfg             Configuration data.
126
 
 *
127
 
 * @return The std logger data.
128
 
 *
129
 
 ******************************************************************************
130
 
 */
131
 
 
132
 
LogHandlerData *
133
 
VMStdLoggerConfig(const gchar *defaultDomain,
134
 
                  const gchar *domain,
135
 
                  const gchar *name,
136
 
                  GKeyFile *cfg)
137
 
{
138
 
   StdLoggerData *data = g_new0(StdLoggerData, 1);
139
 
   data->handler.logfn = VMStdLoggerLog;
140
 
   data->handler.convertToLocal = TRUE;
141
 
   data->handler.timestamp = TRUE;
142
 
   data->handler.shared = FALSE;
143
 
   data->handler.copyfn = NULL;
144
 
   data->handler.dtor = VMStdLoggerDestroy;
145
 
   return &data->handler;
146
 
}
147