/* $Id: ocismp.c,v 1.1 1998/11/03 04:30:51 yxia Exp $ Copyright (c) Oracle Corporation 1991, 1996. All Rights Reserved, Worldwide. NAME ocismp.c FUNCTION OCI test example NOTES Reports OCI provides the call interface for a C program to invoke all Oracle Reports functionalities (Designer, Runtime, and Convrep). The mechanism of OCI and the way to link in OCI could be different from one platform to another. On Win32 platform, Reports OCI is a library (either static or DLL) and the invoked Reports executable is run on either seperate process or linked in depends server and background settings. So the way to link in OCI on Win32 is: > cc r30oci32.lib (for DLL) OR: > cc r30soi32.lib (for static) On some other platforms such as Motif, OCI is a SSL table of entry points to Reports Designer, Runtime, and Convrep. There are four SSL tables: - srxocic.o SSL table for linking in char mode Rintime - srxocib.o SSL table for linking in bitmapped Designer & Runtime - srxocibg.o SSL table for linking in bitmapped Designer & Runtime & Oracle Graphics - srxociw.o SSL table for linking in bitmapped Designer & Runtime on Windows platform In these SSL tables, CONVREP is NEVER linked in. This means a seperate process will be spawned to run CONVREP executables when they are invoked from user's C program. The same thing happens for a program which is linked with srxocic.o when bitmapped Runtime is invoked. On the other hand, bitmapped Runtime will run in the same process for a program linked with srxocib.o. The way to link in OCI on those platforms is: > cc srxoci[c,b,bg].o One and ONLY one srxocib*.c should be used. In this test example, we call the appropriate OCI function and pass in the command line parameters. The decision about which entry point is to be called is based on the first parameter: First Parameter OCI Function ------------------------------------------------- DESIGNER_BITMAP rw2srb RUNTIME_BITMAP rw2rrb RUNTIME_CM rw2run FILE use the command line in file The rest of parameters are passed to the OCI function. */ #define NULLV(x) ((x)0) #include #include #include #include #ifdef WIN_1632 #include #endif #ifndef RWOCI # include "rwoci.h" #endif static long parsecmdline(/*_ char** cmd_linep, long (**entry_fnp)(char*, long*) _*/); #ifndef WIN_1632 long main(argc, argv) int argc; char *argv[]; { long len = 0; long (*entry_fn)(/*_ char*, long* _*/); long ecod; char cmd_line[1204]; char *tmp; int i; if (argc < 2) { (void) fprintf(stderr, "ERROR: Please specify the first parameter as one of the following:"); (void) fprintf(stderr, "\n DESIGNER_BITMAP"); (void) fprintf(stderr, "\n RUNTIME_BITMAP"); (void) fprintf(stderr, "\n RUNTIME_CM"); (void) fprintf(stderr, "\n FILE "); (void) fprintf(stderr, "\n"); } if (!strcmp(argv[1], "FILE") ||!strcmp(argv[1], "file")) { char *filename = argv[2]; FILE *fp = fopen(filename, "r"); if (!fp) { (void) fprintf(stderr, "\n Can't open the file: %s\n", filename); return 1; } while (fgets(cmd_line, 1023, fp)) { char *tmp = cmd_line; if (ecod = parsecmdline(&tmp, &entry_fn)) { (void) fprintf(stderr, "ERROR: Please specify the first parameter as one of the following:"); (void) fprintf(stderr, "\n DESIGNER_BITMAP"); (void) fprintf(stderr, "\n RUNTIME_BITMAP"); (void) fprintf(stderr, "\n RUNTIME_CM"); (void) fprintf(stderr, "\n"); break; } len = strlen(tmp); ecod = (*entry_fn)(tmp, &len); /* don't check the ecod because a bug in ssl (bug xxxxxx), ssl always return error when spawn a executable. !!!! */ } if (fp) (void) fclose(fp); } else { cmd_line[0] = 0; for (i = 1; i < argc; i++) { strcat(cmd_line, argv[i]); strcat(cmd_line, " "); } tmp = cmd_line; if (ecod = parsecmdline(&tmp, &entry_fn)) { (void) fprintf(stderr, "ERROR: Please specify the first parameter as one of the following:"); (void) fprintf(stderr, "\n DESIGNER_BITMAP"); (void) fprintf(stderr, "\n RUNTIME_BITMAP"); (void) fprintf(stderr, "\n RUNTIME_CM"); (void) fprintf(stderr, "\n FILE "); (void) fprintf(stderr, "\n"); } else { len = strlen(tmp); ecod = (*entry_fn)(tmp, &len); } } return ecod; } #else int WINAPI WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow) { char cmd_line[1024]; long len = 0; long (*entry_fn)(/*_ char*, long* _*/) = NULL; int ecod = 0; char *tmp; strcpy(cmd_line, lpszCmdLine); tmp = strtok(cmd_line, " "); if ( !tmp ) { /* printf("Please specify DESIGNER_BITMAP, RUNTIME_BITMAP,"); printf(" or RUNTIME_CM or FILE"); */ return 1; } if (!strcmp(tmp, "FILE") || !strcmp(tmp, "file")) { char *filename = tmp + strlen( tmp ) + 1; FILE *fp = fopen(filename, "r"); if (!fp) { /* printf("\n Can't open the file: %s\n", filename); */ return 1; } while (fgets(cmd_line, 1023, fp)) { char *tmp = cmd_line; if (ecod = parsecmdline(&tmp, &entry_fn)) { /* printf("ERROR: Please specify the first parameter as one of"); printf(" the following:"); printf("\n DESIGNER_BITMAP"); printf("\n RUNTIME_BITMAP"); printf("\n RUNTIME_CM"); printf("\n"); */ break; } len = strlen(tmp); if (ecod = (*entry_fn)(tmp, &len)) break; } if (fp) fclose(fp); } else { strcpy(cmd_line, lpszCmdLine); tmp = cmd_line; if (ecod = parsecmdline(&tmp, &entry_fn)) { /* printf("ERROR: Please specify the first parameter as one of"); printf(" the following:"); printf("\n DESIGNER_BITMAP"); printf("\n RUNTIME_BITMAP"); printf("\n RUNTIME_CM"); printf("\n FILE "); printf("\n"); */ } else { len = strlen(tmp); ecod = (*entry_fn)(tmp, &len); } } return ecod; } #endif /* * parse command line, get correct entry_fn and remaining command */ static long parsecmdline(cmd_linep, entry_fnp) char **cmd_linep; long (**entry_fnp)(/*_ char*, long* _*/); { char *tmp; tmp = strtok(*cmd_linep, " "); if (!tmp) return 1; /*---------------------------------------+ | Name of executable +---------------------------------------*/ if ( !strcmp(tmp, "DESIGNER_BITMAP") || !strcmp(tmp, "designer_bitmap")) *entry_fnp = rw2srb; else if ( !strcmp(tmp, "RUNTIME_BITMAP") || !strcmp(tmp, "runtime_bitmap")) *entry_fnp = rw2rrb; else if ( !strcmp(tmp, "RUNTIME_CM") || !strcmp(tmp, "runtime_cm")) *entry_fnp = rw2run; else return 1; *cmd_linep = tmp + strlen(tmp) + 1; return 0; }