home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / distributed-c-2.1 / part09 < prev    next >
Text File  |  1993-12-22  |  91KB  |  2,406 lines

  1. Newsgroups: comp.sources.unix
  2. From: pleierc@informatik.tu-muenchen.de (Christoph Pleier)
  3. Subject: v27i183: distributed-c-2.1 - Distributed C Development Environment, V2.1, Part09/18
  4. References: <1.756634932.28500@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: pleierc@informatik.tu-muenchen.de (Christoph Pleier)
  9. Posting-Number: Volume 27, Issue 183
  10. Archive-Name: distributed-c-2.1/part09
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 9 (of 18)."
  19. # Contents:  dcanalyse/dcanalyse.dc dcc/code_others.c dcc/code_select.c
  20. #   dcc/symb_general.c dcinstall/Prepare.c examples/config/system.WAN
  21. #   lib/control.c
  22. # Wrapped by vixie@gw.home.vix.com on Thu Dec 23 00:12:01 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'dcanalyse/dcanalyse.dc' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'dcanalyse/dcanalyse.dc'\"
  26. else
  27. echo shar: Extracting \"'dcanalyse/dcanalyse.dc'\" \(11121 characters\)
  28. sed "s/^X//" >'dcanalyse/dcanalyse.dc' <<'END_OF_FILE'
  29. X/***************************************************************************
  30. X *                                                                         *
  31. X * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  32. X * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  33. X * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  34. X * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  35. X * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  36. X *                                                                         *
  37. X *              A compiler for distributed programming with C              *
  38. X *                                                                         *
  39. X *                         d c a n a l y s e . d c                         *
  40. X *                                                                         *
  41. X *                            Package : System Analyser                    *
  42. X *                            Version : 1.0                                *
  43. X *                       CreationDate : 05.03.92                           *
  44. X *                         LastUpDate : 13.03.92                           *
  45. X *                                                                         *
  46. X * The Distributed C source code containing all process definitions needed *
  47. X * for building the system analyser.                                       *
  48. X *                                                                         *
  49. X *                 Copyright (C) 1992 by Christoph Pleier                  *
  50. X *                          All rights reserved!                           *
  51. X ***************************************************************************/
  52. X
  53. X/*
  54. X * This file is part of the Distributed C Development Environment (DCDE).
  55. X * DCDE is free software; you can redistribute it and/or modify
  56. X * it under the terms written in the README-file. 
  57. X * DCDE is distributed in the hope that it will be useful,
  58. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  59. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  60. X * See the file README for more details.
  61. X */
  62. X
  63. X#include <stdio.h>
  64. X#undef stdin
  65. X#undef stdout
  66. X#undef stderr
  67. X#include "cfgparsers.h"
  68. X#include "analyse.h"
  69. X#define DCANALYSE
  70. X#include "version.h"
  71. X
  72. X/****************************************************************************
  73. X *         name : tester                                                    *
  74. X *         type : process specification                                     *
  75. X *   returntype : none                                                      *
  76. X *   parameters : none                                                      *
  77. X *  description : Specification of the process tester which will be started *
  78. X *                during testing.                                           *
  79. X ****************************************************************************/
  80. Xprocess spec tester()
  81. X{
  82. X    /* receive and send data */
  83. X    trans struct trans_data_t TransmitData(struct trans_data_t data);
  84. X}
  85. X
  86. X/****************************************************************************
  87. X *         name : measure                                                   *
  88. X *         type : process specification                                     *
  89. X *   returntype : none                                                      *
  90. X *   parameters : verbose, trial_num, hosts                                 *
  91. X *  description : Specification of the process measure which will be started*
  92. X *                at each host to perform the measuring.                    *
  93. X ****************************************************************************/
  94. Xprocess spec measure(int verbose, int num)
  95. X{
  96. X    /* Get an order */
  97. X    trans int PutOrder(struct order_t order_p);
  98. X
  99. X    /* Send back avarage results */
  100. X    trans struct order_t GetResult();
  101. X}
  102. X
  103. X/****************************************************************************
  104. X *         name : tester                                                    *
  105. X *         type : process definition                                        *
  106. X *   returntype : none                                                      *
  107. X *   parameters : none                                                      *
  108. X *  description : Definition of the body of the process tester.             *
  109. X ****************************************************************************/
  110. Xprocess body tester()
  111. X{
  112. X    int i;
  113. X
  114. X    for(i = 1; i <= COMMUNICNUM; i++) {
  115. X        accept TransmitData(data) {
  116. X        treturn(data);
  117. X        }
  118. X    }
  119. X
  120. X    exit(0);
  121. X} /* process body tester */
  122. X
  123. X/****************************************************************************
  124. X *         name : measure                                                   *
  125. X *         type : process definition                                        *
  126. X *   returntype : none                                                      *
  127. X *   parameters : none                                                      *
  128. X *  description : Definition of the body of the process measure.            *
  129. X ****************************************************************************/
  130. Xprocess body measure(verbose, num, hosts)
  131. X{
  132. X    int i, j; 
  133. X    long start, crea_time, crea_sum_time, comm_time, comm_sum_time;
  134. X    struct order_t order;
  135. X    struct trans_data_t c_param, c_result;
  136. X    process tester t_pdescr;
  137. X
  138. X
  139. X    while(1) {
  140. X
  141. X        accept PutOrder(order) {
  142. X            order = order_p;
  143. X        }
  144. X
  145. X    if (order.code == DO_TERMINATE)
  146. X        exit(0);
  147. X
  148. X    crea_sum_time = comm_sum_time = 0;
  149. X
  150. X        for(i = 1; i<= num; i++) {
  151. X
  152. X            start = time(NULL);
  153. X        if (verbose) {
  154. X            printf("    [%2d] %12s: ", i, order.hostname); 
  155. X        fflush(stdout);
  156. X        }
  157. X            t_pdescr = create tester() at host(order.hostname);
  158. X            crea_time = time(NULL) - start;
  159. X        crea_sum_time += crea_time;
  160. X            if (verbose) {
  161. X                printf("creation: %2d s", crea_time);
  162. X        fflush(stdout);
  163. X            }
  164. X
  165. X            start = time(NULL);
  166. X            for(j = 1; j <= COMMUNICNUM; j++) {
  167. X                c_result = t_pdescr@TransmitData(c_param);
  168. X        }
  169. X            comm_time = time(NULL) - start;
  170. X        comm_sum_time += comm_time;
  171. X            if (verbose) {
  172. X                printf(", communication: %2d s\n", comm_time);
  173. X        fflush(stdout);
  174. X            }
  175. X
  176. X        } /* for(i) */
  177. X
  178. X        order.crea_time = (int) crea_sum_time / num;
  179. X        order.comm_time = (int) comm_sum_time / num;
  180. X
  181. X        accept GetResult() {
  182. X        treturn(order);
  183. X        } /* accept */
  184. X
  185. X    }
  186. X} /* process body measure */
  187. X
  188. X/*
  189. X * global variables of process 'main' 
  190. X */
  191. X
  192. XSYMBTABEL *symbtab, 
  193. X          *last_symb;
  194. Xint        append, 
  195. X           verbose, 
  196. X           alltargets,
  197. X           no_measure,
  198. X           trial_num;
  199. Xchar      *outputfilename, 
  200. X           cfgfilename[200];
  201. Xstruct targetlist_t *first_target, *last_target;
  202. X
  203. X/****************************************************************************
  204. X *         name : main                                                      *
  205. X *         type : function definition                                       *
  206. X *   returntype : int                                                       *
  207. X *   parameters : none                                                      *
  208. X *  description : Definition of the main function building the main program.*
  209. X ****************************************************************************/
  210. Xmain(argc, argv)
  211. Xint   argc;
  212. Xchar *argv[];
  213. X{
  214. X    int i, flag;
  215. X    struct order_t order;
  216. X    FILE *outputfp;
  217. X    SYMBTABEL *symbol, *symbol2;
  218. X    struct targetlist_t *act_target;
  219. X    process measure pdescr;
  220. X
  221. X    /* display start message */
  222. X    fprintf(stderr, "%s\n%s\n%s\n\n", progname, version, copyright);
  223. X
  224. X    /* some initializations */
  225. X    cfgfilename[0] = 0;
  226. X    append = verbose = alltargets = no_measure = FALSE;
  227. X    trial_num = 1;
  228. X    outputfilename = NULL;
  229. X    first_target = last_target = NULL;
  230. X
  231. X    /* is there any job? */
  232. X    if (argc == 1) {
  233. X    fputs("Error: nothing to do\n\n", stderr);
  234. X    DisplayUsage();
  235. X    exit(ERROR);
  236. X    }
  237. X
  238. X    /* parse command line */
  239. X    if (ParseOptions(argc, argv)) {
  240. X        DisplayUsage();
  241. X        exit(ERROR);
  242. X    }
  243. X
  244. X    /* interpret system configuration file */
  245. X    printf("Parsing system configuration file  - \"%s\"\n", cfgfilename);
  246. X    if (!(yyin = fopen(cfgfilename, "r"))) {
  247. X        fprintf(stderr, "Error: can't open system configuration file \"%s\"\n",
  248. X            cfgfilename);
  249. X        exit(ERROR);
  250. X    } else {
  251. X        (void) yyparse();
  252. X        (void) close(yyin);
  253. X    }
  254. X
  255. X    if (append && outputfilename) {
  256. X        fprintf(stderr, "Error: don't know where to write results to!\n");
  257. X    fprintf(stderr, "       option '-append' and an output file specified!\n");
  258. X        exit(ERROR);
  259. X    }
  260. X
  261. X    if (!append && !outputfilename)
  262. X    outputfp = stdout;
  263. X
  264. X    if (append) {
  265. X    if (!(outputfp = fopen(cfgfilename, "a+"))) {
  266. X            fprintf(stderr, "Error: can't open system configuration file \"%s\" for appending\n",
  267. X                cfgfilename);
  268. X            exit(ERROR);
  269. X    }
  270. X    } 
  271. X
  272. X    if (outputfilename) {
  273. X    if (!(outputfp = fopen(outputfilename, "w"))) {
  274. X            fprintf(stderr, "Error: can't open output file \"%s\"\n", outputfilename);
  275. X            exit(ERROR);
  276. X    }
  277. X    }
  278. X
  279. X    fprintf(outputfp, "\n# ----------------------------------------------------------------------------\n"),
  280. X    fprintf(outputfp, "# cost informations generated by dcanalyse\n\n");
  281. X    fprintf(outputfp, "costs informations {\n\n");
  282. X
  283. X    /* perform measuring */
  284. X    for(symbol = symbtab; symbol; symbol = symbol->next) {
  285. X
  286. X    if (symbol->type != S_HOST)
  287. X        continue;
  288. X
  289. X    if (!alltargets) {
  290. X        flag = FALSE;
  291. X        for(act_target = first_target; act_target; act_target = act_target->next) {
  292. X        if (!strcmp(act_target->hostname, symbol->name)) {
  293. X            flag = TRUE;
  294. X            break; 
  295. X        }
  296. X        }
  297. X        if (!flag)
  298. X        continue;
  299. X    }
  300. X
  301. X    if (!no_measure)
  302. X        pdescr = create measure(verbose, trial_num) at host(symbol->name);
  303. X
  304. X        for(symbol2 = symbtab; symbol2; symbol2 = symbol2->next) {
  305. X
  306. X        if (symbol2->type != S_HOST)
  307. X            continue;
  308. X
  309. X        printf("\nMeasuring %s -> %s\n", symbol->name, symbol2->name);
  310. X        fflush(stdout);
  311. X
  312. X        if (!no_measure) {
  313. X            order.code = DO_MEASURING;
  314. X            strcpy(order.hostname, symbol2->name);
  315. X            pdescr@PutOrder(order);
  316. X
  317. X            order = pdescr@GetResult();
  318. X    
  319. X            if (verbose) {
  320. X            printf("    Average result: creation : %d s, communication: %d s\n",
  321. X                order.crea_time, order.comm_time);
  322. X            fflush(stdout);
  323. X            }
  324. X
  325. X            fprintf(outputfp, "    %15s -> %15s: %d, %d\n",
  326. X            symbol->name, symbol2->name, order.crea_time, order.comm_time);
  327. X        } else {
  328. X        fprintf(outputfp, "    %15s -> %15s: %d, %d\n",
  329. X            symbol->name, symbol2->name, 5, 10);
  330. X        }
  331. X
  332. X        fflush(outputfp);
  333. X    
  334. X        } /* for(symbol2) */
  335. X
  336. X    if (!no_measure) {
  337. X            order.code = DO_TERMINATE;
  338. X            order.hostname[0] = 0;
  339. X            pdescr@PutOrder(order);
  340. X    }
  341. X
  342. X    fputs("\n", outputfp);
  343. X
  344. X    } /* for(symbol) */
  345. X
  346. X    fprintf(outputfp, "}\n");
  347. X    fclose(outputfp);
  348. X
  349. X    exit(OK);
  350. X} /* main */
  351. END_OF_FILE
  352. if test 11121 -ne `wc -c <'dcanalyse/dcanalyse.dc'`; then
  353.     echo shar: \"'dcanalyse/dcanalyse.dc'\" unpacked with wrong size!
  354. fi
  355. # end of 'dcanalyse/dcanalyse.dc'
  356. fi
  357. if test -f 'dcc/code_others.c' -a "${1}" != "-c" ; then 
  358.   echo shar: Will not clobber existing file \"'dcc/code_others.c'\"
  359. else
  360. echo shar: Extracting \"'dcc/code_others.c'\" \(12215 characters\)
  361. sed "s/^X//" >'dcc/code_others.c' <<'END_OF_FILE'
  362. X/***************************************************************************
  363. X *                                                                         *
  364. X * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  365. X * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  366. X * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  367. X * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  368. X * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  369. X *                                                                         *
  370. X *              A compiler for distributed programming with C              *
  371. X *                                                                         *
  372. X *                        c o d e _ o t h e r s . c                        *
  373. X *                                                                         *
  374. X *                            Package : Compiler                           *
  375. X *                            Version : 1.1                                *
  376. X *                       CreationDate : 26.07.90                           *
  377. X *                         LastUpDate : 20.12.93                           *
  378. X *                                                                         *
  379. X * The functions to generate the header of the main program and to build   *
  380. X * the code of function definitions.                                       *
  381. X *                                                                         *
  382. X *                  Portions Copyright 1990 Franz Distler                  *
  383. X *               Copyright (C) 1990-1994 by Christoph Pleier               *
  384. X *                          All rights reserved!                           *
  385. X ***************************************************************************/
  386. X
  387. X/*
  388. X * This file is part of the Distributed C Development Environment (DCDE).
  389. X * DCDE is free software; you can redistribute it and/or modify
  390. X * it under the terms written in the README-file. 
  391. X * DCDE is distributed in the hope that it will be useful,
  392. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  393. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  394. X * See the file README for more details.
  395. X */
  396. X
  397. X#include <stdio.h>
  398. X#include <sys/types.h>
  399. X#include "config.h"
  400. X#include "extern.h"
  401. X#include "functions.h"
  402. X#include "com_Errno.h"
  403. X#include "timeout.h"
  404. X
  405. X/******************************************************************************
  406. X * gencode_function()                                                         *
  407. X *                                                                            *
  408. X * Generates special code for the function main of the main process (first    *
  409. X * started process) or writes code for a function definition to 'funcfile'.   *
  410. X *                                                                            *
  411. X * Return values: pointer to generated code string upon success /             *
  412. X *                NULL during error handling                                  *
  413. X ******************************************************************************/
  414. Xchar *
  415. Xgencode_function(decl_spec, attr, decl_list, comp_stat)
  416. XDS_ATTR  *decl_spec;
  417. XD_ATTR   *attr;
  418. Xchar     *decl_list;
  419. XCOMPATTR *comp_stat;
  420. X{
  421. X    register int i, length;
  422. X    register char *cs;
  423. X    register struct include_list *inclptr;
  424. X    DD_ATTR *dd_attr;
  425. X    SYMBTABEL *symbol, *sptr, *actions;
  426. X
  427. X    if (errflag || !attr || !comp_stat) /* error handling! */
  428. X    return(NULL);
  429. X#ifdef CODEDEBUG
  430. X    fputs("[code] ***** gencode_function():\n", debugfile);
  431. X#endif /* CODEDEBUG /**/
  432. X
  433. X    symbol = NULL;
  434. X    for(dd_attr = attr->direct_decl; dd_attr; ) {
  435. X    switch(dd_attr->type) {
  436. X    case DD_ATTR_IDENT:
  437. X            symbol = dd_attr->ident;
  438. X        dd_attr = NULL; /* leave loop! */
  439. X        break;
  440. X    case DD_ATTR_BRACED:
  441. X        dd_attr = dd_attr->info.declarator->direct_decl;
  442. X        break;
  443. X    case DD_ATTR_ARRAY:
  444. X    case DD_ATTR_FUNC:
  445. X        dd_attr = dd_attr->info.comp.direct_decl;
  446. X        break;
  447. X    default:
  448. X        Panic("unknown DD_ATTR type in make_function()");
  449. X    } /* switch */
  450. X    }
  451. X    if (!symbol)
  452. X    Panic("identifier of function definition not found");
  453. X
  454. X    if (!strcmp("main", symbol->name)) {
  455. X
  456. X    mainflag = TRUE;
  457. X
  458. X        if (infoflag) {
  459. X        printf("%s generating code for function 'main'\n", infoprefix);
  460. X        fflush(stdout);
  461. X        }
  462. X        /* create output file */
  463. X        strcpy(outputfilename, filenameprefix);
  464. X        length = MAXFILENAMELEN - strlen(MAINFILEEXT);
  465. X        if (strlen(filenameprefix) <= length)
  466. X        strcat(outputfilename, MAINFILEEXT);
  467. X        else
  468. X            strcpy(&outputfilename[length], MAINFILEEXT);
  469. X        if (!(outfile = fopen(outputfilename, "w"))) {
  470. X        fprintf(stderr, "Error: impossible to open output file '%s'\n",
  471. X            outputfilename);
  472. X        exit(EXIT_FOPEN);
  473. X        }
  474. X
  475. X        fprintf(outfile, "/* main */\n\n");
  476. X        fputs("/*\n", outfile);
  477. X        for(i = 0; *headerstr[i]; ++i)
  478. X        fprintf(outfile, " * %s\n", headerstr[i]);
  479. X        fputs(" */\n\n", outfile);
  480. X        fprintf(outfile, "#include \"%s\"\n\n", inclfilename);
  481. X
  482. X    cs = strmalloc("int              Errno;\n");
  483. X#ifdef UNICOS
  484. X    cs = Strcat(cs, "int              errno;\n");
  485. X#endif
  486. X#ifdef iPSC
  487. X    cs = Strcat(cs, "long            _pidcount;\n");
  488. X#endif /* iPSC /**/
  489. X    cs = Strcat(cs, "char            *_programname;\n");
  490. X    cs = Strcat(cs, "char            *_processname;\n");
  491. X    cs = Strcat(cs, "char             _processprefix[80];\n");
  492. X    cs = Strcat(cs, "DCC_PARAMS       dcc_par;\n");
  493. X    cs = Strcat(cs, "DCC_RESULTS      dcc_res;\n");
  494. X    cs = Strcat(cs, "PORTDESCR        _own_port;\n");
  495. X    cs = Strcat(cs, "PORTDESCR        _creator_port; /* unused but needed! */\n");
  496. X    cs = Strcat(cs, "PORTDESCR        _admin_port;\n");
  497. X    cs = Strcat(cs, "CONNECTIONDESCR  _con_port;\n");
  498. X#ifdef HETEROGENEOUS
  499. X    cs = Strcat(cs, "XDR              encode_xdrs;\n");
  500. X    cs = Strcat(cs, "XDR              decode_xdrs;\n");
  501. X    cs = Strcat(cs, "XDR              _xdr_encode_size_xdrs;\n");
  502. X    cs = Strcat(cs, "XDR              _xdr_decode_size_xdrs;\n");
  503. X    cs = Strcat(cs, "char            *_dcc_buf;\n");
  504. X    cs = Strcat(cs, "unsigned long    _dcc_buf_size;\n");
  505. X    cs = Strcat(cs, "char            *_xdr_size_buf;\n");
  506. X#endif /* HETEROGENEOUS /**/
  507. X    cs = Strcat(cs, "\n");
  508. X    if (decl_spec)
  509. X        cs = convert_ds_to_string(cs, decl_spec);
  510. X
  511. X    /* Hier fehlt noch der environment parameter: argc, argv, envp ! */
  512. X    cs = Strcatmany(cs, 7, "\nmain(argc, argv, envp)\n", 
  513. X        "int argc;\nchar *argv[];\nchar *envp[];\n{\n",
  514. X        comp_stat->decls, "PROCESSDESCR admin_pdescr;\n",
  515. X        "int _opt;\nchar *_configfilename;\n",
  516. X        "extern int optind;\nextern int opterr;\n",
  517. X        "extern char *optarg;\n\n");
  518. X
  519. X    cs = Strcat(cs, "/* initialize program and process name */\n");
  520. X    cs = Strcatmany(cs, 3, "_programname = \"", inputfilename, "\";\n");
  521. X    cs = Strcat(cs, "_processname = \"main process\";\n");
  522. X    cs = Strcat(cs, "_set_processprefix();\n");
  523. X#ifdef iPSC
  524. X    cs = Strcat(cs, "_pidcount    = mynode() * 1000;\n");
  525. X#endif /* iPSC /**/
  526. X
  527. X    cs = Strcat(cs, "\t/* control signals */\n");
  528. X    cs = Strcat(cs, "\t_set_signals();\n");
  529. X
  530. X#ifdef HETEROGENEOUS
  531. X     if (determine_dcc_buf_size) {
  532. X         /* This version of code determines the buffer size to allocate for
  533. X          * subsequent encoding/decoding actions. The result is the size
  534. X          * of the biggest communication structure multiplied by 4.
  535. X          * But the size needed to encode/decode dynamic structures like 
  536. X          * trees or list can not be predicted so errors during encoding or
  537. X          * decoding will be the consequence if the determined buffer is 
  538. X          *too little.
  539. X          */
  540. X             cs = Strcat(cs, "\t/* determine size of encode/decode buffer */\n");
  541. X         cs = Strcat(cs, "\t_dcc_buf_size = 1000;\n");
  542. X             cs = Strcat(cs, "\tDCCBUFRESIZE(PROCESSDATA);\n");
  543. X             for(sptr = symbtab.PstTab[0]; sptr; sptr = sptr->PstNext) {
  544. X                 if (sptr->type != PROCESSDECL)
  545. X                     continue;
  546. X                 if (sptr->info.process.FirstParam) {
  547. X                     cs = Strcatmany(cs, 4, "\tDCCBUFRESIZE(", 
  548. X                sptr->info.process.upiname, POSTFIXSPECPAR, ");\n");
  549. X                }
  550. X                for(actions=sptr->info.process.FirstTrans; actions; actions=actions->info.trans.NextTrans) {
  551. X                    if (actions->info.trans.FirstParam) {
  552. X                        cs = Strcatmany(cs, 4, "\tDCCBUFRESIZE(", actions->info.trans.uptiname, 
  553. X                POSTFIXTRANSPAR, ");\n");
  554. X                    }
  555. X                    cs = Strcatmany(cs, 4, "\tDCCBUFRESIZE(", actions->info.trans.uptiname, 
  556. X                POSTFIXTRANSRES, ");\n");
  557. X                } /* for */
  558. X            } /* for */
  559. X    } else {
  560. X        /* This version of code uses a fixed size to allocate for
  561. X         * the encode/decode buffer!
  562. X         */
  563. X            cs = Strcat(cs, "\t/* size of encode/decode buffer */\n");
  564. X        cs = Strcatmany(cs, 3, "\t_dcc_buf_size = ", encode_decode_buf_size, ";\n");
  565. X    }
  566. X        cs = Strcat(cs, "\t/* allocate heap space for encode/decode buffer */\n");
  567. X        cs = Strcat(cs, "\tif (_allocate_encode_decode_buffer(XDRRESIZE(_dcc_buf_size)))\n");
  568. X        cs = Strcat(cs, "\t\t_RuntimeError(\"allocating heap space for encode/decode buffer\");\n");
  569. X#endif /* HETEROGENEOUS /**/
  570. X
  571. X    cs = Strcat(cs, "/* create own port */\n");
  572. X    cs = Strcat(cs, "if (_create_port(&_own_port))\n");
  573. X    cs = Strcat(cs, "_RuntimeError(\"creating own_port\");\n");
  574. X#ifdef iPSC
  575. X    cs = Strcat(cs, "init_port(&_admin_port, ADMIN_NODE, ADMIN_PID);\n");
  576. X    cs = Strcat(cs, "if (_send_filenname_to_admin(dcc_configfilename))\n");
  577. X    cs = Strcat(cs, "_RuntimeError(\"sending configfilename\");\n");
  578. X    cs = Strcat(cs, "if (_notify_admin_process(NOTIFY_START))\n");
  579. X    cs = Strcat(cs, "_RuntimeError(\"notifying administration process\");\n");
  580. X#else
  581. X    cs = Strcat(cs, "/* create administration process */\n");
  582. X    cs = Strcat(cs, "_configfilename = \"\";\n");
  583. X    cs = Strcat(cs, "{\nint i;\n");
  584. X    cs = Strcat(cs, "for(i=1; i<argc; i++) {\n");
  585. X    cs = Strcat(cs, "if (!strcmp(argv[i], \"-cfgfile\")) {\n");
  586. X    cs = Strcat(cs, "_configfilename = argv[++i];\n");
  587. X    cs = Strcat(cs, "break;\n");
  588. X    cs = Strcat(cs, "}\n}\n}\n");
  589. X    cs = Strcat(cs, "if (_create_dcadmin(\"");
  590. X    cs = Strcat(cs, ADMINPATH);
  591. X    cs = Strcat(cs, "\", _configfilename))\n");
  592. X    cs = Strcat(cs, "_RuntimeError(\"creating administration process\");\n");
  593. X#endif /* iPSC /**/
  594. X    cs = Strcat(cs, comp_stat->stats);
  595. X    cs = Strcat(cs, "exit(0);\n");
  596. X    cs = Strcat(cs, "\n}\n");
  597. X    } else {
  598. X
  599. X        if (infoflag) {
  600. X        printf("%s generating code for function '%s'\n",
  601. X            infoprefix, symbol->name);
  602. X        fflush(stdout);
  603. X        }
  604. X
  605. X    if (!funcflag) {
  606. X        /* create file for functions */
  607. X            (void) strcpy(funcfilename, filenameprefix);
  608. X            length = MAXFILENAMELEN - strlen(FUNCFILEEXT);
  609. X            if (strlen(filenameprefix) <= length)
  610. X            (void) strcat(funcfilename, FUNCFILEEXT);
  611. X            else
  612. X               (void) strcpy(&funcfilename[length], FUNCFILEEXT);
  613. X            if (!(funcfile = fopen(funcfilename, "w"))) {
  614. X            fprintf(stderr,"Error: impossible to open file for functions '%s'\n",
  615. X                funcfilename);
  616. X            exit(EXIT_FOPEN);
  617. X            }
  618. X            fprintf(funcfile, "/* %s */\n\n", funcfilename);
  619. X            fputs("/*\n", funcfile);
  620. X            for(i = 0; *headerstr[i]; ++i)
  621. X                fprintf(funcfile, " * %s\n", headerstr[i]);
  622. X            fputs(" */\n\n", funcfile);
  623. X        fprintf(funcfile, "#include \"%s\"\n\n", inclfilename);
  624. X        funcflag = 1;
  625. X    }
  626. X
  627. X    /* determine the return type of the function; if the return type
  628. X     * equals a string of length zero, don't generate code for this
  629. X     * function!
  630. X     */
  631. X    *convert_buffer = 0;
  632. X    convert_buffer = convert_ds_to_string(convert_buffer, decl_spec);
  633. X    if (*convert_buffer) {
  634. X            fprintf(funcfile,"\n%s\n", convert_buffer);
  635. X        fnextstr = Strcatmany(fnextstr, 2, "extern ", convert_buffer);
  636. X        *convert_buffer = 0;
  637. X        convert_buffer = convert_d_to_string(convert_buffer, attr);
  638. X            fprintf(funcfile,"%s\n%s{\n%s\n%s\n}\n", 
  639. X            convert_buffer, decl_list, comp_stat->decls, comp_stat->stats);
  640. X        fnextstr = Strcatmany(fnextstr, 2, convert_buffer, "();\n");
  641. X    }
  642. X
  643. X        cs = strmalloc("");
  644. X    }
  645. X
  646. X    return(cs);
  647. X} /* gencode_function */
  648. END_OF_FILE
  649. if test 12215 -ne `wc -c <'dcc/code_others.c'`; then
  650.     echo shar: \"'dcc/code_others.c'\" unpacked with wrong size!
  651. fi
  652. # end of 'dcc/code_others.c'
  653. fi
  654. if test -f 'dcc/code_select.c' -a "${1}" != "-c" ; then 
  655.   echo shar: Will not clobber existing file \"'dcc/code_select.c'\"
  656. else
  657. echo shar: Extracting \"'dcc/code_select.c'\" \(12482 characters\)
  658. sed "s/^X//" >'dcc/code_select.c' <<'END_OF_FILE'
  659. X/***************************************************************************
  660. X *                                                                         *
  661. X * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  662. X * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  663. X * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  664. X * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  665. X * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  666. X *                                                                         *
  667. X *              A compiler for distributed programming with C              *
  668. X *                                                                         *
  669. X *                        c o d e _ s e l e c t . c                        *
  670. X *                                                                         *
  671. X *                            Package : Compiler                           *
  672. X *                            Version : 1.1                                *
  673. X *                       CreationDate : 04.09.90                           *
  674. X *                         LastUpDate : 12.03.92                           *
  675. X *                                                                         *
  676. X * The function 'generate_select_code' to build the complete code for a    *
  677. X * select statement.                                                       *
  678. X *                                                                         *
  679. X *               Copyright (C) 1990-1994 by Christoph Pleier               *
  680. X *                          All rights reserved!                           *
  681. X ***************************************************************************/
  682. X
  683. X/*
  684. X * This file is part of the Distributed C Development Environment (DCDE).
  685. X * DCDE is free software; you can redistribute it and/or modify
  686. X * it under the terms written in the README-file. 
  687. X * DCDE is distributed in the hope that it will be useful,
  688. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  689. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  690. X * See the file README for more details.
  691. X */
  692. X
  693. X#include <stdio.h>
  694. X#include <sys/types.h>
  695. X#ifdef HETEROGENEOUS
  696. X# include <rpc/rpc.h>
  697. X#endif
  698. X#include "config.h"
  699. X#include "extern.h"
  700. X#include "functions.h"
  701. X#include "com_Errno.h"
  702. X#include "timeout.h"
  703. X#include "ipc.h"
  704. X#include "dcc.h"
  705. X
  706. X/******************************************************************************
  707. X * generate_select_code()                                                     *
  708. X *                                                                            *
  709. X * Generates the code for a select statement. There are three different types *
  710. X * of select statements. Select statements with only accept alternatives,     *
  711. X * only immediate alternatives and both accept and immediate alternatives.    *
  712. X * NOTE: The last type was not yet implemented!.                              *
  713. X *                                                                            *
  714. X * Return values: pointer to generated code string upon success /             *
  715. X *                NULL upon error or during error handling                    *
  716. X ******************************************************************************/
  717. Xchar *
  718. Xgenerate_select_code(attr)
  719. XSELECTATTR *attr;
  720. X{
  721. X    int            i,
  722. X                   acceptflag,
  723. X                   termntflag,
  724. X                   immedtflag;
  725. X    char           tmpstr[20],
  726. X                   tmpstr1[20], 
  727. X                   tmpstr2[20],
  728. X                  *ptiname,
  729. X                  *uptiname,
  730. X                  *decls,
  731. X                  *stats;
  732. X    register char *cmd;
  733. X    SELECTATTR    *hptr;
  734. X    SYMBTABEL     *symbol,
  735. X                  *params;
  736. X
  737. X    if (errflag || attr->type == ERROR) /* error handling! */
  738. X        return(NULL);
  739. X#ifdef CODEDEBUG
  740. X    fputs("[code] ***** generate_select_code():\n", debugfile);
  741. X    fprintf(debugfile, "[code]       params: attr = %d\n", attr);
  742. X    fputs("[code]       the alternatives are:\n", debugfile);
  743. X    for(hptr = attr, i=1; hptr; hptr = hptr->next, i++) {
  744. X        fprintf(debugfile, "[code] alternative %d:\n", i);
  745. X    fprintf(debugfile, "[code]     guard = \"%s\"\n", hptr->guard);
  746. X    fprintf(debugfile, "[code]     type  = '");
  747. X    switch(hptr->type) {
  748. X    case ALT_ACCEPT:
  749. X        fprintf(debugfile, "accept");
  750. X        break;
  751. X    case ALT_TERMINATE:
  752. X        fprintf(debugfile, "terminate");
  753. X        break;
  754. X    case ALT_IMMEDIATE:
  755. X        fprintf(debugfile, "immediate");
  756. X        break;
  757. X    }
  758. X    fprintf(debugfile, " alternative'\n");
  759. X    } /* for */
  760. X#endif  /* CODEDEBUG /**/
  761. X
  762. X    acceptflag = termntflag = immedtflag = FALSE;
  763. X
  764. X    for(hptr = attr; hptr; hptr = hptr->next) {
  765. X    switch(hptr->type) {
  766. X    case ALT_ACCEPT:
  767. X        acceptflag = TRUE;
  768. X        break;
  769. X    case ALT_TERMINATE:
  770. X        termntflag = TRUE;
  771. X        break;
  772. X    case ALT_IMMEDIATE:
  773. X        immedtflag = TRUE;
  774. X        break;
  775. X    } /* switch */
  776. X    }
  777. X
  778. X    cmd = strmalloc("");
  779. X
  780. X    if (termntflag)
  781. X    cmd = Strcat(cmd, "_notify_admin_process(NOTIFY_ACCORTER_ON);\n");
  782. X
  783. X    cmd = Strcat(cmd, "while(1) {\n");
  784. X
  785. X    if (acceptflag && !immedtflag) {
  786. X    /* case 1:
  787. X     * only accept alternatives
  788. X     */
  789. X
  790. X    cmd = Strcat(cmd, "char *request;\n");
  791. X    cmd = Strcat(cmd, "static TRANSDATA transdata;\n\n");
  792. X
  793. X    cmd = Strcat(cmd, "/* get connection */\n");
  794. X    sprintf(tmpstr2, "%d", SELECTCONTIME);
  795. X    cmd = Strcatmany(cmd, 3, "if (_accept_connection(&_con_port, &_own_port, ",
  796. X        tmpstr2, ")) {\n");
  797. X    cmd = Strcat(cmd, "if (Errno == ETIMEOUT)\n");
  798. X    cmd = Strcat(cmd, "\tErrno = ETSACCEPTCON;\n");
  799. X    cmd = Strcat(cmd, "_RuntimeError(\"accepting connections in select statement\");\n}\n");
  800. X    cmd = Strcat(cmd, "/* check connection type */\n");
  801. X    cmd = Strcat(cmd, "if (_receive_connection_type_or_answer() != TRANSACTION_CONNECTION) {\n");
  802. X    cmd = Strcat(cmd, "if (_send_connection_type_or_answer(ABORT_CONNECTION))\n");
  803. X    cmd = Strcat(cmd, "_RuntimeError(\"sending connection answer\");\n");
  804. X    cmd = Strcat(cmd, "if (_close_connection(&_con_port))\n");
  805. X    cmd = Strcat(cmd, "_RuntimeError(\"closing connection\");\n");
  806. X    cmd = Strcat(cmd, "continue;\n");
  807. X    cmd = Strcat(cmd, "} else {\n");
  808. X    cmd = Strcat(cmd, "if (_send_connection_type_or_answer(ACCEPT_CONNECTION))\n");
  809. X    cmd = Strcat(cmd, "_RuntimeError(\"sending connection answer\");\n");
  810. X    cmd = Strcat(cmd, "}\n");
  811. X    cmd = Strcat(cmd, "/* get transaction request */\n");
  812. X    sprintf(tmpstr2, "%d", SELECTREQTIME);
  813. X    cmd = Strcat(cmd, "if (_recv_data");
  814. X#ifdef HETEROGENEOUS
  815. X    cmd = Strcat(cmd, "_encoded");
  816. X#endif
  817. X    cmd = Strcat(cmd, "(&_con_port, (char *) &transdata, ");
  818. X#if defined(SINGLE) || defined(HOMOGENEOUS)
  819. X    cmd = Strcat(cmd, "sizeof(TRANSDATA), ");
  820. X#else /* HETEROGENEOUS */
  821. X    cmd = Strcat(cmd, "xdr_TRANSDATA, ");
  822. X#endif
  823. X    cmd = Strcatmany(cmd, 2, tmpstr2, ")<0) {\n");
  824. X    cmd = Strcat(cmd, "if (Errno == ETIMEOUT)\n");
  825. X    cmd = Strcat(cmd, "\tErrno = ETSRCVREQUEST;\n");
  826. X    cmd = Strcat(cmd, "_RuntimeError(\"accepting transaction in select statement\");\n");
  827. X    cmd = Strcat(cmd, "}\n");
  828. X    cmd = Strcat(cmd, "request = transdata.request;\n");
  829. X
  830. X        for(hptr = attr, i = 1; hptr; hptr = hptr->next, ++i) {
  831. X        if (hptr->type == ALT_TERMINATE) {
  832. X            cmd = Strcat(cmd, "/* terminate alternative */\n");
  833. X        cmd = Strcat(cmd, "if (!strcmp(request, \"TRANS_TERMINATE\")) {\n");
  834. X        cmd = Strcat(cmd, "if (_close_connection(&_con_port))\n");
  835. X            cmd = Strcat(cmd, "_RuntimeError(\"closing connection\");\n");
  836. X        cmd = Strcat(cmd, "exit(0);\n");
  837. X        cmd = Strcat(cmd, "}\n");
  838. X        continue;
  839. X        }
  840. X
  841. X        symbol      = hptr->accept_attr->transaction;
  842. X            ptiname     = symbol->info.trans.ptiname,
  843. X            uptiname    = symbol->info.trans.uptiname;
  844. X
  845. X        sprintf(tmpstr1, "%d", i);
  846. X        cmd = Strcatmany(cmd, 3, "/* alternative ", tmpstr1, " */\n");
  847. X        cmd = Strcatmany(cmd, 3, "if (!strcmp(request, \"", uptiname, "\")");
  848. X        if (hptr->guard)
  849. X        cmd = Strcatmany(cmd, 3, " && (", hptr->guard, ")) {\n");
  850. X        else
  851. X        cmd = Strcat(cmd, ") {\n");
  852. X
  853. X        if (symbol->info.trans.FirstParam) {
  854. X        for(params=symbol->info.trans.FirstParam; params; 
  855. X                       params=params->info.varorpar.NextParam) {
  856. X            *convert_buffer = 0;
  857. X            convert_buffer = convert_ds_to_string(convert_buffer, 
  858. X            params->info.varorpar.DataType); 
  859. X                    cmd = Strcatmany(cmd, 3, convert_buffer, params->name, ";\n");
  860. X        }
  861. X        }
  862. X        *convert_buffer = 0;
  863. X        convert_buffer = convert_ds_to_string(convert_buffer, 
  864. X        symbol->info.trans.ReturnType);
  865. X        cmd = Strcatmany(cmd, 2, convert_buffer, "_transaction_result;\n\n");
  866. X
  867. X        cmd = Strcat(cmd, "_SendTransCallReply(TRANS_ACCEPT);\n");
  868. X
  869. X        if (symbol->info.trans.FirstParam) {
  870. X#ifdef HETEROGENEOUS
  871. X            /* We must clear the memory where the received data will be 
  872. X         * stored in, because the xdr routines allocate storage for 
  873. X         * pointers only if the pointer values equal the NULL pointer!!
  874. X          */
  875. X        cmd = Strcat(cmd, "/* clear structure to handle pointers correctly */\n");
  876. X        cmd = Strcatmany(cmd, 6, "bzero(&dcc_par.", ptiname, ", sizeof(",
  877. X            uptiname, POSTFIXTRANSPAR, "));\n");
  878. X#endif
  879. X            cmd = Strcat(cmd, "/* get parameters */\n");
  880. X            sprintf(tmpstr1, "%d", SELECTPARTIME);
  881. X        cmd = Strcat(cmd, "if (_recv_data");
  882. X#ifdef HETEROGENEOUS
  883. X        cmd = Strcat(cmd, "_encoded");
  884. X#endif
  885. X            cmd = Strcatmany(cmd, 2, "(&_con_port, (char *) &dcc_par.", ptiname);
  886. X#if defined(SINGLE) || defined(HOMOGENEOUS)
  887. X            cmd = Strcatmany(cmd, 4, ", sizeof(", uptiname, POSTFIXTRANSPAR, ")");
  888. X#else /* HETEROGENEOUS */
  889. X            cmd = Strcatmany(cmd, 3, ", xdr_", uptiname, POSTFIXTRANSPAR);
  890. X#endif
  891. X            cmd = Strcatmany(cmd, 3, ", ", tmpstr1, ") < 0){\n");
  892. X            cmd = Strcat(cmd,"if (Errno == ETIMEOUT)\nErrno = ETSRCVPARAMS;\n");
  893. X                cmd = Strcat(cmd, "_RuntimeError(\"getting transaction parameters\");\n}\n");
  894. X
  895. X        cmd = Strcat(cmd, "/* initialize parameters */\n");
  896. X        for(params=symbol->info.trans.FirstParam; params; 
  897. X                    params=params->info.varorpar.NextParam)
  898. X            cmd = Strcatmany(cmd, 6, params->name, " = dcc_par.", ptiname, 
  899. X            ".", params->name, ";\n");
  900. X        }
  901. X
  902. X        decls = hptr->accept_attr->comp_attr->decls;
  903. X        stats = hptr->accept_attr->comp_attr->stats;
  904. X            if (*decls != 0 || *stats != 0) {
  905. X                cmd = Strcat(cmd, "/* execute transaction */\n");
  906. X            cmd = Strcatmany(cmd, 5, "{\n", decls, "\n", stats, "\n}\n");
  907. X                sprintf(tmpstr, "tlabel_%d:\n", symbol->info.trans.labnum);
  908. X                cmd = Strcat(cmd, tmpstr);
  909. X        }
  910. X
  911. X            cmd = Strcat(cmd, "/* send result back to caller */\n");
  912. X        cmd = Strcatmany(cmd, 3, "dcc_res.", ptiname, ".result = _transaction_result;\n");
  913. X            cmd = Strcatmany(cmd, 3, "dcc_res.", ptiname, ".Errno = OK;\n");
  914. X            sprintf(tmpstr1, "%d", SELECTRESTIME);
  915. X            cmd = Strcat(cmd, "if (_send_data");
  916. X#ifdef HETEROGENEOUS
  917. X            cmd = Strcat(cmd, "_encoded");
  918. X#endif /* HETEROGENEOUS /**/
  919. X            cmd = Strcatmany(cmd, 2, "(&_con_port, (char *) &dcc_res.", ptiname);
  920. X#if defined(SINGLE) || defined(HOMOGENEOUS)
  921. X            cmd = Strcatmany(cmd, 4, ", sizeof(", uptiname, POSTFIXTRANSRES, ")");
  922. X#else /* HETEROGENEOUS */
  923. X            cmd = Strcatmany(cmd, 3, ", xdr_", uptiname, POSTFIXTRANSRES);
  924. X#endif
  925. X            cmd = Strcatmany(cmd, 3, ", ", tmpstr1, ") < 0) {\n");
  926. X            cmd = Strcat(cmd, "if (Errno == ETIMEOUT)\nErrno = ETASNDRESULT;\n");
  927. X            cmd = Strcat(cmd, "_RuntimeError(\"sending transaction results\");\n}\n");
  928. X
  929. X        cmd = Strcat(cmd, "if (_close_connection(&_con_port))\n");
  930. X            cmd = Strcat(cmd, "_RuntimeError(\"closing connection\");\n");
  931. X
  932. X        cmd = Strcat(cmd, hptr->stats);
  933. X        cmd = Strcat(cmd, "break;\n}\n");
  934. X    } /* for */
  935. X    cmd = Strcat(cmd, "_SendTransCallReply(TRANS_DENIED);\n");
  936. X    cmd = Strcat(cmd, "if (_close_connection(&_con_port))\n");
  937. X        cmd = Strcat(cmd, "_RuntimeError(\"closing connection\");\n");
  938. X    } else if (acceptflag && immedtflag) {
  939. X    /* case 2:
  940. X     * both accept and immediate alternatives
  941. X     */
  942. X    cmd = Strcat(cmd, "this type of select statement is not yet implemented!");
  943. X    } else {
  944. X    /* case 3:
  945. X     * only immediate alternatives
  946. X     */
  947. X        for(hptr = attr; hptr; hptr = hptr->next) {
  948. X        if (hptr->guard)
  949. X        cmd = Strcatmany(cmd, 5, "if (", hptr->guard, ") {\n", 
  950. X            hptr->stats, "break;\n}\n");
  951. X        else
  952. X        cmd = Strcatmany(cmd, 2, hptr->stats, "break;\n");
  953. X    } /* for */
  954. X    }
  955. X
  956. X    cmd = Strcat(cmd, "} /* while */\n");
  957. X
  958. X    if (termntflag) 
  959. X        cmd = Strcat(cmd, "_notify_admin_process(NOTIFY_ACCORTER_OFF);\n");
  960. X
  961. X    return(cmd);
  962. X} /* generate_select_code */
  963. END_OF_FILE
  964. if test 12482 -ne `wc -c <'dcc/code_select.c'`; then
  965.     echo shar: \"'dcc/code_select.c'\" unpacked with wrong size!
  966. fi
  967. # end of 'dcc/code_select.c'
  968. fi
  969. if test -f 'dcc/symb_general.c' -a "${1}" != "-c" ; then 
  970.   echo shar: Will not clobber existing file \"'dcc/symb_general.c'\"
  971. else
  972. echo shar: Extracting \"'dcc/symb_general.c'\" \(12189 characters\)
  973. sed "s/^X//" >'dcc/symb_general.c' <<'END_OF_FILE'
  974. X/***************************************************************************
  975. X *                                                                         *
  976. X * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  977. X * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  978. X * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  979. X * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  980. X * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  981. X *                                                                         *
  982. X *              A compiler for distributed programming with C              *
  983. X *                                                                         *
  984. X *                       s y m b _ g e n e r a l . c                       *
  985. X *                                                                         *
  986. X *                            Package : Compiler                           *
  987. X *                            Version : 2.0                                *
  988. X *                       CreationDate : 01.08.90                           *
  989. X *                         LastUpDate : 08.11.91                           *
  990. X *                                                                         *
  991. X *          The functions used to administrate the symbol table.           *
  992. X *                                                                         *
  993. X *                  Portions Copyright 1990 Franz Distler                  *
  994. X *               Copyright (C) 1990-1994 by Christoph Pleier               *
  995. X *                          All rights reserved!                           *
  996. X ***************************************************************************/
  997. X
  998. X/*
  999. X * This file is part of the Distributed C Development Environment (DCDE).
  1000. X * DCDE is free software; you can redistribute it and/or modify
  1001. X * it under the terms written in the README-file. 
  1002. X * DCDE is distributed in the hope that it will be useful,
  1003. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1004. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  1005. X * See the file README for more details.
  1006. X */
  1007. X
  1008. X#include <stdio.h>
  1009. X#include <ctype.h>
  1010. X#include "config.h"
  1011. X#include "extern.h"
  1012. X#include "functions.h"
  1013. X#include "y.tab.h" 
  1014. X#include "com_Errno.h"
  1015. X
  1016. X/******************************************************************************
  1017. X * strsave()                                                                  *
  1018. X *                                                                            *
  1019. X * Copies 's' to a new allocated main memory block.                           *
  1020. X *                                                                            *
  1021. X * Return values: pointer to saved string upon success / NULL upon error      *
  1022. X ******************************************************************************/
  1023. Xchar *
  1024. Xstrsave(s)
  1025. Xregister char *s;
  1026. X{
  1027. X    register char *cp;
  1028. X
  1029. X    cp = (char *) Malloc(strlen(s)+1);
  1030. X    strcpy(cp, s);
  1031. X    return(cp);
  1032. X} /* strsave */
  1033. X
  1034. X/******************************************************************************
  1035. X * hash()                                                                     *
  1036. X *                                                                            *
  1037. X * Determines to the name 'name' the corresponding hash value.                *
  1038. X *                                                                            *
  1039. X * Return values: corresponding hash value                                    *
  1040. X ******************************************************************************/
  1041. Xint
  1042. Xhash(name)
  1043. Xchar *name;
  1044. X{
  1045. X    register char *p;
  1046. X    register unsigned h=0, g;
  1047. X
  1048. X    for(p = name; *p != '\0'; p = p+1) {
  1049. X    h = (h << 4) + (*p);
  1050. X    if (g = h & 0xf0000000) {
  1051. X        h = h ^ (g >> 24);
  1052. X        h = h ^ g;
  1053. X    }
  1054. X    }
  1055. X#ifdef SYMBDEBUG
  1056. X    fprintf(debugfile, "[symb]       hash(\"%s\") = %d\n", name, h % MAXIDNUM);
  1057. X#endif /* SYMBDEBUG /**/
  1058. X    return(h % MAXIDNUM);
  1059. X} /* hash */
  1060. X
  1061. X/******************************************************************************
  1062. X * init_symbtab()                                                             *
  1063. X *                                                                            *
  1064. X * Initializes the symbol table and the block depth.                          *
  1065. X *                                                                            *
  1066. X * Return values: always OK for success                                       *
  1067. X ******************************************************************************/
  1068. Xint
  1069. Xinit_symbtab()
  1070. X{
  1071. X    register int i;
  1072. X
  1073. X#ifdef SYMBDEBUG
  1074. X    fputs("[symb] ***** init_symbtab():\n", debugfile);
  1075. X#endif /* SYMBDEBUG /**/
  1076. X
  1077. X    blknum = 0;
  1078. X
  1079. X    for(i=0; i < MAXIDNUM; i++)
  1080. X    symbtab.IdTab[i] = (SYMBTABEL *) NULL;
  1081. X
  1082. X    for(i=0; i < MAXPSTNUM; i++)
  1083. X    symbtab.PstTab[i] = (SYMBTABEL *) NULL;
  1084. X
  1085. X    return(OK);
  1086. X} /* init_symbtab */
  1087. X
  1088. X/******************************************************************************
  1089. X * enter_symbtabel()                                                          *
  1090. X *                                                                            *
  1091. X * Creates a new symbol table element by allocating the needed heap space and *
  1092. X * initializes the components: 'name', 'type', 'blknum'.                      *
  1093. X * The new symbol table element will also be entered in the symbol table.     *
  1094. X *                                                                            *
  1095. X * Return values: pointer to new element upon success / NULL upon error       *
  1096. X ******************************************************************************/
  1097. XSYMBTABEL *
  1098. Xenter_symbtabel(name)
  1099. Xregister char *name;
  1100. X{
  1101. X    register int hashid;
  1102. X    register SYMBTABEL *symbol;
  1103. X
  1104. X    if (errflag)
  1105. X    return((SYMBTABEL *) NULL);
  1106. X
  1107. X#ifdef SYMBDEBUG
  1108. X    fprintf(debugfile, "[symb] ***** enter_symbtabel(): params: name = %s\n",
  1109. X    name);
  1110. X    fprintf(debugfile, "[symb]       creating and initializing new element\n");
  1111. X#endif /* SYMBDEBUG /**/
  1112. X
  1113. X    /* create and initialize new symbol table element */
  1114. X    symbol = (SYMBTABEL *) Malloc(sizeof(SYMBTABEL));
  1115. X    symbol->name         = strsave(name);
  1116. X    symbol->type         = UDEC;
  1117. X    symbol->blknum       = blknum;
  1118. X    symbol->WasInSysIncl = (sysinclflag) ? TRUE : FALSE;
  1119. X    symbol->IdNext       = symbol->PstNext = (SYMBTABEL *) NULL;
  1120. X
  1121. X    /* insert new element in PST list */
  1122. X    symbol->PstNext        = symbtab.PstTab[blknum];
  1123. X    symbtab.PstTab[blknum] = symbol;
  1124. X
  1125. X    /* insert new element in ID list */
  1126. X    hashid = hash(symbol->name);
  1127. X    symbol->IdNext        = symbtab.IdTab[hashid];
  1128. X    symbtab.IdTab[hashid] = symbol;
  1129. X
  1130. X#ifdef SYMBDEBUG
  1131. X    display_symbtab_entry(symbol);
  1132. X#endif /* SYMBDEBUG /**/
  1133. X
  1134. X    return(symbol);
  1135. X} /* enter_symbtabel */
  1136. X
  1137. X/******************************************************************************
  1138. X * lookup_symbtabel()                                                         *
  1139. X *                                                                            *
  1140. X * Search the symbol table entry specified by 'name'.                         *
  1141. X *                                                                            *
  1142. X * Return values: pointer to the found symbol table element upon success /    *
  1143. X *                NULL, if element not found or upon error                    *
  1144. X ******************************************************************************/
  1145. XSYMBTABEL *
  1146. Xlookup_symbtabel(name)
  1147. Xchar *name;
  1148. X{
  1149. X    register SYMBTABEL *symbol;
  1150. X    SYMBTABEL *result;
  1151. X
  1152. X    if (errflag || (!name))
  1153. X    return((SYMBTABEL *) NULL);
  1154. X
  1155. X#ifdef SYMBDEBUG
  1156. X    fprintf(debugfile, "[symb] ***** lookup_symbtabel()\n");
  1157. X    fprintf(debugfile, "[symb]       searching entry for \"%s\" in symbol table\n", name);
  1158. X#endif /* SYMBDEBUG /**/
  1159. X
  1160. X    result = (SYMBTABEL *) NULL;
  1161. X
  1162. X    for(symbol = symbtab.IdTab[hash(name)]; symbol; symbol = symbol->IdNext) {
  1163. X#ifdef SYMBDEBUG
  1164. X        fprintf(debugfile, "[symb]       checking \"%s\"\n", symbol->name);
  1165. X#endif /* SYMBDEBUG /**/
  1166. X    if (!strcmp(symbol->name, name)) {
  1167. X        result = symbol;
  1168. X        break;
  1169. X    }
  1170. X    } /* for */
  1171. X
  1172. X#ifdef SYMBDEBUG
  1173. X    if (!result) 
  1174. X        fprintf(debugfile, "[symb]       element not found\n");
  1175. X    else {
  1176. X        fprintf(debugfile, "[symb]       element found (adr = %d)\n", result);
  1177. X        fprintf(debugfile, "[symb]       name = %s, blknum = %d\n",
  1178. X        result->name, result->blknum);
  1179. X        fprintf(debugfile, "[symb]       WasInSysIncl = %s, type = ",
  1180. X        (result->WasInSysIncl) ? "TRUE" : "FALSE");
  1181. X        switch(result->type) {
  1182. X        case UDEC:
  1183. X            fprintf(debugfile, "UDEC (not declared)\n");
  1184. X        break;
  1185. X        case PROCESSDECL:
  1186. X            fprintf(debugfile, "PROCESSDECL (process declaration)\n");
  1187. X        break;
  1188. X        case VARORPAR:
  1189. X            fprintf(debugfile, "VARORPAR (variable or parameter)\n");
  1190. X        break;
  1191. X        case TRANSACTION:
  1192. X            fprintf(debugfile, "TRANSACTION (transaction declaration)\n");
  1193. X        break;
  1194. X        case FUNCTIONDEF:
  1195. X            fprintf(debugfile, "FUNCTIONDEF (function definition)\n");
  1196. X        break;
  1197. X        case PROCESSVAR:
  1198. X            fprintf(debugfile, "PROCESSVAR (process variable)\n");
  1199. X        break;
  1200. X        case TYPEDEFNAME:
  1201. X            fprintf(debugfile, "TYPEDEFNAME (type definition)\n");
  1202. X        break;
  1203. X        case STRUCTDECL:
  1204. X            fprintf(debugfile, "STRUCTDECL (structure declaration)\n");
  1205. X        break;
  1206. X        default:
  1207. X            fprintf(debugfile, "UNKNOWN (type = %d)\n", result->type);
  1208. X        } /* switch */
  1209. X    }
  1210. X#endif /* SYMBDEBUG /**/
  1211. X
  1212. X    return(result);
  1213. X} /* lookup_symbtabel */
  1214. X
  1215. X/******************************************************************************
  1216. X * blk_push()                                                                 *
  1217. X *                                                                            *
  1218. X * Increments the block depth counter.                                        *
  1219. X *                                                                            *
  1220. X * Return values: always OK for success                                       *
  1221. X ******************************************************************************/
  1222. Xint
  1223. Xblk_push()
  1224. X{
  1225. X#ifdef SYMBDEBUG
  1226. X    fprintf(debugfile, "[symb] ***** blk_push():\n");
  1227. X    fprintf(debugfile, "[symb]       new blknum = %d\n", blknum + 1);
  1228. X#endif /* SYMBDEBUG /**/
  1229. X    ++blknum;
  1230. X    return(OK);
  1231. X} /* blk_push */
  1232. X
  1233. X/******************************************************************************
  1234. X * blk_pop()                                                                  *
  1235. X *                                                                            *
  1236. X * Closes a block, deletes all symbol table entries corresponding to the      *
  1237. X * actual block depth and finally decrements the block depth.                 *
  1238. X *                                                                            *
  1239. X * REMARK: Transactions aren't deleted, so transaction names must be definite!*
  1240. X *                                                                            *
  1241. X * Return values: OK upon success / ERROR upon error                          *
  1242. X ******************************************************************************/
  1243. Xint
  1244. Xblk_pop()
  1245. X{
  1246. X    int hashid;
  1247. X    register SYMBTABEL *ptr;
  1248. X
  1249. X#ifdef SYMBDEBUG
  1250. X    fprintf(debugfile, "[symb] ***** blk_pop():\n");
  1251. X    fprintf(debugfile, "[symb]       deleting entries with blknum = %d\n",
  1252. X    blknum);
  1253. X#endif /* SYMBDEBUG /**/
  1254. X    for(ptr = symbtab.PstTab[blknum]; ptr; ptr = ptr->PstNext) {
  1255. X#ifdef SYMBDEBUG
  1256. X    fprintf(debugfile, "[symb]       deleting \"%s\"\n", ptr->name);
  1257. X#endif  /* SYMBDEBUG /**/
  1258. X    /* delete element from Id list */
  1259. X    hashid = hash(ptr->name);
  1260. X    symbtab.IdTab[hashid] = symbtab.IdTab[hashid]->IdNext;
  1261. X    /* free heap space */
  1262. X    /* don't free parameters or transaction declarations! */
  1263. X    if (ptr->type != VARORPAR && ptr->type != TRANSACTION) {
  1264. X        Free((char *) ptr->name);
  1265. X        Free((char *) ptr);
  1266. X    }
  1267. X    } /* for */
  1268. X    /* delete PST list with actual blknum */
  1269. X    symbtab.PstTab[blknum] = (SYMBTABEL *) NULL;
  1270. X    /* decrement blknum */
  1271. X    if (--blknum < 0)
  1272. X    Panic("blknum < 0");
  1273. X#ifdef SYMBDEBUG
  1274. X    fprintf(debugfile, "[symb]       new blknum = %d\n", blknum);
  1275. X#endif  /* SYMBDEBUG /**/
  1276. X    return(OK);
  1277. X} /* blk_pop */
  1278. END_OF_FILE
  1279. if test 12189 -ne `wc -c <'dcc/symb_general.c'`; then
  1280.     echo shar: \"'dcc/symb_general.c'\" unpacked with wrong size!
  1281. fi
  1282. # end of 'dcc/symb_general.c'
  1283. fi
  1284. if test -f 'dcinstall/Prepare.c' -a "${1}" != "-c" ; then 
  1285.   echo shar: Will not clobber existing file \"'dcinstall/Prepare.c'\"
  1286. else
  1287. echo shar: Extracting \"'dcinstall/Prepare.c'\" \(12503 characters\)
  1288. sed "s/^X//" >'dcinstall/Prepare.c' <<'END_OF_FILE'
  1289. X/***************************************************************************
  1290. X *                                                                         *
  1291. X * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  1292. X * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  1293. X * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  1294. X * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  1295. X * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  1296. X *                                                                         *
  1297. X *              A compiler for distributed programming with C              *
  1298. X *                                                                         *
  1299. X *                            P r e p a r e . c                            *
  1300. X *                                                                         *
  1301. X *                            Package : Installer Program                  *
  1302. X *                            Version : 1.1                                *
  1303. X *                       CreationDate : 25.11.91                           *
  1304. X *                         LastUpDate : 06.12.93                           *
  1305. X *                                                                         *
  1306. X * The routine 'PrepareTarget' which prepares target hosts for remote      *
  1307. X * compilation and program installing.                                     *
  1308. X *                                                                         *
  1309. X *               Copyright (C) 1991-1994 by Christoph Pleier               *
  1310. X *                          All rights reserved!                           *
  1311. X ***************************************************************************/
  1312. X
  1313. X/*
  1314. X * This file is part of the Distributed C Development Environment (DCDE).
  1315. X * DCDE is free software; you can redistribute it and/or modify
  1316. X * it under the terms written in the README-file. 
  1317. X * DCDE is distributed in the hope that it will be useful,
  1318. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1319. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  1320. X * See the file README for more details.
  1321. X */
  1322. X
  1323. X#include <stdio.h>
  1324. X#include <pwd.h>
  1325. X#include "cfgparsers.h"
  1326. X#include "dcinstall.h"
  1327. X
  1328. Xchar *src_inc_files[] = {
  1329. X    "run_Errno.h",
  1330. X    "run_errlist.h",
  1331. X    "ipc.h",
  1332. X    "dcc.h",
  1333. X    "config.h",
  1334. X    "timeout.h",
  1335. X    "ipc_socket.h",
  1336. X    "ipc_msgsem.h",
  1337. X    ""
  1338. X};
  1339. X
  1340. Xchar *del_inc_files[] = {
  1341. X    "run_errlist.h",
  1342. X    "config.h",
  1343. X    "timeout.h",
  1344. X    "ipc_socket.h",
  1345. X    "ipc_msgsem.h",
  1346. X    ""
  1347. X};
  1348. X
  1349. Xchar *src_lib_files[] = {
  1350. X    "RuntimeError.c",
  1351. X    "control.c",
  1352. X    "convert.c",
  1353. X    "creation.c",
  1354. X    "debug.c",
  1355. X    "destruction.c",
  1356. X    "ipc.c",
  1357. X    "transaction.c",
  1358. X#ifdef HETEROGENEOUS
  1359. X    "transfer.c",
  1360. X#endif
  1361. X    ""
  1362. X};
  1363. X
  1364. X/******************************************************************************
  1365. X * PrepareTarget()                                                            *
  1366. X *                                                                            *
  1367. X * Prepares the target host specified by 'dest' for remote compilation.       *
  1368. X *                                                                            *
  1369. X * Return values: OK upon success / ERROR upon error                          *
  1370. X ******************************************************************************/
  1371. Xint
  1372. XPrepareTarget(src, dest)
  1373. XSYMBTABEL *src;        /* source host */
  1374. XSYMBTABEL *dest;    /* destination host */
  1375. X{
  1376. X    int mounted;                /* src and dest share one filesystem or not */
  1377. X    char **fptr;
  1378. X    static char cmd[1000];    /* to store the command */
  1379. X    TARGETINFO *targets;
  1380. X    SYMBTABEL *symbol, *symbol2, *class;
  1381. X
  1382. X    if (!dest->info.Host.istarget || dest->info.Host.ex_storage->info.disk.wasprepared) 
  1383. X    return(OK);
  1384. X
  1385. X#ifndef DEBUG
  1386. X    printf("Preparing    %s (%s)\n",
  1387. X        dest->name, dest->info.Host.ex_storage->name);
  1388. X#endif /* Not DEBUG /**/
  1389. X
  1390. X    /* Determine access mode:
  1391. X     * If source-host equals destination host or source and dest host
  1392. X     * share one disk the access mode is mounted. Otherwise if dest is
  1393. X     * accessed via network, it is not mounted!
  1394. X     */
  1395. X    if (src == dest || src->info.Host.ex_storage->info.disk.location == dest->info.Host.ex_storage->info.disk.location)
  1396. X    mounted = TRUE;
  1397. X    else
  1398. X    mounted = FALSE;
  1399. X
  1400. X    /* 
  1401. X     * FIRST: make directories 
  1402. X     */
  1403. X
  1404. X    if (mounted) {
  1405. X    sprintf(cmd, "cd %s ; \\rm -rf dcc", gethomedir(getLogin()));
  1406. X    strcat(cmd,  " ; mkdir dcc");
  1407. X    strcat(cmd,  " ; mkdir dcc/bin");
  1408. X    strcat(cmd,  " ; mkdir dcc/bin/");
  1409. X    strcat(cmd,  dest->info.Host.type->name);
  1410. X    strcat(cmd,  " ; mkdir dcc/include");
  1411. X    strcat(cmd,  " ; mkdir dcc/lib");
  1412. X    strcat(cmd,  " ; mkdir dcc/lib/");
  1413. X    strcat(cmd,  dest->info.Host.type->name);
  1414. X    strcat(cmd,  " ; mkdir dcc/compile");
  1415. X    } else {
  1416. X    sprintf(cmd, "%s %s -n \\\\rm -rf dcc", RSH, dest->name);
  1417. X    strcat(cmd,  " \";\" mkdir dcc");
  1418. X    strcat(cmd,  " \";\" mkdir dcc/bin");
  1419. X    strcat(cmd,  " \";\" mkdir dcc/bin/");
  1420. X    strcat(cmd,  dest->info.Host.type->name);
  1421. X    strcat(cmd,  " \";\" mkdir dcc/include");
  1422. X    strcat(cmd,  " \";\" mkdir dcc/lib");
  1423. X    strcat(cmd,  " \";\" mkdir dcc/lib/");
  1424. X    strcat(cmd,  dest->info.Host.type->name);
  1425. X    strcat(cmd,  " \";\" mkdir dcc/compile");
  1426. X    }
  1427. X
  1428. X    if (verbose)
  1429. X    printf("Make dirs    command: %s\n", cmd);
  1430. X
  1431. X    if (!noexecute)
  1432. X        if (system(cmd)) {
  1433. X            fprintf(stderr, "\nError making directories at host \"%s\"\n", dest->name);
  1434. X        fprintf(stderr, "The following command caused the error:\n");
  1435. X        fprintf(stderr, "\"%s\"\n", cmd);
  1436. X        exit(ERROR);
  1437. X    }
  1438. X
  1439. X    /*
  1440. X     * SECOND: Transfer needed source files to host to build runtime library
  1441. X     */
  1442. X
  1443. X    /* Transfer include files */
  1444. X    for(fptr = src_inc_files; *fptr[0] != 0; fptr++) {
  1445. X
  1446. X    if (mounted)
  1447. X            sprintf(cmd, "cp %s/%s %s/dcc/include/%s", 
  1448. X        INCLUDEDIR, *fptr, gethomedir(getLogin()), *fptr);
  1449. X    else
  1450. X        sprintf(cmd, "rcp %s/%s %s@%s:./dcc/include/%s", 
  1451. X        INCLUDEDIR, *fptr, getLogin(), dest->name, *fptr);
  1452. X
  1453. X    if (verbose)
  1454. X        printf("Transferring command: %s\n", cmd);
  1455. X
  1456. X    if (!noexecute)
  1457. X            if (system(cmd)) {
  1458. X            fprintf(stderr, "\nError transferring source files to host \"%s\"\n", dest->name);
  1459. X            fprintf(stderr, "The following command caused the error:\n");
  1460. X            fprintf(stderr, "\"%s\"\n", cmd);
  1461. X            exit(ERROR);
  1462. X        }
  1463. X    } /* for */
  1464. X
  1465. X    /* Transfer library files */
  1466. X    for(fptr = src_lib_files; *fptr[0] != 0; fptr++) {
  1467. X
  1468. X    if (mounted)
  1469. X            sprintf(cmd, "cp %s/%s %s/dcc/compile/%s", 
  1470. X        LIBRARYDIR, *fptr, gethomedir(getLogin()), *fptr);
  1471. X    else
  1472. X        sprintf(cmd, "rcp %s/%s %s@%s:./dcc/compile/%s", 
  1473. X        LIBRARYDIR, *fptr, getLogin(), dest->name, *fptr);
  1474. X
  1475. X    if (verbose)
  1476. X        printf("Transferring command: %s\n", cmd);
  1477. X
  1478. X    if (!noexecute)
  1479. X            if (system(cmd)) {
  1480. X            fprintf(stderr, "\nError transferring source files to host \"%s\"\n", dest->name);
  1481. X            fprintf(stderr, "The following command caused the error:\n");
  1482. X            fprintf(stderr, "\"%s\"\n", cmd);
  1483. X            exit(ERROR);
  1484. X        }
  1485. X    } /* for */
  1486. X
  1487. X    /*
  1488. X     * THIRD: Build library
  1489. X     */
  1490. X
  1491. X    if (mounted)
  1492. X    sprintf(cmd, "cd %s/dcc/compile ;", gethomedir(getLogin()));
  1493. X    else
  1494. X    sprintf(cmd, "%s %s cd dcc/compile \";\"", RSH, dest->name);
  1495. X
  1496. X#ifdef HETEROGENEOUS
  1497. X    strcat(cmd, " rpcgen -c -o transfer.c ../include/dcc.h ");
  1498. X    if (mounted)
  1499. X    strcat(cmd, ";");
  1500. X    else
  1501. X    strcat(cmd, "\";\"");
  1502. X#endif /* HETEROGENEOUS /**/
  1503. X
  1504. X    for(targets = dest->info.Host.compinfo; targets; targets = targets->next) 
  1505. X    if (!strcmp(targets->type, dest->info.Host.type->name) 
  1506. X            && !strcmp(targets->os, dest->info.Host.os->name))
  1507. X        break;
  1508. X
  1509. X    if (!targets) {
  1510. X    fprintf(stderr, "Error: target specification for computer type \"%s\" of operating",
  1511. X        dest->info.Host.type->name);
  1512. X    fprintf(stderr, "       system \"%s\" of host \"%s\" not found \n",
  1513. X        dest->info.Host.os->name, dest->name);
  1514. X    fprintf(stderr, "       in system configuration file \"%s\"\n",
  1515. X        cfgfilename);
  1516. X    exit(ERROR);
  1517. X    }
  1518. X
  1519. X    strcat(cmd, " ");
  1520. X    strcat(cmd, targets->cc);
  1521. X    strcat(cmd, " -I../include ");
  1522. X    strcat(cmd, targets->cflags);
  1523. X    strcat(cmd, " -c ");
  1524. X
  1525. X    for(fptr = src_lib_files; *fptr[0] != 0; fptr++) {
  1526. X    strcat(cmd, *fptr);
  1527. X    strcat(cmd, " ");
  1528. X    }
  1529. X
  1530. X    strcat(cmd, targets->libs);
  1531. X
  1532. X    if (mounted)
  1533. X    strcat(cmd, ";");
  1534. X    else
  1535. X    strcat(cmd, "\";\"");
  1536. X    
  1537. X    strcat(cmd, " ar q ../lib/");
  1538. X    strcat(cmd, dest->info.Host.type->name);
  1539. X    strcat(cmd, "/dcc.a ");
  1540. X    for(fptr = src_lib_files; *fptr[0] != 0; fptr++) {
  1541. X    strcat(cmd, *fptr);
  1542. X    cmd[strlen(cmd)-1] = 'o';
  1543. X    strcat(cmd, " ");
  1544. X    }
  1545. X
  1546. X#if !defined(UNICOS) && !defined(HPUX)
  1547. X    if (mounted)
  1548. X    strcat(cmd, ";");
  1549. X    else
  1550. X    strcat(cmd, "\";\"");
  1551. X    
  1552. X    strcat(cmd, " ranlib ../lib/");
  1553. X    strcat(cmd, dest->info.Host.type->name);
  1554. X    strcat(cmd, "/dcc.a ");
  1555. X#endif
  1556. X
  1557. X    if (verbose)
  1558. X        printf("Compilation  command: %s\n", cmd);
  1559. X
  1560. X    if (!noexecute) 
  1561. X        if (system(cmd)) {
  1562. X            fprintf(stderr, "\nError building the library for host \"%s\"\n", 
  1563. X        dest->name);
  1564. X            fprintf(stderr, "The following command caused the error:\n");
  1565. X            fprintf(stderr, "\"%s\"\n", cmd);
  1566. X#ifndef SCO_UNIX
  1567. X        /* use of runlib produces an error under SCO UNIX -> ignored! */
  1568. X            exit(ERROR);
  1569. X#endif
  1570. X        }
  1571. X
  1572. X    dest->info.Host.ex_storage->info.disk.wasprepared = TRUE; 
  1573. X
  1574. X    /* check the remainding hosts */
  1575. X    for(symbol = symbtab; symbol; symbol = symbol->next) {
  1576. X
  1577. X    if (symbol->type == S_HOST && symbol->info.Host.istarget
  1578. X        && symbol->info.Host.type == dest->info.Host.type
  1579. X        && symbol->info.Host.os   == dest->info.Host.os) {
  1580. X
  1581. X        if (symbol->info.Host.ex_storage->info.disk.wasprepared)
  1582. X        continue;
  1583. X
  1584. X        if (symbol->info.Host.ex_storage == dest->info.Host.ex_storage) {
  1585. X        /* Host shares files with compilation host => nothing to do! */
  1586. X            symbol->info.Host.ex_storage->info.disk.wasprepared = TRUE;
  1587. X        } else {
  1588. X        /* Host has own filesystem => distribute files */
  1589. X#ifndef DEBUG
  1590. X            printf("Distributing files %s (%s) -> %s (%s)\n",
  1591. X                dest->name, dest->info.Host.ex_storage->info.disk.location->name, 
  1592. X            symbol->name, symbol->info.Host.ex_storage->info.disk.location->name);
  1593. X#endif /* Not DEBUG /**/
  1594. X        sprintf(cmd, "rcp %s@%s:dcc/lib/%s/dcc.a %s@%s:dcc/lib/%s/dcc.a",
  1595. X            getLogin(), dest->name, dest->info.Host.type->name, 
  1596. X            getLogin(), symbol->name, symbol->info.Host.type->name);
  1597. X        sprintf(&cmd[strlen(cmd)], "; rcp %s@%s:dcc/include/dcc.h %s@%s:dcc/include/dcc.h",
  1598. X            getLogin(), dest->name, getLogin(), symbol->name);
  1599. X        sprintf(&cmd[strlen(cmd)], "; rcp %s@%s:dcc/include/run_Errno.h %s@%s:dcc/include/run_Errno.h",
  1600. X            getLogin(), dest->name, getLogin(), symbol->name);
  1601. X        sprintf(&cmd[strlen(cmd)], "; rcp %s@%s:dcc/include/ipc.h %s@%s:dcc/include/ipc.h",
  1602. X            getLogin(), dest->name, getLogin(), symbol->name);
  1603. X        if (verbose)
  1604. X            printf("Distribution command: %s\n", cmd);
  1605. X        if (!noexecute)
  1606. X                    if (system(cmd)) {
  1607. X                    fprintf(stderr, "\nError distributing files to host \"%s\"\n", 
  1608. X                symbol->name);
  1609. X                    fprintf(stderr, "The following command caused the error:\n");
  1610. X                    fprintf(stderr, "\"%s\"\n", cmd);
  1611. X                    exit(ERROR);
  1612. X                }
  1613. X            /* all hosts of this filesystem and the same class are also 
  1614. X         * marked 
  1615. X         */
  1616. X            for(symbol2 = symbtab; symbol2; symbol2 = symbol2->next) {
  1617. X            if (symbol2->type == S_HOST 
  1618. X                   && symbol2->info.Host.type == symbol->info.Host.type
  1619. X                   && symbol2->info.Host.os   == symbol->info.Host.os
  1620. X               && symbol2->info.Host.ex_storage == symbol->info.Host.ex_storage) {
  1621. X            symbol2->info.Host.ex_storage->info.disk.wasprepared = TRUE;
  1622. X            }
  1623. X        } /* for */
  1624. X        } /* else */
  1625. X    } /* if */
  1626. X
  1627. X    } /* for(symbol) */
  1628. X
  1629. X    /*
  1630. X     * FOURTH: Delete some include files
  1631. X     */
  1632. X
  1633. X    /* Delete some include files */
  1634. X
  1635. X    if (mounted)
  1636. X    sprintf(cmd, "cd %s/dcc/include ; \\rm -f", gethomedir(getLogin()));
  1637. X    else
  1638. X    sprintf(cmd, "%s %s cd dcc/include \";\" \\\\rm -f", RSH, dest->name);
  1639. X
  1640. X    for(fptr = del_inc_files; *fptr[0] != 0; fptr++) {
  1641. X    strcat(cmd, " ");
  1642. X    strcat(cmd, *fptr);
  1643. X    } /* for */
  1644. X
  1645. X    if (verbose)
  1646. X    printf("Deleting     command: %s\n", cmd);
  1647. X
  1648. X    if (!noexecute)
  1649. X        if (system(cmd)) {
  1650. X            fprintf(stderr, "\nError deleting include files at host \"%s\"\n", dest->name);
  1651. X            fprintf(stderr, "The following command caused the error:\n");
  1652. X            fprintf(stderr, "\"%s\"\n", cmd);
  1653. X            exit(ERROR);
  1654. X        }
  1655. X
  1656. X    return(OK);
  1657. X
  1658. X} /* PrepareTarget */
  1659. END_OF_FILE
  1660. if test 12503 -ne `wc -c <'dcinstall/Prepare.c'`; then
  1661.     echo shar: \"'dcinstall/Prepare.c'\" unpacked with wrong size!
  1662. fi
  1663. # end of 'dcinstall/Prepare.c'
  1664. fi
  1665. if test -f 'examples/config/system.WAN' -a "${1}" != "-c" ; then 
  1666.   echo shar: Will not clobber existing file \"'examples/config/system.WAN'\"
  1667. else
  1668. echo shar: Extracting \"'examples/config/system.WAN'\" \(12406 characters\)
  1669. sed "s/^X//" >'examples/config/system.WAN' <<'END_OF_FILE'
  1670. X# system.WAN
  1671. X#
  1672. X# This is a system configuration file defining a Wide Area Network
  1673. X# consisting of computers in the area of munich.
  1674. X# This file contains ONLY the definitions needed for dcinstall, not
  1675. X# the definitions for dclocate or dcanalyse.
  1676. X# Use this file only in combination with dcinstall, version 2.0 or greater and 
  1677. X# dcadmin, version 2.0 (process allocation by mapfile).
  1678. X#
  1679. X# Christoph Pleier, December 1993
  1680. X#
  1681. X#
  1682. X# **************************************************************************
  1683. X# * PART I: definition of all hostnames
  1684. X# **************************************************************************
  1685. Xhostnames = {
  1686. X
  1687. X    # ----------
  1688. X    # LAN 1 at Technische Universitaet Muenchen
  1689. X    #
  1690. X    # Sun SPARCstation
  1691. X    suneickel2, suneickel4, suneickel5, suneickel6, suneickel7, 
  1692. X    suneickel8, suneickel9,
  1693. X    # HP 9000/720
  1694. X    hpeick7, hpeick8, hpeick9, 
  1695. X    # HP 9000/755
  1696. X    hpeick6,
  1697. X    # AT 486
  1698. X    ateickel1,
  1699. X    # ----------
  1700. X    # LAN 2 at Technische Universitaet Muenchen
  1701. X    #
  1702. X    # HP 9000/720
  1703. X    hphalle0, hphalle0a, hphalle0b, hphalle0c, hphalle0d, hphalle0e, 
  1704. X              hphalle0f, hphalle0g, hphalle0h, hphalle0i, hphalle0j,
  1705. X    hphalle1, hphalle1a, hphalle1b, hphalle1c, hphalle1d, hphalle1e, 
  1706. X              hphalle1f, hphalle1g, hphalle1h, hphalle1i, hphalle1j,
  1707. X    hphalle2, hphalle2a, hphalle2b, hphalle2c, hphalle2d, hphalle2e, 
  1708. X              hphalle2f, hphalle2g, hphalle2h, hphalle2i, hphalle2j,
  1709. X    hphalle3, hphalle3a, hphalle3b, hphalle3c, hphalle3d, hphalle3e, 
  1710. X              hphalle3f, hphalle3g, hphalle3h, hphalle3i, hphalle3j,
  1711. X    hphalle4, hphalle4a, hphalle4b, hphalle4c, hphalle4d, hphalle4e, 
  1712. X              hphalle4f, hphalle4g, hphalle4h, hphalle4i, hphalle4j,
  1713. X    hphalle5, hphalle5a, hphalle5b, hphalle5c, hphalle5d, hphalle5e, 
  1714. X              hphalle5f, hphalle5g, hphalle5h, hphalle5i, hphalle5j,
  1715. X    hphalle6, hphalle6a, hphalle6b, hphalle6c, hphalle6d, hphalle6e, 
  1716. X              hphalle6f, hphalle6g, hphalle6h, hphalle6i, hphalle6j,
  1717. X    hphalle7, hphalle7a, hphalle7b, hphalle7c, hphalle7d, hphalle7e, 
  1718. X              hphalle7f, hphalle7g, hphalle7h, hphalle7i, hphalle7j,
  1719. X    hphalle8, hphalle8a, hphalle8b, hphalle8c, hphalle8d, hphalle8e, 
  1720. X              hphalle8f, hphalle8g, hphalle8h, hphalle8i, hphalle8j,
  1721. X    hphalle9, hphalle9a, hphalle9b, hphalle9c, hphalle9d, hphalle9e, 
  1722. X              hphalle9f, hphalle9g, hphalle9h, hphalle9i, hphalle9j,
  1723. X    # ----------
  1724. X    # LAN 3 at Gesellschaft fuer Strahlen- und Umweltforschung, Neuherberg
  1725. X    #
  1726. X    # Convex supercomputer C3840 "cony" (146.107.1.2)
  1727. X    cony.gsf.de,
  1728. X    # ----------
  1729. X    # LAN 4 at Botanisches Institut, Ludwig-Maximilians-Universitaet Muenchen
  1730. X    #
  1731. X    # IBM RS 6000
  1732. X    odin.botanik.biologie.uni-muenchen.de, 
  1733. X    adgard.botanik.biologie.uni-muenchen.de, 
  1734. X    mitgard.botanik.biologie.uni-muenchen.de, 
  1735. X    utgard.botanik.biologie.uni-muenchen.de, 
  1736. X    baldur.botanik.biologie.uni-muenchen.de, 
  1737. X    freya.botanik.biologie.uni-muenchen.de, 
  1738. X    thor.botanik.biologie.uni-muenchen.de, 
  1739. X    fenris.botanik.biologie.uni-muenchen.de, 
  1740. X    loki.botanik.biologie.uni-muenchen.de, 
  1741. X    hel.botanik.biologie.uni-muenchen.de, 
  1742. X    woelsung.botanik.biologie.uni-muenchen.de, 
  1743. X    ragnaroek.botanik.biologie.uni-muenchen.de, 
  1744. X    sigurd.botanik.biologie.uni-muenchen.de,
  1745. X    # ----------
  1746. X    # LAN 5 at Leibniz Rechenzentrum, Muenchen
  1747. X    #
  1748. X    # Cray Supercomputer Y-MP EL "yel" (yel@lrz-muenchen.de)
  1749. X    129.187.14.4
  1750. X    # ----------
  1751. X}
  1752. X
  1753. X# **************************************************************************
  1754. X# * PART II: definition of all computer types
  1755. X# **************************************************************************
  1756. Xcomputer types = {
  1757. X    AT486, RS6000, SPARC, HP9000_720, HP9000_755, CONVEX_C3840, CRAY_Y-MP
  1758. X}
  1759. X
  1760. X# **************************************************************************
  1761. X# * PART III: definition of all UNIX variants
  1762. X# **************************************************************************
  1763. Xoperating system variants = {
  1764. X    LINUX, AIX, SunOS, HPUX, ConvexOS, UNICOS
  1765. X}
  1766. X
  1767. X# **************************************************************************
  1768. X# * PART IV: definition of all fixed disks (used by dcinstall) and their 
  1769. X# *          properities
  1770. X# *          Note: the speed value is not important here!
  1771. X# **************************************************************************
  1772. Xfixed disks = {
  1773. X    SUN6disk = {
  1774. X    location : suneickel6
  1775. X    }
  1776. X    HPEICK7disk = {
  1777. X    location : hpeick7
  1778. X    }
  1779. X    HPEICK8disk = {
  1780. X    location : hpeick8
  1781. X    }
  1782. X    HPEICK9disk = {
  1783. X    location : hpeick9
  1784. X    }
  1785. X    HPEICK6disk = {
  1786. X    location : hpeick6
  1787. X    }
  1788. X    HPHALLE7disk = {
  1789. X    location : hphalle7
  1790. X    }
  1791. X    CONVEXdisk = {
  1792. X        location : cony.gsf.de
  1793. X    }
  1794. X    CRAYdisk = {
  1795. X        location : 129.187.14.4
  1796. X    }
  1797. X    ODINdisk = {
  1798. X    location : odin.botanik.biologie.uni-muenchen.de
  1799. X    }
  1800. X    ATEICKEL1disk = {
  1801. X        location : ateickel1
  1802. X    }
  1803. X}
  1804. X
  1805. X# **************************************************************************
  1806. X# * PART V: definition of the hosts
  1807. X# **************************************************************************
  1808. Xhost suneickel2, suneickel4, suneickel5, suneickel6, suneickel7, suneickel8, suneickel9 = {
  1809. X    operating system : SunOS
  1810. X    computer specification {
  1811. X    type                    : SPARC
  1812. X    physical memory         : 16 MB    
  1813. X    virtual memory          : 32 MB    
  1814. X    performance index       : 4.0
  1815. X    storage for executables : SUN6disk
  1816. X    }
  1817. X    compilation {
  1818. X        target: SPARC (SunOS) {
  1819. X        CC      = "cc"
  1820. X        CFLAGS  = "-DSPARC -DBSD -DSOCKET -DHETEROGENEOUS"
  1821. X        LDFLAGS = ""
  1822. X        LIBS    = ""
  1823. X    }
  1824. X    }
  1825. X} # suneickel2, suneickel4, suneickel5, suneickel6, suneickel7, suneickel8, suneickel9
  1826. X
  1827. Xhost hpeick7 = {
  1828. X    operating system : HPUX
  1829. X    computer specification {
  1830. X    type                    : HP9000_720
  1831. X    physical memory         : 32 MB    
  1832. X    virtual memory          : 32 MB    
  1833. X    performance index       : 18.0
  1834. X    storage for executables : HPEICK7disk
  1835. X    }
  1836. X    compilation {
  1837. X        target: HP9000_720 (HPUX) {
  1838. X        CC      = "cc"
  1839. X        CFLAGS  = "-DHPUX -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  1840. X        LDFLAGS = ""
  1841. X        LIBS    = "-lcodelibs"
  1842. X    }
  1843. X    }
  1844. X} # hpeick7
  1845. X
  1846. Xhost hpeick8 = {
  1847. X    operating system : HPUX
  1848. X    computer specification {
  1849. X    type                    : HP9000_720
  1850. X    physical memory         : 32 MB    
  1851. X    virtual memory          : 32 MB    
  1852. X    performance index       : 18.0
  1853. X    storage for executables : HPEICK8disk
  1854. X    }
  1855. X    compilation {
  1856. X        target: HP9000_720 (HPUX) {
  1857. X        CC      = "cc"
  1858. X        CFLAGS  = "-DHPUX -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  1859. X        LDFLAGS = ""
  1860. X        LIBS    = "-lcodelibs"
  1861. X    }
  1862. X    }
  1863. X} # hpeick8
  1864. X
  1865. Xhost hpeick9 = {
  1866. X    operating system : HPUX
  1867. X    computer specification {
  1868. X    type                    : HP9000_720
  1869. X    physical memory         : 32 MB    
  1870. X    virtual memory          : 32 MB    
  1871. X    performance index       : 18.0
  1872. X    storage for executables : HPEICK9disk
  1873. X    }
  1874. X    compilation {
  1875. X        target: HP9000_720 (HPUX) {
  1876. X        CC      = "cc"
  1877. X        CFLAGS  = "-DHPUX -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  1878. X        LDFLAGS = ""
  1879. X        LIBS    = "-lcodelibs"
  1880. X    }
  1881. X    }
  1882. X} # hpeick9
  1883. X
  1884. Xhost hpeick6 = {
  1885. X    operating system : HPUX
  1886. X    computer specification {
  1887. X    type                    : HP9000_755
  1888. X    physical memory         : 128 MB    
  1889. X    virtual memory          : 128 MB    
  1890. X    performance index       : 24
  1891. X    storage for executables : HPEICK6disk
  1892. X    }
  1893. X    compilation {
  1894. X        target: HP9000_755 (HPUX) {
  1895. X        CC      = "cc"
  1896. X        CFLAGS  = "-DHPUX -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  1897. X        LDFLAGS = ""
  1898. X        LIBS    = "-lcodelibs"
  1899. X    }
  1900. X    }
  1901. X} # hpeick6
  1902. X
  1903. Xhost hphalle0,  hphalle0a, hphalle0b, hphalle0c, hphalle0d, hphalle0e, 
  1904. X     hphalle0f, hphalle0g, hphalle0h, hphalle0i, hphalle0j,
  1905. X     hphalle1,  hphalle1a, hphalle1b, hphalle1c, hphalle1d, hphalle1e, 
  1906. X     hphalle1f, hphalle1g, hphalle1h, hphalle1i, hphalle1j,
  1907. X     hphalle2,  hphalle2a, hphalle2b, hphalle2c, hphalle2d, hphalle2e, 
  1908. X     hphalle2f, hphalle2g, hphalle2h, hphalle2i, hphalle2j,
  1909. X     hphalle3,  hphalle3a, hphalle3b, hphalle3c, hphalle3d, hphalle3e, 
  1910. X     hphalle3f, hphalle3g, hphalle3h, hphalle3i, hphalle3j,
  1911. X     hphalle4,  hphalle4a, hphalle4b, hphalle4c, hphalle4d, hphalle4e, 
  1912. X     hphalle4f, hphalle4g, hphalle4h, hphalle4i, hphalle4j,
  1913. X     hphalle5,  hphalle5a, hphalle5b, hphalle5c, hphalle5d, hphalle5e, 
  1914. X     hphalle5f, hphalle5g, hphalle5h, hphalle5i, hphalle5j,
  1915. X     hphalle6,  hphalle6a, hphalle6b, hphalle6c, hphalle6d, hphalle6e, 
  1916. X     hphalle6f, hphalle6g, hphalle6h, hphalle6i, hphalle6j,
  1917. X     hphalle7,  hphalle7a, hphalle7b, hphalle7c, hphalle7d, hphalle7e, 
  1918. X     hphalle7f, hphalle7g, hphalle7h, hphalle7i, hphalle7j,
  1919. X     hphalle8,  hphalle8a, hphalle8b, hphalle8c, hphalle8d, hphalle8e, 
  1920. X     hphalle8f, hphalle8g, hphalle8h, hphalle8i, hphalle8j,
  1921. X     hphalle9,  hphalle9a, hphalle9b, hphalle9c, hphalle9d, hphalle9e, 
  1922. X     hphalle9f, hphalle9g, hphalle9h, hphalle9i, hphalle9j
  1923. X= {
  1924. X    operating system : HPUX
  1925. X    computer specification {
  1926. X    type                    : HP9000_720
  1927. X    physical memory         : 32 MB    
  1928. X    virtual memory          : 32 MB    
  1929. X    performance index       : 18.0
  1930. X    storage for executables : HPHALLE7disk
  1931. X    }
  1932. X    compilation {
  1933. X        target: HP9000_720 (HPUX) {
  1934. X        CC      = "cc"
  1935. X        CFLAGS  = "-DHPUX -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  1936. X        LDFLAGS = ""
  1937. X        LIBS    = "-lcodelibs"
  1938. X    }
  1939. X    }
  1940. X} # hphalle0, hphalle0a, ... , hphalle9j
  1941. X
  1942. X# definition of host "cony" (inetadr 146.107.1.2)
  1943. Xhost cony.gsf.de = {
  1944. X    operating system : ConvexOS
  1945. X    computer specification {
  1946. X        type:                    CONVEX_C3840
  1947. X        physical memory:         1 GB
  1948. X        virtual memory:          1 GB
  1949. X        performance index:       75
  1950. X        multiprocessor system: 4 processors, shared memory
  1951. X        vector computer
  1952. X        parallelizing compiler
  1953. X        storage for executables: CONVEXdisk
  1954. X    }
  1955. X    compilation {
  1956. X        target: CONVEX_C3840 (ConvexOS) {
  1957. X            CC      = "cc"
  1958. X            CFLAGS  = "-DCONVEX -DBSD -DSOCKET -DHETEROGENEOUS -ext"
  1959. X            LDFLAGS = "-ext"
  1960. X            LIBS    = ""
  1961. X        }
  1962. X    }
  1963. X
  1964. X    accessible filesystems = {
  1965. X        CONVEXdisk (10 ms)
  1966. X    }
  1967. X} # cony.gsf.de
  1968. X
  1969. X# muss noch aktualisiert werden!
  1970. X# definition of host "yel" (inetadr 129.187.14.4)
  1971. Xhost 129.187.14.4 = {
  1972. X    operating system : UNICOS
  1973. X    computer specification {
  1974. X        type:                    CRAY_Y-MP
  1975. X        physical memory:         1 GB    # ???
  1976. X        virtual memory:          1 GB    # ???
  1977. X        performance index:       75    # ???
  1978. X        multiprocessor system: 2 processors, shared memory # ???
  1979. X        vector computer
  1980. X        parallelizing compiler
  1981. X        storage for executables: CRAYdisk
  1982. X    }
  1983. X    compilation {
  1984. X        target: CRAY_Y-MP (UNICOS) {
  1985. X            CC      = "cc"
  1986. X            CFLAGS  = "-DCRAY -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  1987. X            LDFLAGS = ""
  1988. X            LIBS    = ""
  1989. X        }
  1990. X    }
  1991. X} # 129.187.14.4
  1992. X
  1993. Xhost 
  1994. X    odin.botanik.biologie.uni-muenchen.de, 
  1995. X    adgard.botanik.biologie.uni-muenchen.de, 
  1996. X    mitgard.botanik.biologie.uni-muenchen.de, 
  1997. X    utgard.botanik.biologie.uni-muenchen.de, 
  1998. X    baldur.botanik.biologie.uni-muenchen.de, 
  1999. X    freya.botanik.biologie.uni-muenchen.de, 
  2000. X    thor.botanik.biologie.uni-muenchen.de, 
  2001. X    fenris.botanik.biologie.uni-muenchen.de, 
  2002. X    loki.botanik.biologie.uni-muenchen.de, 
  2003. X    hel.botanik.biologie.uni-muenchen.de, 
  2004. X    woelsung.botanik.biologie.uni-muenchen.de, 
  2005. X    ragnaroek.botanik.biologie.uni-muenchen.de, 
  2006. X    sigurd.botanik.biologie.uni-muenchen.de 
  2007. X= {
  2008. X    operating system : AIX
  2009. X    computer specification {
  2010. X        type                    : RS6000
  2011. X        physical memory         : 32 MB
  2012. X        virtual memory          : 32 MB
  2013. X        performance index       : 8.0
  2014. X        storage for executables : ODINdisk
  2015. X    }
  2016. X    compilation {
  2017. X        target: RS6000 (AIX) {
  2018. X            CC      = "cc"
  2019. X            CFLAGS  = "-DAIX -DSYSTEM_V -DSOCKET -DHETEROGENEOUS"
  2020. X            LDFLAGS = ""
  2021. X            LIBS    = ""
  2022. X        }
  2023. X    }
  2024. X} # odin.botanik.biologie.uni-muenchen.de, ...
  2025. X
  2026. Xhost ateickel1 = {
  2027. X    operating system : LINUX
  2028. X    computer specification {
  2029. X        type                    : AT486
  2030. X        physical memory         : 16 MB
  2031. X        virtual memory          : 16 MB
  2032. X        performance index       : 3.0
  2033. X        storage for executables : ATEICKEL1disk
  2034. X    }
  2035. X    compilation {
  2036. X        target: AT486 (LINUX) {
  2037. X            CC      = "cc"
  2038. X            CFLAGS  = "-DLINUX -DSYSTEM_V -DSOCKET -DHOMOGENEOUS"
  2039. X            LDFLAGS = ""
  2040. X            LIBS    = ""
  2041. X        }
  2042. X    }
  2043. X}
  2044. X
  2045. X
  2046. END_OF_FILE
  2047. if test 12406 -ne `wc -c <'examples/config/system.WAN'`; then
  2048.     echo shar: \"'examples/config/system.WAN'\" unpacked with wrong size!
  2049. fi
  2050. # end of 'examples/config/system.WAN'
  2051. fi
  2052. if test -f 'lib/control.c' -a "${1}" != "-c" ; then 
  2053.   echo shar: Will not clobber existing file \"'lib/control.c'\"
  2054. else
  2055. echo shar: Extracting \"'lib/control.c'\" \(11254 characters\)
  2056. sed "s/^X//" >'lib/control.c' <<'END_OF_FILE'
  2057. X/***************************************************************************
  2058. X *                                                                         *
  2059. X * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  2060. X * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  2061. X * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  2062. X * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  2063. X * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  2064. X *                                                                         *
  2065. X *              A compiler for distributed programming with C              *
  2066. X *                                                                         *
  2067. X *                          c o n t r o l . c                              *
  2068. X *                                                                         *
  2069. X *                            Package : Runtime Library                    *
  2070. X *                            Version : 1.0                                *
  2071. X *                       CreationDate : 31.08.90                           *
  2072. X *                         LastUpDate : 06.12.93                           *
  2073. X *                                                                         *
  2074. X *       The routines to control signals and to terminate processes.       *
  2075. X *                                                                         *
  2076. X *     Copyright (C) 1990-1994 by Franz Distler and Christoph Pleier.      *
  2077. X *                          All rights reserved!                           *
  2078. X ***************************************************************************/
  2079. X
  2080. X/*
  2081. X * This file is part of the Distributed C Development Environment (DCDE).
  2082. X * DCDE is free software; you can redistribute it and/or modify
  2083. X * it under the terms written in the README-file. 
  2084. X * DCDE is distributed in the hope that it will be useful,
  2085. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2086. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  2087. X * See the file README for more details.
  2088. X */
  2089. X
  2090. X#include <stdio.h>
  2091. X#include <signal.h>
  2092. X#include <sys/types.h>
  2093. X#ifdef HETEROGENEOUS
  2094. X# include <rpc/rpc.h>
  2095. X#endif
  2096. X#include "ipc.h"
  2097. X#include "dcc.h"
  2098. X#include "run_Errno.h"
  2099. X
  2100. X#define DEBUG_CONTROL /**/
  2101. X
  2102. X#ifdef DEBUG_CONTROL
  2103. X/* the flag to control the debug messages output */
  2104. Xint _debug_control = 0;
  2105. X#endif /* DEBUG_CONTROL /**/
  2106. X
  2107. X#ifdef DEBUG_CONTROL
  2108. X# define DEBUGPUTS(msg)        if (_debug_control) { \
  2109. X                    fprintf(_debugout, "[con] %s %s\n", \
  2110. X                        _processprefix, msg); \
  2111. X                    if (_debugflush) \
  2112. X                        fflush(_debugout); \
  2113. X                }
  2114. X# define DEBUGDISPERR(w, msg)    if (_debug_control) { \
  2115. X                    fprintf(_debugout, "[con] %s error: %s\n", \
  2116. X                        _processprefix, msg); \
  2117. X                    fprintf(_debugout, "[con] %s reason: %s\n",\
  2118. X                        _processprefix, sys_errlist[errno]); \
  2119. X                    if (_debugflush) \
  2120. X                        fflush(_debugout); \
  2121. X                }
  2122. X#else
  2123. X# define DEBUGPUTS(msg)        { /* nothing */ }
  2124. X# define DEBUGDISPERR(msg)    { /* nothing */ }
  2125. X#endif
  2126. X
  2127. X/******************************************************************************
  2128. X * _set_signals()                                                             *
  2129. X *                                                                            *
  2130. X * Catches all signals which default action is to terminate the program using *
  2131. X * '_catch'.                                                                  *
  2132. X *                                                                            *
  2133. X * Return value: none!                                                        *
  2134. X ******************************************************************************/
  2135. Xint
  2136. X_set_signals()
  2137. X{
  2138. X    register int i;
  2139. X#if defined(HPUX) || defined(UNICOS) || defined(LINUX)
  2140. X    void _Exit();
  2141. X#else
  2142. X    int _Exit();
  2143. X#endif /* HPUX || UNICOS || LINUX /**/
  2144. X    
  2145. X    DEBUGPUTS("catching signals");
  2146. X    for(i = 1; i <= NSIG; ++i) {
  2147. X        switch(i) {
  2148. X        case SIGUSR1:
  2149. X            /* SIGUSR1 is used to force processes to terminate! 
  2150. X             * See also destruction.c
  2151. X             */
  2152. X            signal(i, _Exit);
  2153. X            break;
  2154. X        case SIGHUP:
  2155. X        case SIGALRM:
  2156. X        case SIGUSR2:
  2157. X#ifdef SIGCLD
  2158. X        case SIGCLD:
  2159. X#else
  2160. X        case SIGCHLD:
  2161. X#endif /* SIGCLD /**/
  2162. X            continue;
  2163. X        default:
  2164. X            signal(i, _catch);
  2165. X        }
  2166. X    }
  2167. X#ifdef UNICOS
  2168. X    signal(SIGINFO, SIG_IGN);
  2169. X#endif /* UNICOS /**/
  2170. X} /* _set_signals */
  2171. X
  2172. X/******************************************************************************
  2173. X * _catch()                                                                   *
  2174. X *                                                                            *
  2175. X * '_catch' will be called when a signal occurs. It then displays the signal  *
  2176. X * type on stdout and finally calles the signal by itsself to perform the     *
  2177. X * default action.                                                            *
  2178. X *                                                                            *
  2179. X * Return value: none!                                                        *
  2180. X ******************************************************************************/
  2181. X#if defined(HPUX) || defined(UNICOS) || defined(LINUX)
  2182. Xvoid 
  2183. X#else
  2184. Xint
  2185. X#endif
  2186. X_catch(sig)
  2187. Xint sig;
  2188. X{
  2189. X    char *what;
  2190. X    static char kind[40];
  2191. X
  2192. X    signal(sig, SIG_IGN);
  2193. X    switch(sig) {
  2194. X    case SIGHUP:
  2195. X        what = "Hangup";
  2196. X        break;
  2197. X    case SIGINT:
  2198. X        what = "Interrupt";
  2199. X        break;
  2200. X    case SIGQUIT:
  2201. X        what = "Quit";
  2202. X        break;
  2203. X    case SIGILL:
  2204. X        what = "Illegal instruction";
  2205. X        break;
  2206. X    case SIGTRAP:
  2207. X        what = "Trace trap";
  2208. X        break;
  2209. X#ifdef SIGIOT
  2210. X    case SIGIOT:
  2211. X        what = "I/O trap instruction";
  2212. X        break;
  2213. X#else    /* Do not delete this else! */
  2214. X# ifdef SIGABRT
  2215. X    case SIGABRT:
  2216. X        what = "abort";
  2217. X        break;
  2218. X# endif
  2219. X#endif
  2220. X#ifdef SIGEMT
  2221. X    case SIGEMT:
  2222. X        what = "Emulator trap instruction";
  2223. X        break;
  2224. X#endif
  2225. X    case SIGFPE:
  2226. X        what = "Floating-point exception";
  2227. X        break;
  2228. X    case SIGBUS:
  2229. X        what = "Bus error";
  2230. X        break;
  2231. X    case SIGSEGV:
  2232. X        what = "Segmentation violation";
  2233. X        break;
  2234. X#ifdef SIGSYS
  2235. X    case SIGSYS:
  2236. X        what = "Bad argument to system call";
  2237. X        break;
  2238. X#endif
  2239. X    case SIGPIPE:
  2240. X        what = "Write on a pipe with no one to read it";
  2241. X        break;
  2242. X    case SIGALRM:
  2243. X        what = "Alarm clock";
  2244. X        break;
  2245. X    case SIGTERM:
  2246. X        what = "Software termination signal";
  2247. X        break;
  2248. X    case SIGUSR1:
  2249. X        what = "User defined signal 1";
  2250. X        break;
  2251. X    case SIGUSR2:
  2252. X        what = "User defined signal 2";
  2253. X        break;
  2254. X#ifdef SIGCLD
  2255. X    case SIGCLD:
  2256. X#else
  2257. X    case SIGCHLD:
  2258. X#endif /* SIGCLD /**/
  2259. X        what = "Death of a child";
  2260. X        break;
  2261. X    default:
  2262. X        sprintf(kind, "unknown kind (number %d)", sig);
  2263. X        what = kind;
  2264. X    } /* switch */
  2265. X#ifndef DEBUG
  2266. X# ifdef SIGCLD
  2267. X    if (sig!=SIGALRM && sig!=SIGUSR1 && sig!=SIGUSR2 && sig!=SIGCLD){
  2268. X# else
  2269. X    if (sig!=SIGALRM && sig!=SIGUSR1 && sig!=SIGUSR2 && sig!=SIGCHLD){
  2270. X# endif /* SIGCLD /**/
  2271. X        fprintf(stdout, "***** PROGRAM TERMINATED BY SIGNAL ******\n");
  2272. X# ifdef iPSC
  2273. X        fprintf(stdout, "PROGRAM: %s, PROCESS: %s, NODE: %ld, PID: %ld\n", 
  2274. X            _programname, _processname, mynode(), mypid());
  2275. X# else
  2276. X#  ifdef SINGLE
  2277. X        fprintf(stdout, "PROGRAM: %s, PROCESS: %s, PID: %d\n",
  2278. X            _programname, _processname, getpid());
  2279. X#  else /* HOMOGENEOUS || HETEROGENEOUS */
  2280. X        fprintf(stdout, "PROGRAM: %s, PROCESS: %s, HOST: %s, PID: %d\n", 
  2281. X            _programname, _processname, _own_port.hostname, getpid());
  2282. X#  endif /* SINGLE /**/
  2283. X# endif /* iPSC /**/
  2284. X        fprintf(stdout, "Signal: %s\n", what);
  2285. X        fflush(stdout);
  2286. X    }
  2287. X#else
  2288. X    if (_debug_control) {
  2289. X        fprintf(_debugout, "[con] %s Signal received: %s\n",
  2290. X        _processprefix, what);
  2291. X        if (_debugflush)
  2292. X        fflush(_debugout);
  2293. X    }
  2294. X#endif /* Not DEBUG /**/
  2295. X    signal(sig, SIG_DFL);
  2296. X    if (strcmp(_processname, "administration process")) {
  2297. X#ifdef SOCKET
  2298. X        _own_port.state = CONNECTIONLESS;    /* DIRTY PROGRAMMING! */
  2299. X#endif /* SOCKET /**/
  2300. X        _notify_admin_process(NOTIFY_ERROR);
  2301. X    }
  2302. X    /* force a core dump! */
  2303. X    abort();
  2304. X} /* _catch */
  2305. X
  2306. X/******************************************************************************
  2307. X * _Exit()                                                                    *
  2308. X *                                                                            *
  2309. X * Notifies the administration process the termination, deletes the port and  *
  2310. X * terminates.                                                                *
  2311. X *                                                                            *
  2312. X * Return values: none!                                                       *
  2313. X ******************************************************************************/
  2314. X#if defined(HPUX) || defined(UNICOS) || defined(LINUX)
  2315. Xvoid
  2316. X#else
  2317. Xint
  2318. X#endif
  2319. X_Exit(code)
  2320. Xint code;
  2321. X{
  2322. X    int waitflag = TRUE;
  2323. X
  2324. X    if (!strcmp(_processname, "main process")) {
  2325. X        /* The main process must be the last process to terminate.
  2326. X             * This must be ensured to handle the terminal redirections
  2327. X             * (by rsh) correctly.
  2328. X             * We guarrantee this by simulating a select-statement with
  2329. X             * terminate-alternative.
  2330. X             */
  2331. X        fprintf(stderr, "main process: waiting for all processes to terminate!\n");
  2332. X            _notify_admin_process(NOTIFY_ACCORTER_ON);
  2333. X            while(waitflag) {
  2334. X                char *request;
  2335. X                static TRANSDATA transdata;
  2336. X
  2337. X                /* get connection */
  2338. X                (void) _accept_connection(&_con_port, &_own_port, 0);
  2339. X                /* check connection type */
  2340. X                if (_receive_connection_type_or_answer() != TRANSACTION_CONNECTION) {
  2341. X                        if (_send_connection_type_or_answer(ABORT_CONNECTION))
  2342. X                                _RuntimeError("sending connection answer");
  2343. X                        if (_close_connection(&_con_port))
  2344. X                                _RuntimeError("closing connection");
  2345. X                        continue;
  2346. X                } else {
  2347. X                        if (_send_connection_type_or_answer(ACCEPT_CONNECTION))
  2348. X                                _RuntimeError("sending connection answer");
  2349. X                }
  2350. X                /* get transaction request */
  2351. X#if defined(SINGLE) || defined(HOMOGENEOUS)
  2352. X                if (_recv_data(&_con_port, (char *) &transdata, sizeof(TRANSDATA), 30)<0) {
  2353. X#else
  2354. X                if (_recv_data_encoded(&_con_port, (char *) &transdata, xdr_TRANSDATA, 30)<0) {
  2355. X#endif /* SINGLE || HOMOGENEOUS /**/
  2356. X                        if (Errno == ETIMEOUT)
  2357. X                                Errno = ETSRCVREQUEST;
  2358. X                        _RuntimeError("simulating terminate-Alternative in main process");
  2359. X                }
  2360. X                request = transdata.request;
  2361. X                /* terminate alternative */
  2362. X                if (!strcmp(request, "TRANS_TERMINATE")) {
  2363. X                        (void) _close_connection(&_con_port);
  2364. X            waitflag = FALSE;
  2365. X                } else {
  2366. X                    _SendTransCallReply(TRANS_DENIED);
  2367. X                    if (_close_connection(&_con_port))
  2368. X                        _RuntimeError("closing connection");
  2369. X        }
  2370. X            } /* while */
  2371. X        fprintf(stderr, "main process: all processes have terminated! Terminating.\n");
  2372. X    } 
  2373. X
  2374. X#ifdef SOCKET
  2375. X    _own_port.state = CONNECTIONLESS;    /* DIRTY PROGRAMMING! */
  2376. X#endif /* SOCKET /**/
  2377. X    DEBUGPUTS("notifying admin process");
  2378. X    _notify_admin_process(NOTIFY_END);
  2379. X    (void) _delete_port(&_own_port);
  2380. X    DEBUGPUTS("terminating by exit()");
  2381. X    exit(code);
  2382. X} /* _Exit */
  2383. END_OF_FILE
  2384. if test 11254 -ne `wc -c <'lib/control.c'`; then
  2385.     echo shar: \"'lib/control.c'\" unpacked with wrong size!
  2386. fi
  2387. # end of 'lib/control.c'
  2388. fi
  2389. echo shar: End of archive 9 \(of 18\).
  2390. cp /dev/null ark9isdone
  2391. MISSING=""
  2392. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  2393.     if test ! -f ark${I}isdone ; then
  2394.     MISSING="${MISSING} ${I}"
  2395.     fi
  2396. done
  2397. if test "${MISSING}" = "" ; then
  2398.     echo You have unpacked all 18 archives.
  2399.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2400. else
  2401.     echo You still need to unpack the following archives:
  2402.     echo "        " ${MISSING}
  2403. fi
  2404. ##  End of shell archive.
  2405. exit 0
  2406.