C code in OpenEmm

Use this forum for all questions related to the source code of OpenEMM

Moderator: moderator

rmizzi
Posts: 8
Joined: Thu May 31, 2012 10:57 am

C code in OpenEmm

Post by rmizzi »

Hello,

I'm a student that is currently carrying out some research on polyglot programming and have come across openEmm which seems to me to be a good example of such software being written in Java, Python and C.

I'm wondering whether people familiar with the openEmm source code can give me some starting points to answer these 2 questions :
1) what functions is the code written in C carrying out? documentation mentions functions requiring better performance but i'm interested in knowing what these functions are.

2) how is the C code called? is it being called from Java or from Python?

I basically want to pin point what action I, as a user, can carry out on the GUI to trigger calling of the C functions without having to dive into the source code blindly.

Thanks in advance,
Ruth
ud
Posts: 154
Joined: Thu Aug 17, 2006 9:56 am
Location: Munich, Germany
Contact:

Re: C code in OpenEmm

Post by ud »

Hello Ruth,

thank you for your question, I'm glad to see that someone is still interested in C while the world is only talking about Java these days.

1.) The C code is primary written to create the final mails. While the Java code retrieves the informations from the database and collect them in a XML file (for a real mailing with typically 1,000 receivers per XML file), the C part takes these informations and creates every final mail. Beside resolving the dynamic dependencies and adding the personalization for each created mail, the converting to the destination character set and the transfer encoding are the most CPU intensive tasks done here.

As the C part "knows" everything about creating the mail content, it is also responsible for generating the preview in OpenEMM and the fullview for a newsletter.

Beside this core component, there are some tools written in C, either to use external libraries (e.g. bav as this relies on the sendmail milter library) or for security reason, if a program needs super user rights.

2.) The code is called from both, Java and Python. But, in good Unix tradition, the C part is not an integral part of Java or Python but is called a an external stand alone program. Communication between C and Java/Python is done using XML files. Theses approaches allow easily separate testing of each component and examine of the exchanged data as they are human readable files.

-- ud
rmizzi
Posts: 8
Joined: Thu May 31, 2012 10:57 am

Re: C code in OpenEmm

Post by rmizzi »

Thanks a lot for your prompt and informative reply.
I will use this information as a starting point and will definitely come back here if I have additional questions.
sofia
Posts: 1
Joined: Fri May 10, 2013 6:44 am

Re: C code in OpenEmm

Post by sofia »

Hello,

We are now studing openemm for sending dynamic attachment. It seems the email generation part is writen in C. Where to download the sourcecode for xmlback.exe?

Sofia
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: C code in OpenEmm

Post by maschoff »

You can find the source code of OpenEMM at SourceForge. The source tarball includes a build script that compiles xmlback out of the source code.
OpenEMM Maintainer
Wendy
Posts: 11
Joined: Thu May 16, 2013 2:58 am

Re: C code in OpenEmm

Post by Wendy »

Hello,

I installed Microsoft Visual Studio 8 and MinGW in my win32 PC, when I try to run build.bat, I got a lot of error, and I tried to correct these error by update lib and code, but it did not work at all. I want to know what kind of environment should I prepare to build xmlback.c succeffully?

Thanks a lot!
Wendy
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: C code in OpenEmm

Post by maschoff »

Linux. We use CentOS 5 or 6.

If you want to compile with Windows, we provide a batch file build.bat in directories /src/c/lib, /src/c/xmlback and /src/c/xmlback/grammar each.

But you need Windows libraries for libxml2, libz, iconv and libslang first. For compiling we use Visual Studio 8.
OpenEMM Maintainer
Wendy
Posts: 11
Joined: Thu May 16, 2013 2:58 am

Re: C code in OpenEmm

Post by Wendy »

maschoff wrote:Linux. We use CentOS 5 or 6.

If you want to compile with Windows, we provide a batch file build.bat in directories /src/c/lib, /src/c/xmlback and /src/c/xmlback/grammar each.

But you need Windows libraries for libxml2, libz, iconv and libslang first. For compiling we use Visual Studio 8.
Thanks a lot for your information! I recompiled C code again, but I still need libslang.lib, how can I get it? by compile slang-1.4.9 and how? or Can I download the lib file?
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: C code in OpenEmm

Post by maschoff »

File INSTALL.pc in tarball slang-1.4.9.tar.gz (part of the OpenEMM source tarball) is an entry point for users of Windows platforms.
OpenEMM Maintainer
Wendy
Posts: 11
Joined: Thu May 16, 2013 2:58 am

Re: C code in OpenEmm

Post by Wendy »

maschoff wrote:Linux. We use CentOS 5 or 6.

If you want to compile with Windows, we provide a batch file build.bat in directories /src/c/lib, /src/c/xmlback and /src/c/xmlback/grammar each.

But you need Windows libraries for libxml2, libz, iconv and libslang first. For compiling we use Visual Studio 8.

Hi,

When we compiling /src/c/lib with the provide build.bat, we got below message:

Code: Select all

C:\workspace\emm_c\src\lib>build.bat
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

atob.c
c:\workspace\emm_c\src\lib\agn.h(313) : error C2061: syntax error : identifier 'pid_t'
c:\workspace\emm_c\src\lib\agn.h(317) : error C2059: syntax error : '}'
c:\workspace\emm_c\src\lib\agn.h(469) : error C2143: syntax error : missing '{' before '*'
c:\workspace\emm_c\src\lib\agn.h(470) : error C2143: syntax error : missing '{' before '*'
......
It seems the pid_t is not defined in VC8.
So could you please kindly let me know what is the complile environment you are using? Only VC8, or some others?

Thank you!!

Wendy
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: C code in OpenEmm

Post by maschoff »

Strange, this part of the code should not be compiled at all because it is wrapped with #ifndef WIN32 and #endif.
OpenEMM Maintainer
Wendy
Posts: 11
Joined: Thu May 16, 2013 2:58 am

Re: C code in OpenEmm

Post by Wendy »

This is the relative code from agn.h (the log reminds that the error happened in line 313)

Code: Select all

typedef struct { /*{{{*/
	bool_t	background;	/* if we should run in background	*/
	bool_t	detach;		/* if we should detach from current tty	*/
	pid_t	pid;		/* process ID of daemon process		*/
	char	*pidfile;	/* file to write PID to			*/
	bool_t	pfvalid;	/* if pidfile is used by us		*/
	/*}}}*/
}	daemon_t;

and we did not find #if and #endif declaration here.

By the way, all my code are from OpenEMM-2013-src.tar.gz.

Wendy
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: C code in OpenEmm

Post by maschoff »

Oops, that's a bug (Winodws version only)! You can remove the complete structure and prototypes for function daemon_* from the source code. Or you can wait because we will provide a new source tarball soon.
OpenEMM Maintainer
Wendy
Posts: 11
Joined: Thu May 16, 2013 2:58 am

Re: C code in OpenEmm

Post by Wendy »

Thanks for your quick responce and guidance.

We will try the two ways but we are looking forward your updated version. Please let us know when you are prepared.

Wendy
Wendy
Posts: 11
Joined: Thu May 16, 2013 2:58 am

Re: C code in OpenEmm

Post by Wendy »

Hi maschoff,

we followed your suggesation to comment pid_t definition and exclude the whole deamon.c and build the code, and the compile failed again.
and here is a part of the error log:

Code: Select all

...
c:\workspace\openemm_vc\src\lib\csig.c(42) : error C2079: 'set' uses undefined struct 'sigaction'
c:\workspace\openemm_vc\src\lib\csig.c(43) : error C2079: 'old' uses undefined struct 'sigaction'
c:\workspace\openemm_vc\src\lib\csig.c(61) : error C2224: left of '.sa_handler' must have struct/union type
.....
I think it'd beter to wait for your clean updated version.
Thanks again!

Wendy
Post Reply