~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools-august.merge

« back to all changes in this revision

Viewing changes to lib/include/posix.h

  • Committer: Bazaar Package Importer
  • Author(s): Nate Muench
  • Date: 2011-07-22 16:41:03 UTC
  • mfrom: (1.4.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110722164103-xci04yu18mjvhr1j
Tags: 2011.07.19-450511-0ubuntu1
* Merge latest upstream git tag. Fixes Building on Oneiric
  (LP: #776103, LP: #807903)

* The Toolbox (GUI) has been removed.
* Changes in debian folder:
  - Contents of open-vm-toolbox.lintian-overrides have been moved to
    open-vm-tools.lintian-overrides.
  - The contents of open-vm-toolbox.manpages (excluding the first line,
    which relates to the Toolbox) have been moved to open-vm-tools.manpages.
* Changes in debian/control:
  - Convert open-vm-toolbox into a transitional package.
  - All dependencies for toolbox have been moved to open-vm-tools package.
  - Changed architecture for open-vm-toolbox package to all.
  - Added Replaces and Breaks fields to open-vm-tools.
* Changes in debian/rules:
  - Commented out references to the Toolbox (GUI), that no longer exist
    in the package itself.
  - Remaining references changed from open-vm-toolbox to open-vm-tools.
  - Added -Wno-unused-but-set-variable to CFLAGS to suppress remaining
    issues with GCC 4.6.0 or later.
* Files removed in debian/manpages:
  - vmmemctl.9 (Component no longer in package)
  - vmware-toolbox.1 (Component removed in this release)
  - vmxnet3.9 (vmxnet3 is now included in kernel itself)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 * leading to a (potentially undetected) mismatch.
44
44
 */
45
45
 
46
 
#if defined(linux) && !defined(N_PLAT_NLM) && \
 
46
#if defined(linux) && \
47
47
    (!defined(_LARGEFILE64_SOURCE) || _FILE_OFFSET_BITS != 64)
48
48
#error LFS support is not enabled!
49
49
#endif
81
81
int Posix_Printf(ConstUnicode format, ...);
82
82
int Posix_Fprintf(FILE *stream, ConstUnicode format, ...);
83
83
 
84
 
#if !defined(N_PLAT_NLM)
85
84
int Posix_Mkdir(ConstUnicode pathName, mode_t mode);
86
85
int Posix_Chdir(ConstUnicode pathName);
87
86
Unicode Posix_Getenv(ConstUnicode name);
88
87
long Posix_Pathconf(ConstUnicode pathName, int name);
89
88
int Posix_Lstat(ConstUnicode pathName, struct stat *statbuf);
90
 
#endif
91
89
 
92
90
#if !defined(_WIN32)
93
91
/*
99
97
#define Posix_GetHostByName gethostbyname
100
98
#endif
101
99
#define Posix_GetAddrInfo getaddrinfo
 
100
#define Posix_FreeAddrInfo freeaddrinfo
102
101
#define Posix_GetNameInfo getnameinfo
103
102
 
104
103
void *Posix_Dlopen(ConstUnicode pathName, int flags);
105
104
 
106
105
int Posix_Utime(ConstUnicode pathName, const struct utimbuf *times);
107
106
 
108
 
#if !defined(N_PLAT_NLM)
109
107
int Posix_Mknod(ConstUnicode pathName, mode_t mode, dev_t dev);
110
108
int Posix_Chown(ConstUnicode pathName, uid_t owner, gid_t group);
111
109
int Posix_Lchown(ConstUnicode pathName, uid_t owner, gid_t group);
169
167
int Posix_Getmntent(FILE *fp, struct mnttab *mp);
170
168
 
171
169
#endif // !defined(sun)
172
 
#endif // !defined(N_PLAT_NLM)
173
170
#if !defined(__APPLE__)
174
171
 
175
172
 
428
425
#ifdef _WS2TCPIP_H_
429
426
typedef int (WINAPI *GetAddrInfoWFnType)(PCWSTR pNodeName, PCWSTR pServiceName,
430
427
                                         const struct addrinfo *pHints,
431
 
                                         struct addrinfo **ppResult);
 
428
                                         struct addrinfoW **ppResult);
 
429
typedef void (WINAPI *FreeAddrInfoWFnType)(struct addrinfoW *ai);
432
430
typedef int (WINAPI *GetNameInfoWFnType)(const SOCKADDR *pSockaddr,
433
431
                                         socklen_t SockAddrLength,
434
432
                                         PWCHAR pNodeBuffer,
461
459
                  const struct addrinfo *hints, // IN
462
460
                  struct addrinfo **res)        // OUT
463
461
{
464
 
   HMODULE hWs2_32;
 
462
   HMODULE hWs2_32 = GetModuleHandleW(L"ws2_32");
 
463
   GetAddrInfoWFnType GetAddrInfoWFn = NULL;
 
464
   FreeAddrInfoWFnType FreeAddrInfoWFn = NULL;
465
465
   int retval;
466
466
   char *nodenameMBCS;
467
467
   char *servnameMBCS;
468
 
   GetAddrInfoWFnType GetAddrInfoWFn;
 
468
   struct addrinfo *resA;
469
469
 
470
470
   ASSERT(nodename || servname);
471
471
   ASSERT(res);
472
 
 
473
 
   hWs2_32 = LoadLibraryW(L"ws2_32");
 
472
   ASSERT(hWs2_32);
474
473
 
475
474
   if (hWs2_32) {
476
 
      /*
477
 
       * If the unicode version of getaddrinfo exists, use it.  The string
478
 
       * conversion required is between UTF-8 and UTF-16 encodings.  Note
479
 
       * that struct addrinfo and ADDRINFOW are identical except for the
480
 
       * fields ai_canonname (char * vs. PWSTR) and ai_next (obviously).
481
 
       */
482
 
 
483
475
      GetAddrInfoWFn = (GetAddrInfoWFnType)GetProcAddress(hWs2_32,
484
476
                                                          "GetAddrInfoW");
485
 
 
486
 
      if (GetAddrInfoWFn) {
487
 
         utf16_t *nodenameW = Unicode_GetAllocUTF16(nodename);
488
 
         utf16_t *servnameW = Unicode_GetAllocUTF16(servname);
489
 
 
490
 
         retval = (*GetAddrInfoWFn)(nodenameW, servnameW, hints, res);
491
 
 
492
 
         if (retval == 0) {
493
 
            struct addrinfo *cur;
494
 
            utf16_t *tempW;
495
 
 
496
 
            for (cur = *res; cur != NULL; cur = cur->ai_next) {
497
 
               if (cur->ai_canonname) {
498
 
                  tempW = (utf16_t *)cur->ai_canonname;
499
 
                  cur->ai_canonname = Unicode_AllocWithUTF16(tempW);
500
 
                  free(tempW);
501
 
               }
 
477
      FreeAddrInfoWFn = (FreeAddrInfoWFnType)GetProcAddress(hWs2_32,
 
478
                                                            "FreeAddrInfoW");
 
479
   }
 
480
 
 
481
   /*
 
482
    * If the unicode version of getaddrinfo exists, use it.  The string
 
483
    * conversion required is between UTF-8 and UTF-16 encodings.  Note
 
484
    * that struct addrinfo and ADDRINFOW are identical except for the
 
485
    * fields ai_canonname (char * vs. PWSTR) and ai_next (obviously).
 
486
    */
 
487
 
 
488
   if (GetAddrInfoWFn && FreeAddrInfoWFn) {
 
489
      utf16_t *nodenameW = Unicode_GetAllocUTF16(nodename);
 
490
      utf16_t *servnameW = Unicode_GetAllocUTF16(servname);
 
491
      struct addrinfoW *resW;
 
492
 
 
493
      retval = (*GetAddrInfoWFn)(nodenameW, servnameW, hints, &resW);
 
494
 
 
495
      if (retval == 0) {
 
496
         struct addrinfoW *cur;
 
497
         struct addrinfo **pres = res;
 
498
 
 
499
         for (cur = resW; cur != NULL; cur = cur->ai_next) {
 
500
            *pres = (struct addrinfo *)Util_SafeMalloc(sizeof **pres);
 
501
            (*pres)->ai_flags = cur->ai_flags;
 
502
            (*pres)->ai_family = cur->ai_family;
 
503
            (*pres)->ai_socktype = cur->ai_socktype;
 
504
            (*pres)->ai_protocol = cur->ai_protocol;
 
505
            (*pres)->ai_addrlen = cur->ai_addrlen;
 
506
            if (cur->ai_canonname) {
 
507
               (*pres)->ai_canonname = Unicode_AllocWithUTF16(cur->ai_canonname);
 
508
            } else {
 
509
               (*pres)->ai_canonname = NULL;
502
510
            }
 
511
            (*pres)->ai_addr = (struct sockaddr *)
 
512
                               Util_SafeMalloc((*pres)->ai_addrlen);
 
513
            memcpy((*pres)->ai_addr, cur->ai_addr, (*pres)->ai_addrlen);
 
514
            pres = &((*pres)->ai_next);
503
515
         }
504
 
 
505
 
         free(nodenameW);
506
 
         free(servnameW);
507
 
 
508
 
         goto exit;
 
516
         *pres = NULL;
 
517
         FreeAddrInfoWFn(resW);
509
518
      }
 
519
 
 
520
      free(nodenameW);
 
521
      free(servnameW);
 
522
 
 
523
      goto exit;
510
524
   }
511
525
 
512
526
   /*
519
533
   servnameMBCS = (char *)Unicode_GetAllocBytes(servname,
520
534
                                                STRING_ENCODING_DEFAULT);
521
535
 
522
 
   retval = getaddrinfo(nodenameMBCS, servnameMBCS, hints, res);
 
536
   retval = getaddrinfo(nodenameMBCS, servnameMBCS, hints, &resA);
523
537
 
524
538
   if (retval == 0) {
 
539
      struct addrinfo **pres = res;
525
540
      struct addrinfo *cur;
526
 
      char *temp;
527
541
 
528
 
      for (cur = *res; cur != NULL; cur = cur->ai_next) {
 
542
      for (cur = resA; cur != NULL; cur = cur->ai_next) {
 
543
         *pres = (struct addrinfo *)Util_SafeMalloc(sizeof **pres);
 
544
         (*pres)->ai_flags = cur->ai_flags;
 
545
         (*pres)->ai_family = cur->ai_family;
 
546
         (*pres)->ai_socktype = cur->ai_socktype;
 
547
         (*pres)->ai_protocol = cur->ai_protocol;
 
548
         (*pres)->ai_addrlen = cur->ai_addrlen;
529
549
         if (cur->ai_canonname) {
530
 
            temp = cur->ai_canonname;
531
 
            cur->ai_canonname = Unicode_Alloc(temp, STRING_ENCODING_DEFAULT);
532
 
            free(temp);
 
550
            (*pres)->ai_canonname = Unicode_Alloc(cur->ai_canonname,
 
551
                                                  STRING_ENCODING_DEFAULT);
 
552
         } else {
 
553
            (*pres)->ai_canonname = NULL;
533
554
         }
 
555
         (*pres)->ai_addr = (struct sockaddr *)
 
556
                            Util_SafeMalloc((*pres)->ai_addrlen);
 
557
         memcpy((*pres)->ai_addr, cur->ai_addr, (*pres)->ai_addrlen);
 
558
         pres = &((*pres)->ai_next);
534
559
      }
 
560
      *pres = NULL;
 
561
      freeaddrinfo(resA);
535
562
   }
536
563
 
537
564
   free(nodenameMBCS);
538
565
   free(servnameMBCS);
539
566
 
540
567
exit:
541
 
   if (hWs2_32) {
542
 
      FreeLibrary(hWs2_32);
 
568
   return retval;
 
569
}
 
570
 
 
571
 
 
572
/*
 
573
 *----------------------------------------------------------------------------
 
574
 *
 
575
 * Posix_FreeAddrInfo --
 
576
 *
 
577
 *      Free the addrinfo structure allocated by Posix_GetAddrInfo.
 
578
 *
 
579
 * Results:
 
580
 *      None.
 
581
 *
 
582
 * Side effects:
 
583
 *      None.
 
584
 *
 
585
 *----------------------------------------------------------------------------
 
586
 */
 
587
 
 
588
static INLINE void
 
589
Posix_FreeAddrInfo(struct addrinfo *ai)
 
590
{
 
591
   struct addrinfo *temp;
 
592
 
 
593
   while (ai) {
 
594
      temp = ai;
 
595
      ai = ai->ai_next;
 
596
      free(temp->ai_canonname);
 
597
      free(temp->ai_addr);
 
598
      free(temp);
543
599
   }
544
 
 
545
 
   return retval;
546
600
}
547
601
 
548
602
 
688
742
#if (defined(VMX86_SERVER) || defined(__APPLE__)) && \
689
743
   !defined(UNICODE_BUILDING_POSIX_WRAPPERS)
690
744
/*
691
 
 * ESX and MacOS X are UTF-8 environments so these functions can be
 
745
 * ESX and Mac OS are UTF-8 environments so these functions can be
692
746
 * "defined away" - the POSIX wrapper call can be directly mapped to the
693
747
 * POSIX function avoiding unneccesary (call and handling) overhead.
694
748
 *