--- a/c2iec.y
+++ b/c2iec.y
@@ -60,6 +60,14 @@
 
 // map c datatype to iec (standard and userdefined)
 char *maptype(char *ctype);
+
+// get identifier from payload data
+// when used e.g. with the declarator of a struct,
+// the name is reproducable
+char *genIdentifier(char *szData);
+
+// convert input string to upper case
+char *strUpper(char *szStr);
 
 // lex/yacc functions
 extern int yylex (void);
@@ -318,10 +326,15 @@
 struct_or_union_specifier
 	: struct_or_union IDENTIFIER '{' struct_declaration_list '}'
 	{
-		printf("TYPE %s:\nSTRUCT\n %s\nEND_STRUCT\nEND_TYPE\n", $<str>2, $<str>4);
-		strcpy($<str>$, "");
+		printf("TYPE %s:\n%s\n %s\nEND_STRUCT\nEND_TYPE\n\n", $<str>2, strUpper($<str>1), $<str>4);
+		strcpy($<str>$, $<str>2);
 	}
 	| struct_or_union '{' struct_declaration_list '}'
+	{
+		char *szTypeName = genIdentifier($<str>3);
+		printf("TYPE %s:\n%s\n %s\nEND_STRUCT\nEND_TYPE\n\n", szTypeName, strUpper($<str>1), $<str>3);
+		strcpy($<str>$, szTypeName);
+	}
 	| struct_or_union IDENTIFIER
 	;
 
@@ -743,6 +756,50 @@
 		return "STRUCT";
 	if (!strcmp(ctype, ""))
 		return "";
-	printf("maptype: not found: %s\n", ctype);
+//	printf("maptype: not found: %s\n", ctype);
 	return ctype;
 }
+
+unsigned int genCRC(char *szData)
+{
+	char *p;
+	unsigned int i;
+	unsigned int v;
+	unsigned int crc;
+
+	i = 0;
+	crc = 42; // start value
+	p = szData;
+	while (*p != 0)
+	{
+		v = crc & 0xf8000000;
+		crc = crc << 5;
+		crc = crc ^ (v >> 27);
+		crc ^= i;
+		i++;
+		p++;
+	}
+	return crc;
+}
+
+char *genIdentifier(char *szData)
+{
+	static char szId[8];
+	unsigned int crc;
+	crc = genCRC(szData);
+	sprintf(szId, "Id%u", crc);
+	return szId;
+}
+
+char *strUpper(char *szStr)
+{
+	char *p;
+	p = szStr;
+	while (*p != 0)
+	{
+		if (*p >= 'a' && *p <= 'z')
+			*p = *p - ('a' - 'A');
+		p++;
+	}
+	return szStr;
+}