Skip to content

Commit

Permalink
Windows portability changes contributed by Richard Christman.
Browse files Browse the repository at this point in the history
  • Loading branch information
merkinmuffley committed Aug 7, 2014
1 parent a5777a6 commit 82575e9
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 13 deletions.
10 changes: 8 additions & 2 deletions Src/config.h
Expand Up @@ -391,8 +391,14 @@ extern int MAXRECIPIENTS;
extern long TIMESKEW_FORWARD;
extern long TIMESKEW_BACK;
extern int TEMP_FAIL;
extern char ALLPINGERSURL[];
extern char ALLPINGERSFILE[];

#ifdef WIN32 // RTC
DLLIMPORT extern char ALLPINGERSURL[]; // RTC
DLLIMPORT extern char ALLPINGERSFILE[]; // RTC
#else // RTC
extern char ALLPINGERSURL[]; // RTC
extern char ALLPINGERSFILE[]; // RTC
#endif /* WIN32 */ // RTC

extern char WGET[];
extern char STATSSRC[];
Expand Down
15 changes: 13 additions & 2 deletions Src/keymgt.c
Expand Up @@ -13,7 +13,12 @@
#include <string.h>
#include <time.h>
#include <assert.h>
#include <unistd.h>

#ifdef WIN32 // RTC
#include <io.h> // RTC
#else // RTC
#include <unistd.h> // RTC
#endif // RTC

int getv2seckey(byte keyid[], BUFFER *key);
static int getv2pubkey(byte keyid[], BUFFER *key);
Expand Down Expand Up @@ -510,7 +515,13 @@ int deleteoldkeys(void)
mixfile(path2, SECRING);
if (rename(path1, path2)) return -14;
}
sync();

#ifdef WIN32 // RTC
// sync() // RTC
#else // RTC
sync(); // RTC
#endif /* WIN32 */ // RTC

if (!keyring) return -15;
memset(line,'\n',LINELEN-1);
line[LINELEN-1]='\0';
Expand Down
4 changes: 2 additions & 2 deletions Src/main.c
Expand Up @@ -162,16 +162,16 @@ int main(int argc, char *argv[])
if (lifeindays<0)
lifeindays=0;
} else if (strleft(p, "size") && p[strlen("size")] == '=') {
keysize=strtol(p + strlen("size") + 1,NULL,10);
switch(keysize) {
case 1024:
case 2048:
case 3072:
case 4096:
/* only certain permitted sizes */
keysize=strtol(p + strlen("size") + 1,NULL,10);
break;
default:
keysize=4096;
/* ignoring invalid size seen on comand-line */
break;
}
} else if (strleft(p, "update-stats") && p[strlen("update-stats")] == '=') {
Expand Down
10 changes: 9 additions & 1 deletion Src/menustats.c
Expand Up @@ -20,7 +20,12 @@ int menu_getuserpass(BUFFER *p, int mode) { return 0; };
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef WIN32 // RTC
#include <io.h> // RTC
#else // RTC
#include <unistd.h> // RTC
#endif

#include "menu.h"
#ifdef WIN32
Expand Down Expand Up @@ -264,6 +269,9 @@ int stats_download(BUFFER *allpingers, char *sourcename, int curses) {
mixfile(path, localfiles[i]);
mixfile(path_t, localfiles[i]);
strcat(path_t, ".t");
#ifdef WIN32 // RTC
unlink(path); // RTC
#endif /* WIN32 */ // RTC
rename(path_t, path);
}

Expand Down
5 changes: 3 additions & 2 deletions Src/menuutil.c
Expand Up @@ -91,9 +91,10 @@ void menu_spawn_editor(char *path, int lineno) {
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
sei.hwnd = NULL;
sei.lpVerb = "open";
sei.lpFile = path;
sei.lpParameters = NULL;
sei.nShow = SW_SHOWNORMAL;
// next 2 settings from RTC
sei.lpFile = "notepad.exe";
sei.lpParameters = path;

if (ShellExecuteEx(&sei) == TRUE) {
WaitForSingleObject(sei.hProcess, INFINITE);
Expand Down
35 changes: 32 additions & 3 deletions Src/mix.c
Expand Up @@ -620,7 +620,7 @@ int mix_configline(char *line)
read_conf_i(CLIENTAUTOFLUSH) ||
read_conf_i(MAXRECIPIENTS) ||
read_conf_i(SMTPPORT) ||

read_conf_t(TIMESKEW_FORWARD) ||
read_conf_t(TIMESKEW_BACK) ||
read_conf_i(TEMP_FAIL) );
Expand Down Expand Up @@ -656,15 +656,22 @@ int mix_config(void)
* first match wins.
*
* - what the MIXPATH environment variable points to, if it is set.
* - (MIX3PATH on WIN32 to avoid clashing with earlier versions)
* - On WIN32, HKEY_CURRENT_USER\Software\Mixmaster\MixDir, if it exists
* - whatever is compiled in with -DSPOOL
* - On Win32 %APPDATA%\Mixmaster
* - on POSIX, ~/Mix (or ~/<HOMEMIXDIR>)
* - the current working directory
*/

if (err == -1 && (d = getenv("MIXPATH")) != NULL)
err = mixdir(d, 1);
if (err == -1 && (d = getenv(
#ifdef WIN32
// MIX3PATH comes from RTC
"MIX3PATH"
#else
"MIXPATH"
#endif /* WIN32 */
)) != NULL) err = mixdir(d, 1);

#ifdef WIN32
RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &regsw);
Expand Down Expand Up @@ -907,8 +914,30 @@ void mix_check_timeskew() {
}
}

#ifdef WIN32 // RTC
char* mix_version(void) // RTC
{ // RTC
return VERSION; // RTC
} // RTC
int mix_initex(char *mixdir) // RTC
{ // RTC
return mix_init(mixdir); // RTC
} // RTC
#endif /* WIN32 */ // RTC

int mix_init(char *mixdir)
{
#ifdef WIN32 // RTC
char mixpath[PATHMAX + 50]; // RTC
if (mixdir) // RTC
{ // RTC
strcpy(mixpath, "MIX3PATH="); // RTC
strncat(mixpath, mixdir, PATHMAX); // RTC
putenv(mixpath); // RTC
initialized = 0; // RTC
} // RTC
#endif /* WIN32 */ // RTC

if (!initialized) {
if (mixdir)
strncpy(MIXDIR, mixdir, LINELEN);
Expand Down
5 changes: 5 additions & 0 deletions Src/mix3.h
Expand Up @@ -244,6 +244,11 @@ int mix_config(void);
int mix_initialized(void);
int mix_daily(void);

#ifdef WIN32 // RTC
char* mix_version(void); // RTC
int mix_initex(char *mixdir); // RTC
#endif // RTC

/* message pool */
#define INTERMEDIATE 0
int pool_send(void);
Expand Down
10 changes: 10 additions & 0 deletions Src/mixlib.def
Expand Up @@ -119,3 +119,13 @@ EXPORTS
mix_check_timeskew @114
MIXCONF @115
menu_main @116

ALLPINGERSFILE @117 ; // RTC
ALLPINGERSURL @118 ; // RTC
STATSSRC @119 ; // RTC
download_stats @120 ; // RTC
url_download @121 ; // RTC
parse_yearmonthday @122 ; // RTC
rnd_bytes @123 ; // RTC
mix_version @124 ; // RTC
mix_initex @125 ; // RTC
2 changes: 1 addition & 1 deletion Src/version.h
@@ -1 +1 @@
#define VERSION "3.0.2e"
#define VERSION "3.0.2f"

0 comments on commit 82575e9

Please sign in to comment.