// // Copyright (C) 2004-2005 David Essex, Rildo Pragana. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this software; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // Boston, MA 02111-1307 USA // // HTCOBRUN is a program to load and run TinyCOBOL modules (shared-libraries) // // This source is derived from a posting on the OpenCOBOL mailing-list by Roger While. // #include #include "htcoblib.h" int main (int argc, char **argv) { int r; int (*func)(); char modname[255], *argn[64]; struct fld_desc fds; if (argc < 2) { fprintf(stderr, "ERROR: Module parameter not specified\n"); r = 1; } else { if (argc > 65) { fprintf(stderr, "ERROR: Number of parameter specified is %d, max is 64\n"); r = 2; } else { for (r = 1; r < argc; r++) { argn[r - 1] = argv[r]; } tcob_init(argc - 1, argn); strcpy(modname, argv[1]); fds.len = strlen(argv[1]); func = tcob_resolve_subr(&fds, modname, 0); if (func == NULL) { fprintf(stderr, "ERROR: Failed to resolve module \'%s\'\n", modname); r = 3; } else { r = func(); // If it returns then a 'STOP RUN" was not executed, // and the run-time elements need to be cleaned. tcob_stop_run(); } } } return r; }