Skip to content
Snippets Groups Projects
Commit 0ca44d66 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Work with MINGW compiler. No need to have cygwin1.dll.

parent b9768afb
No related branches found
No related tags found
No related merge requests found
......@@ -2,15 +2,15 @@
# Makefile
#-------------------------------------------------------------------#
# 1.0 Laurent Destailleur Creation
# 1.1 Works with VC++ and gcc, Windows and Unix
# 1.1 Works with VC++ and GCC, Windows and Unix
#-------------------------------------------------------------------#
# Project options
#-----------------
# "GCC" to use GNU C++ compiler, "VC" to use Microsoft Visual C+
COMP=GCC
# "GCC" to use GCC GNU C++ (Cygwin or Linux), "MINGW" to use MINGW, "VC" to use Microsoft Visual C+
COMP=MINGW
# DEBUG=1 for debug
DEBUG=0
......@@ -27,6 +27,7 @@ PROGRAM = $(RUNDIR)UsedPort
# Object files to build (Ex: $(LIBDIR)yyy.o $(LIBDIR)zzz.o ...)
OBJLIST = $(LIBDIR)UsedPort.o$(BJ)
# Archive file for o files (Ex: $(LIBDIR)libxxx.a)
ifeq "$(OS)" "Windows_NT"
ARCHIVE = "mylib.a"
......@@ -34,9 +35,8 @@ else
ARCHIVE = "mylib.a"
endif
# Compiler options
#-----------------
# Compilation par gcc
# Compilation/Link by GCC
#------------------------
ifeq "$(COMP)" "GCC"
CC = gcc
CPP = g++
......@@ -49,17 +49,40 @@ else
COPTIONS=-O3
endif
ifeq "$(OS)" "Windows_NT"
LOPTIONS=-lwsock32
# wsock32 required only if _WIN32 defined in source code and use WSA* functions
# wsock32 of CYGWIN need cygwin1.dll to work
#LOPTIONS=-lwsock32 -Bstatic
LOPTIONS=-Bstatic
endif
ifeq "$(MACHTYPE)" "sparc"
LOPTIONS=-lsocket
LOPTIONS=-lsocket -Bstatic
endif
ifeq "$(PROCESSOR_ARCHITECTURE)" "x86"
LOPTIONS2=-m486
endif
endif
# Compilation/Link by MINGW
#--------------------------
ifeq "$(COMP)" "MINGW"
CC = mingw32-gcc.exe
CPP = mingw32-g++.exe
RSC = mingw32-g++.exe
AR = ar r
OUT=-o
ifeq "$(DEBUG)" "1"
COPTIONS=-Wall -g -DDEBUG
else
COPTIONS=-O3
endif
LOPTIONS=-lwsock32 -Bstatic
ifeq "$(PROCESSOR_ARCHITECTURE)" "x86"
LOPTIONS2=-m486
endif
endif
# Compilation par vc
# Compilation/Link by VC
#-----------------------
ifeq "$(COMP)" "VC"
CC = cl.exe
CPP = cl.exe
......@@ -90,25 +113,33 @@ endif
LDFLAGS = $(LOPTIONS) $(LOPTIONS2) $(LIBS)
$(LIBDIR)%.o: %.cpp
@echo ----- Compilation C++ par $(COMP) - $@
@echo ----- Compilation C++ by $(COMP) $(CPP) - $@
@echo CPP=$(CPP)
@echo CFLAGS=$(CFLAGS)
$(CPP) -c $(CFLAGS) $(SRC)$< $(OUT)$@
# @echo ----- Archivage en $(ARCHIVE)
# $(AR) $(ARCHIVE) $@
$(LIBDIR)%.obj: %.cpp
@echo ----- Compilation C++ par $(COMP) - $@
@echo ----- Compilation C++ by $(COMP) $(CPP) - $@
@echo CPP=$(CPP)
@echo CFLAGS=$(CFLAGS)
$(CPP) -c $(CFLAGS) $(SRC)$< $(OUT)$@
# @echo ----- Archivage en $(ARCHIVE)
# $(AR) $(ARCHIVE) $@
$(LIBDIR)%.o: %.c
@echo ----- Compilation C par $(COMP) - $@
@echo ----- Compilation C by $(COMP) $(CC) - $@
@echo CC=$(CC)
@echo CFLAGS=$(CFLAGS)
$(CC) -c $(CFLAGS) $(SRC)$< $(OUT)$@
# @echo ----- Archivage en $(ARCHIVE)
# $(AR) $(ARCHIVE) $@
$(LIBDIR)%.obj: %.c
@echo ----- Compilation C par $(COMP) - $@
@echo ----- Compilation C by $(COMP) $(CC) - $@
@echo CPP=$(CPP)
@echo CFLAGS=$(CFLAGS)
$(CC) -c $(CFLAGS) $(SRC)$< $(OUT)$@
# @echo ----- Archivage en $(ARCHIVE)
# $(AR) $(ARCHIVE) $@
......@@ -123,13 +154,15 @@ all: $(PROGRAM)
# Program (if PROGRAM is just one exe)
#$(PROGRAM1): $(OBJLIST1)
# @echo ----- Link - $@
# @echo ----- Link by $(COMP) $(CC) - $@
# rm -f $(RUNDIR)$@
# $(CC) -o $(RUNDIR)$@ $(OBJLIST) $(LDFLAGS) $(ARCHIVE)
# Program (if PROGRAM are several exe)
$(PROGRAM): $(OBJLIST)
@echo ----- Link - $@
@echo ----- Link by $(COMP) $(CC) - $@
@echo LIBDIR=$(LIBDIR)
@echo LDFLAGS=$(LDFLAGS)
rm -f $(RUNDIR)$@
# $(CC) -o $(RUNDIR)$@ $(LIBDIR)$@.o$(BJ) $(LDFLAGS) $(ARCHIVE)
$(CC) -o $(RUNDIR)$@ $(LIBDIR)$@.o$(BJ) $(LDFLAGS)
......@@ -137,9 +170,8 @@ $(PROGRAM): $(OBJLIST)
# Clean
clean:
@echo ----- Clean
$(RM) $(LIBDIR)*.a $(LIBDIR)*.o $(LIBDIR)*.obj $(RUNDIR)core $(OBJLIST)
$(RM) $(LIBDIR)*.a $(LIBDIR)*.o $(LIBDIR)*.obj $(RUNDIR)UsedPort.exe $(RUNDIR)core $(OBJLIST)
# Dependencies xxx.o: xxx.c xxxa.h xxxb.h
#$(LIBDIR)UsedPort.o: $(SRCDIR)UsedPort.cpp
#$(LIBDIR)SendMess.o: $(SRCDIR)SendMess.cpp
//---------------------------------------------------------------------------
// GetMess
//
// Get mails of POP3 account from command line or from a HTTP form (use CGI GET or POST method)
// It applies to the RFC 821 and RFC 822 specs
// It supports MIME 1.0 encoding of European national characters.
//
// Tested with :
// VC++ 4.0 (WIN32)
// GCC 2.8.1 (WIN32)
// GCC 2.7.3 (Aix 4.x)
// GCC 2.9 (Linux 2.0.x)
// UsedPort
//---------------------------------------------------------------------------
// 08/01/99 1.1 Laurent Destailleur Creation
// 15/10/99 1.2 Allow to delete several messages in action command
// 29/12/99 1.8 Use now good fonctions base64_decode and quoted_decode
// Tested with :
// VC++ 4.0
// GCC 3.4.4 CYGWIN (CYGWIN need cygwin1.dll)
// MINGW 3.4.5
// Not tested with:
// GCC 3.4.4 Linux
//---------------------------------------------------------------------------
// Required field if used as a CGI-BIN application:
// HOST = POP3 Server name
// USER = EMail POP3 account
// PASSWD = EMail POP3 password
//
// Optionnal fields if used as a CGI-BIN application:
// ACTION = Action to do (l,g,d)
// LANG = Language of messages
// 08/08/09 1.1 Laurent Destailleur Creation
//---------------------------------------------------------------------------
#define PROG "UsedPort"
#define VERSION "1.0"
// If GNU GCC CYGWIN: _WIN32 to defined manually, __GNUC__ is defined, _MSC_VER not defined
// If GNU GCC MINGW: _WIN32 automaticaly defined, __GNUC__ is defined, _MSC_VER not defined
// If VC: _WIN32 automaticaly defined, __GNUC__ is not defined, _MSC_VER defined
// If on Windows and Cygwin, we can use _WIN32 WSA pre function, if we want or not with Cygwin.
//#define _WIN32
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <malloc.h>
#include <memory.h>
#ifndef _WIN32
// Pour Unix
......@@ -47,6 +36,7 @@
#define LPHOSTENT struct hostent * // Non defini sous Unix
#define MAXHOSTNAMELEN 256
#endif
#ifdef _WIN32
#ifdef _MSC_VER
// Pour VC++
......@@ -55,14 +45,14 @@
#define MAXHOSTNAMELEN 256
#endif
#ifdef __GNUC__
#define MAXHOSTNAMELEN 256
// Pour GCC WIN32 CYGWIN
#include <winsock.h>
#include <mingw32/dir.h>
// Pour GCC WIN32 EGCS
//#include <base.h>
//#include <defines.h>
//#include <structures.h>
//#include <sockets.h> // Fichier a modifier sous GCC WIN32 pour contourner bug !!!
//#include <sockets.h>
//#include <functions.h>
#endif
#endif
......@@ -71,7 +61,6 @@
#define MAX_ENTRIES 10 // SUBJECT, HOST, USER, PASSWD
#define MAX_MAILS 100 // Nb max of mails managed
#define FILEINI "awmess.conf"
#define SIZE_RECEIVE_BUFFER 4096 // Ko
#define SIZE_BLOCK_FILELIST 256 // Size of block used to extend by alloc/realloc files list string
......@@ -146,7 +135,6 @@ int Ack(SOCKET sc);
int Ack_Stat(SOCKET sc,int *iNbUnread,unsigned long int *lSizeUnread);
int Ack_Mail(SOCKET sc,int mailcpt,const unsigned long int liMailSize);
int DoQuit(int iRet);
char *cgiLookup(char *tag,char *default_tag);
......@@ -204,11 +192,9 @@ int testConnect()
//---------------------------------------------------------------------------
{
SOCKET sc;
char bold[4],unbold[5];
char s[2048],t[256];
int i,firstmail,lastmail,mailcpt;
strcpy(bold,"");strcpy(unbold,"");
startgetmess:
......
No preview for this file type
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment