Bug 641212 Part 4 - Refactor updater headers to be usable from C. r?rstrong draft
authorMatt Howell <mhowell@mozilla.com>
Thu, 26 Jan 2017 15:11:15 -0800
changeset 607656 1c0cbaadc6768afd981953f84cf1b164d1376af9
parent 607655 531b395baa57783489b21a55579e2b5385cca974
child 607657 1cba5ce0b41469b70b0effd8743505157e26aa06
push id68072
push usermhowell@mozilla.com
push dateWed, 12 Jul 2017 17:32:12 +0000
reviewersrstrong
bugs641212
milestone56.0a1
Bug 641212 Part 4 - Refactor updater headers to be usable from C. r?rstrong The changes to libmar mean that a couple of C files there now need to include updatedefines.h. This file contains a couple of things that only build in C++, so rearrange those things to make it work in C as well. MozReview-Commit-ID: 3YtWv67UinW
toolkit/mozapps/update/common/readstrings.h
toolkit/mozapps/update/common/updatedefines.h
--- a/toolkit/mozapps/update/common/readstrings.h
+++ b/toolkit/mozapps/update/common/readstrings.h
@@ -2,24 +2,19 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef READSTRINGS_H__
 #define READSTRINGS_H__
 
-#define MAX_TEXT_LEN 600
+#include "updatedefines.h"
 
-#ifdef XP_WIN
-# include <windows.h>
-  typedef WCHAR NS_tchar;
-#else
-  typedef char NS_tchar;
-#endif
+#define MAX_TEXT_LEN 600
 
 #ifndef NULL
 #define NULL 0
 #endif
 
 struct StringTable
 {
   char title[MAX_TEXT_LEN];
--- a/toolkit/mozapps/update/common/updatedefines.h
+++ b/toolkit/mozapps/update/common/updatedefines.h
@@ -1,17 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef UPDATEDEFINES_H
 #define UPDATEDEFINES_H
 
-#include "readstrings.h"
-
 #ifndef MAXPATHLEN
 # ifdef PATH_MAX
 #  define MAXPATHLEN PATH_MAX
 # elif defined(MAX_PATH)
 #  define MAXPATHLEN MAX_PATH
 # elif defined(_MAX_PATH)
 #  define MAXPATHLEN _MAX_PATH
 # elif defined(CCHMAXPATH)
@@ -24,16 +22,18 @@
 #if defined(XP_WIN)
 # include <windows.h>
 # include <shlwapi.h>
 # include <direct.h>
 # include <io.h>
 # include <stdio.h>
 # include <stdarg.h>
 
+typedef WCHAR NS_tchar;
+
 # ifndef F_OK
 #   define F_OK 00
 # endif
 # ifndef W_OK
 #   define W_OK 02
 # endif
 # ifndef R_OK
 #   define R_OK 04
@@ -83,37 +83,43 @@ static inline int mywcsprintf(WCHAR* des
 # define NS_tstrcmp wcscmp
 # define NS_tstricmp wcsicmp
 # define NS_tstrcpy wcscpy
 # define NS_tstrncpy wcsncpy
 # define NS_tstrlen wcslen
 # define NS_tstrchr wcschr
 # define NS_tstrrchr wcsrchr
 # define NS_tstrstr wcsstr
+
+#ifdef __cplusplus
 # include "win_dirent.h"
 # define NS_tDIR DIR
 # define NS_tdirent dirent
 # define NS_topendir opendir
 # define NS_tclosedir closedir
 # define NS_treaddir readdir
+#endif
+
 #else
 # include <sys/wait.h>
 # include <unistd.h>
 
 #ifdef SOLARIS
 # include <sys/stat.h>
 #else
 # include <fts.h>
 #endif
 # include <dirent.h>
 
 #ifdef XP_MACOSX
 # include <sys/time.h>
 #endif
 
+typedef char NS_tchar;
+
 # define LOG_S "%s"
 # define NS_T(str) str
 # define NS_SLASH NS_T('/')
 # define NS_tsnprintf snprintf
 # define NS_taccess access
 # define NS_tatoi atoi
 # define NS_tchdir chdir
 # define NS_tchmod chmod