Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/sync/notifier/base/nethelpers.cc

Issue 1956001: Moved XMPP notifier library from chrome/browser/sync to chrome/common.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "build/build_config.h"
6 #include "chrome/browser/sync/notifier/base/nethelpers.h"
7
8 namespace notifier {
9
10 hostent* SafeGetHostByName(const char* hostname, hostent* host,
11 char* buffer, size_t buffer_len,
12 int* herrno) {
13 hostent* result = NULL;
14 #if WIN32
15 result = gethostbyname(hostname);
16 if (!result) {
17 *herrno = WSAGetLastError();
18 }
19 #elif OS_LINUX
20 gethostbyname_r(hostname, host, buffer, buffer_len, &result, herrno);
21 #elif OS_MACOSX
22 result = getipnodebyname(hostname, AF_INET, AI_DEFAULT, herrno);
23 #else
24 #error "I don't know how to do gethostbyname safely on your system."
25 #endif
26 return result;
27 }
28
29 // This function should mirror the above function, and free any resources
30 // allocated by the above.
31 void FreeHostEnt(hostent* host) {
32 #if WIN32
33 // No need to free anything, struct returned is static memory.
34 #elif OS_LINUX
35 // No need to free anything, we pass in a pointer to a struct.
36 #elif OS_MACOSX
37 freehostent(host);
38 #else
39 #error "I don't know how to free a hostent on your system."
40 #endif
41 }
42
43 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/base/nethelpers.h ('k') | chrome/browser/sync/notifier/base/network_status_detector_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698