Commit 16aa0061 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Properly shield against using missing functions in non-UNIXy embedded systems

parent 3240e549
......@@ -306,8 +306,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_SourceFile.write(" if (ossEncode(g_world, OSS_%s_PDU, &var_%s, &strm) != 0) {\n" %
(self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename)))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not encode %s (at %%s, %%d), errorMessage was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" assert(strm.length <= iMaxBufferSize);\n")
......@@ -321,8 +323,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_SourceFile.write(" if (asn1Scc%s_%sEncode(pSrc, &strm, &errorCode, TRUE) == FALSE) {\n" %
(self.CleanNameAsToolWants(nodeTypename),
("ACN_" if encoding.lower() == "acn" else "")))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" return BitStream_GetLength(&strm);\n")
......@@ -399,8 +403,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.CleanNameAsToolWants(nodeTypename))
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not decode %s (at %%s, %%d), error message was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n")
......@@ -408,8 +414,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
elif encoding.lower() in ["uper", "acn"]:
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not decode %s (at %%s, %%d), error code was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n")
......
......@@ -296,8 +296,10 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.C_SourceFile.write(
" if (ossEncode(g_world, OSS_%s_PDU, &var_%s, &strm) != 0) {\n" %
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not encode %s (at %%s, %%d), errorMessage was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" assert(strm.length <= iMaxBufferSize);\n")
......@@ -312,8 +314,10 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
(self.CleanNameAsToolWants(nodeTypename),
"ACN_" if encoding.lower() == "acn" else "",
self.CleanNameAsToolWants(nodeTypename)))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" return BitStream_GetLength(&strm);\n")
......@@ -440,16 +444,20 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.C_SourceFile.write(" ossFreeBuf(g_world, pVar_%s);\n" % self.CleanNameAsToolWants(nodeTypename))
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not decode %s (at %%s, %%d), error message was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n\n")
elif encoding.lower() in ["uper", "acn"]:
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not decode %s (at %%s, %%d), error code was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n\n")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment