char * idl_constExpressionImage ( idl_constExpression constExpression) { char *image = NULL; char *operandImage = NULL; int i; int newLen; if (c_iterLength (constExpression->operands) == 1) { /* Unary operator */ operandImage = idl_operandImage (idl_operand(c_iterObject (constExpression->operands, 0))); newLen = strlen (operatorImage(constExpression->kind)) + strlen (operandImage) + 3; image = os_malloc (newLen); snprintf (image, newLen, "(%s%s)", operatorImage(constExpression->kind), operandImage); os_free (operandImage); } else { /* Binary operator */ for (i = 0; i < c_iterLength (constExpression->operands); i++) { operandImage = idl_operandImage (idl_operand(c_iterObject (constExpression->operands, i))); if (image == NULL) { newLen = strlen (operandImage) + 2; image = os_malloc (newLen); os_strncpy (image, "(", newLen); } else { newLen = strlen (image) + strlen (operatorImage(constExpression->kind)) + strlen (operandImage) + 4; image = os_realloc (image, newLen); strncat (image, " ", newLen); os_strncat (image, operatorImage(constExpression->kind), newLen); strncat (image, " ", newLen); } os_strncat (image, operandImage, newLen); os_free (operandImage); } strncat (image, ")", newLen); } return image; }
/** @brief generate name which will be used as a macro to prevent multiple inclusions * * From the specified basename create a macro which will * be used to prevent multiple inclusions of the generated * header file. The basename characters are translated * into uppercase characters and the append string is * appended to the macro. */ static c_char * idl_macroFromBasename( const char *basename, const char *append) { static c_char macro[200]; c_long i; for (i = 0; i < (c_long)strlen(basename); i++) { macro[i] = toupper (basename[i]); macro[i+1] = '\0'; } os_strncat(macro, append, (size_t)((int)sizeof(macro)-(int)strlen(append))); return macro; }
static char * idl_genSajXMLMeta( c_type type) { char *meta; char *newMeta; int pcs; int len; char *ptr; int i; meta = idl_genXMLmeta(type); len = strlen(meta); pcs = (len/IDL_MAX_JSTRING_META_SIZE); if ((len % IDL_MAX_JSTRING_META_SIZE) != 0) { pcs++; } /** * What do we need per piece? * - two " characters * - one ',' character * - one '\n' character * */ len += 4*pcs; newMeta = os_malloc(len + 1); if (newMeta) { ptr = meta; newMeta[0] = 0; while (pcs > 1) { os_strcat(newMeta, "\""); i = 1; while (ptr[IDL_MAX_JSTRING_META_SIZE-i] == '\\') { i++; } os_strncat(newMeta, ptr, IDL_MAX_JSTRING_META_SIZE-i+1); ptr += (IDL_MAX_JSTRING_META_SIZE-i+1); os_strcat(newMeta, "\",\n"); pcs--; } os_strcat(newMeta, "\""); os_strcat(newMeta, ptr); os_strcat(newMeta, "\""); } os_free(meta); return newMeta; }
/* Build a textual presenation of the provided scope stack taking the Java keyword identifier translation into account. Further the function equals "idl_scopeStack". */ c_char * idl_scopeStackJava ( idl_scope scope, const char *scopeSepp, const char *name) { c_long si; c_long sz; c_char *scopeStack; c_char *Id; if(orgLastSubstituted) { os_free(orgLastSubstituted); orgLastSubstituted = NULL; } if(tarLastSubstituted) { os_free(tarLastSubstituted); tarLastSubstituted = NULL; } si = 0; sz = idl_scopeStackSize(scope); if (si < sz) { /* The scope stack is not empty */ /* Copy the first scope element name */ scopeStack = os_strdup(idl_javaId(idl_scopeJavaElementName(idl_scopeIndexed(scope, si)))); si++; while (si < sz) { /* Translate the scope name to a C identifier */ Id = idl_javaId(idl_scopeJavaElementName(idl_scopeIndexed(scope, si))); /* allocate space for the current scope stack + the separator and the next scope name */ /* QAC EXPECT 5007; will not use wrapper */ scopeStack = os_realloc(scopeStack, (size_t)( (int)strlen(scopeStack)+ (int)strlen(scopeSepp)+ (int)strlen(Id)+1)); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, scopeSepp); /* Concatenate the scope name */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat (scopeStack, Id); si++; } if(strlen(scopeStack) > 0) { os_char* ptr; os_char* ptr2; os_char* ptr3; /* es, dds1540: The following code is not pretty, but time limitations * required it's implementation. To ensure * proper substitution of for example package name 'Chat' with * 'org.opensplice.Chat' without substitution class names like * 'ChatMessage' to 'org.opensplice.ChatMessage' we need to take some * special arrangements. We need to allow the user to state he wants to * replace 'Chat.' with ''org.opensplice.Chat.', as this would resolve * the previously stated problem. * However this function for getting the scope stack is called in a * special way if only the package names are required (without the * specific class at the end). In these cases package Chat would become * in string format 'Chat' instead of 'Chat.'. And this would cause * problems when doing the substitution for the directory names and * package directives. So to ensure substitution always goes correctly * we added the scopeSepp to the end of the scopeStack and input that * into the substitution algorithm. After the algorithm we remove the * added scopeSepp again. * So not that nicely solved, but lack of time to do it more nicely * (which would be to support regular expression type things) --> No. */ ptr = os_malloc(strlen(scopeStack)+ strlen(scopeSepp) + 1); os_strcpy(ptr, scopeStack); os_strncat(ptr, scopeSepp, strlen(scopeSepp)); ptr2 = idl_genJavaHelperApplyPackageSubstitute(ptr, scopeSepp); memset(ptr, 0, strlen(ptr)); os_free(ptr); ptr3 = strrchr(ptr2, *scopeSepp); if(ptr3) { *ptr3 = '\0'; } ptr = os_strdup(ptr2); memset(ptr2, 0, strlen(ptr2)); os_free(ptr2); memset(scopeStack, 0, strlen(scopeStack)); os_free(scopeStack); scopeStack = ptr; } if (name) { /* A user identifier is specified */ /* Translate the user identifier to a Java identifier */ Id = idl_javaId(name); /* allocate space for the current scope stack + the separator and the user identifier */ /* QAC EXPECT 5007; will not use wrapper */ scopeStack = os_realloc(scopeStack, (size_t)( (int)strlen(scopeStack)+ (int)strlen(scopeSepp)+ (int)strlen(Id)+1)); /* Concatenate the separator */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat(scopeStack, scopeSepp); /* Concatenate the user identifier */ /* QAC EXPECT 5007; will not use wrapper */ os_strcat (scopeStack, Id); } } else { /* The stack is empty */ if (name) { /* A user identifier is specified */ scopeStack = os_strdup(idl_javaId(name)); } else { /* make the stack represenation empty */ scopeStack = os_strdup(""); } } /* return the scope stack representation */ return scopeStack; }