コード例 #1
0
ファイル: vmtoolsLog.c プロジェクト: bzed/pkg-open-vm-tools
static void
VMToolsLogWrapper(GLogLevelFlags level,
                  const char *fmt,
                  va_list args)
{
   if (!gLogInitialized && !IS_FATAL(level)) {
      /*
       * Avoid logging without initialization because
       * it leads to spamming of the console output.
       * Fatal messages are exception.
       */
      return;
   }

   VMTools_AcquireLogStateLock();
   if (gLoggingStopped) {
      /* This is to avoid nested logging in vmxLogger */
      VMTools_ReleaseLogStateLock();
      return;
   }
   VMTools_ReleaseLogStateLock();

   if (gPanicCount == 0) {
      char *msg = Str_Vasprintf(NULL, fmt, args);
      if (msg != NULL) {
         g_log(gLogDomain, level, "%s", msg);
         free(msg);
      }
   } else {
      /* Try to avoid malloc() since we're aborting. */
      gchar msg[256];
      Str_Vsnprintf(msg, sizeof msg, fmt, args);
      VMToolsLog(gLogDomain, level, msg, gDefaultData);
   }
}
コード例 #2
0
Unicode
Unicode_Format(const char *fmt,	// IN: the format
	       ...)		// IN: the arguments
{
   va_list args;
   char *p;
   
   va_start(args, fmt);
   p = Str_Vasprintf(NULL, fmt, args);
   va_end(args);

   return p;
}
コード例 #3
0
ファイル: stub-log.c プロジェクト: SvenDowideit/open-vm-tools
void
LogV(uint32 unused,
     const char *fmt,
     va_list args)
{
   char *str;

   str = Str_Vasprintf(NULL, fmt, args);
   if (str != NULL) {
      fputs(str, stderr);
      free(str);
   }
}
コード例 #4
0
ファイル: stub-warning.c プロジェクト: bzed/pkg-open-vm-tools
void
Warning(const char *fmt, ...)
{
   char *str;
   va_list args;

   va_start(args, fmt);
   str = Str_Vasprintf(NULL, fmt, args);
   va_end(args);

   if (str != NULL) {
      fputs(str, stderr);
   }
}
コード例 #5
0
ファイル: str.c プロジェクト: raphaeldias/vmware
char *
Str_Asprintf(size_t *length,       // OUT
             const char *format,   // IN
             ...)                  // IN
{
   va_list arguments;
   char *result;

   va_start(arguments, format);
   result = Str_Vasprintf(length, format, arguments);
   va_end(arguments);

   return result;
}
コード例 #6
0
void
Panic(const char *fmt, ...) // IN
{
   va_list args;
   char *result;

   va_start(args, fmt);
   result = Str_Vasprintf(NULL, fmt, args);
   va_end(args);

   if (result) {
      printk(KERN_EMERG "%s", result);
   }

   BUG();

   while (1); // Avoid compiler warning.
}
コード例 #7
0
ファイル: vmtoolsLog.c プロジェクト: bzed/pkg-open-vm-tools
void
Panic(const char *fmt, ...)
{
   va_list args;

   va_start(args, fmt);

   if (gGuestSDKMode) {
      GuestSDK_Panic(fmt, args);
   } else {
      if (gPanicCount == 0) {
         char *msg = Str_Vasprintf(NULL, fmt, args);
         if (msg != NULL) {
            g_log(gLogDomain, G_LOG_LEVEL_ERROR, "%s", msg);
            free(msg);
         }
         /*
          * In case an user-installed custom handler doesn't panic on error,
          * force a core dump. Also force a dump in the recursive case.
          */
         VMToolsLogPanic();
      } else if (gPanicCount == 1) {
         /*
          * Use a stack allocated string since we're in a recursive panic, so
          * probably already in a weird state.
          */
         gchar msg[1024];
         Str_Vsnprintf(msg, sizeof msg, fmt, args);
         fprintf(stderr, "Recursive panic: %s\n", msg);
         VMToolsLogPanic();
      } else {
         fprintf(stderr, "Recursive panic, giving up.\n");
         exit(-1);
      }
   }
   va_end(args);
   while (1) ; // avoid compiler warning
}
コード例 #8
0
ファイル: rpcChannel.c プロジェクト: nf-mlo/open-vm-tools
gboolean
RpcChannel_SendOne(char **reply,
                   size_t *repLen,
                   char const *reqFmt,
                   ...)
{
   va_list args;
   gboolean status;
   char *request;
   size_t reqLen = 0;

   status = FALSE;

   /* Format the request string */
   va_start(args, reqFmt);
   request = Str_Vasprintf(&reqLen, reqFmt, args);
   va_end(args);

   /*
    * If Str_Vasprintf failed, write NULL into the reply if the caller wanted
    * a reply back.
    */
   if (request == NULL) {
      goto error;
   }

   /*
    * If the command doesn't contain a space, add one to the end to maintain
    * compatibility with old VMXs.
    *
    * For a long time, the GuestRpc logic in the VMX was wired to expect a
    * trailing space in every command, even commands without arguments. That is
    * no longer true, but we must continue to add a trailing space because we
    * don't know whether we're talking to an old or new VMX.
    */
   if (request[reqLen - 1] != ' ') {
      char *tmp;

      tmp = Str_Asprintf(NULL, "%s ", request);
      free(request);
      request = tmp;

      /*
       * If Str_Asprintf failed, write NULL into reply if the caller wanted
       * a reply back.
       */
      if (request == NULL) {
         goto error;
      }
   }

   status = RpcChannel_SendOneRaw(request, reqLen, reply, repLen);

   free(request);

   return status;

error:
   if (reply) {
      *reply = NULL;
   }

   if (repLen) {
      *repLen = 0;
   }
   return FALSE;
}
コード例 #9
0
ファイル: rpcout.c プロジェクト: nf-mlo/open-vm-tools
Bool
RpcOut_sendOne(char **reply,        // OUT: Result
               size_t *repLen,      // OUT: Length of the result
               char const *reqFmt,  // IN: RPCI command
               ...)                 // Unspecified
{
    va_list args;
    Bool status;
    char *request;
    size_t reqLen = 0;

    status = FALSE;

    /* Format the request string */
    va_start(args, reqFmt);
    request = Str_Vasprintf(&reqLen, reqFmt, args);
    va_end(args);

    /*
     * If Str_Vasprintf failed, write NULL into the reply if the caller wanted
     * a reply back.
     */
    if (request == NULL) {
        if (reply) {
            *reply = NULL;
        }
        return FALSE;
    }

    /*
     * If the command doesn't contain a space, add one to the end to maintain
     * compatibility with old VMXs.
     *
     * For a long time, the GuestRpc logic in the VMX was wired to expect a
     * trailing space in every command, even commands without arguments. That is
     * no longer true, but we must continue to add a trailing space because we
     * don't know whether we're talking to an old or new VMX.
     */
    if (strchr(request, ' ') == NULL) {
        char *tmp;

        tmp = Str_Asprintf(NULL, "%s ", request);
        free(request);
        request = tmp;

        /*
         * If Str_Asprintf failed, write NULL into reply if the caller wanted
         * a reply back.
         */
        if (request == NULL) {
            if (reply != NULL) {
                *reply = NULL;
            }
            return FALSE;
        }
    }

    status = RpcOut_SendOneRaw(request, reqLen, reply, repLen);

    free(request);

    return status;
}