



		    convert_old_basic_file.pl1      11/18/82  1709.0rew 11/18/82  1630.2       15498



/* ***********************************************************
   *                                                         *
   * Copyright, (C) Honeywell Information Systems Inc., 1982 *
   *                                                         *
   * Copyright (c) 1972 by Massachusetts Institute of        *
   * Technology and Honeywell Information Systems, Inc.      *
   *                                                         *
   *********************************************************** */


convert_old_basic_file:  proc;

/* This command converts and old format basic file to vfile_ format */
/* coded 2/76 by M. Weaver */

dcl arg char(alng) based(aptr);
dcl dirname char(168);
dcl entname char(32);
dcl me char(22) aligned init("convert_old_basic_file");

dcl alng fixed bin;
dcl code fixed bin(35);
dcl error_table_$not_done fixed bin(35) ext;
dcl aptr ptr;

dcl addr builtin;
dcl cu_$arg_ptr entry (fixed bin, ptr, fixed bin, fixed bin(35));
dcl expand_path_ entry (ptr, fixed bin, ptr, ptr, fixed bin(35));
dcl convert_old_basic_file_ entry (char(*), char(*), fixed bin(35));
dcl (com_err_, ioa_) entry options(variable);



	call cu_$arg_ptr (1,  aptr, alng, code);	/* pick up pathname of original file */
	if code ^= 0 then do;
	     call com_err_ (code, me);
	     return;
	end;

	call expand_path_ (aptr, alng, addr(dirname), addr(entname), code);
	if code ^= 0 then do;
error:	     call com_err_ (code, me, arg);
	     return;
	     end;

	call convert_old_basic_file_ (dirname, entname, code);
	if code ^= 0 then do;		/* file wasn't converted */
	     if code = error_table_$not_done
	     then call ioa_ ("File ^a did not need converting", arg);
	     else goto error;
	end;

	return;
	end;
  



		    convert_old_basic_file_.pl1     11/18/82  1709.0rew 11/18/82  1630.2       63279



/* ***********************************************************
   *                                                         *
   * Copyright, (C) Honeywell Information Systems Inc., 1982 *
   *                                                         *
   * Copyright (c) 1972 by Massachusetts Institute of        *
   * Technology and Honeywell Information Systems, Inc.      *
   *                                                         *
   *********************************************************** */


/* This procedure converts old format basic random foramt files to new format
   files which are maintained by vfile_.  Access and quota on the old file
   must be adequate. */

/* coded 76.1.19 by M. Weaver */

convert_old_basic_file_: proc (dir, ent, code);

dcl (dir, ent) char (*);
dcl  code fixed bin (35);

dcl (i, k, dlng, margin) fixed bin;
dcl  type fixed bin (2);
dcl  bitcnt fixed bin (24);
dcl (old_ptr, new_ptr, iocb_ptr, arrayp, fcb_pt) ptr;
dcl  new_path char (168) var;
dcl  dirname char (168);
dcl  entname char (32);

dcl  fixed_dec_value fixed dec (7);
dcl  fixed_digits char (8) aligned based (addr (fixed_dec_value));

dcl  unique_count fixed dec (6) static init (0);
dcl 1 unique_value static,
    2 header char (11) init ("convert_bf."),
    2 count picture "999999";

dcl  based_array (1) ptr based (arrayp);

dcl 1 random_numeric aligned based,
    2 header bit (36),
    2 count fixed bin (18),
    2 value (i) float bin;

dcl 1 d_random_numeric aligned based,
    2 header bit (36),
    2 count fixed bin (18),
    2 value (i) float bin (63);

dcl 1 random_string aligned based,
    2 header unaligned,
      3 flag bit (18),
      3 max_length fixed bin (12),
    2 count fixed bin,
    2 value (i),
      3 vlng fixed bin,
      3 vstring char (margin);

dcl (stream_input_output init(3),
     sequential_update init(7)) fixed bin static options(constant);

dcl  error_table_$not_done ext fixed bin (35);

dcl (addr, convert, index, min, null, string, substr, verify) builtin;
dcl  cleanup condition;

dcl  hcs_$initiate entry (char (*), char (*), char (*), fixed bin, fixed bin, ptr, fixed bin (35));
dcl  hcs_$terminate_noname entry (ptr, fixed bin (35));
dcl  get_temp_segments_ entry (char (*), (*) ptr, fixed bin (35));
dcl  release_temp_segments_ entry (char (*), (*) ptr, fixed bin (35));
dcl  hcs_$fs_get_path_name entry (ptr, char (*), fixed bin, char (*), fixed bin (35));
dcl  iox_$attach_ioname entry (char (*), ptr, char (*), fixed bin (35));
dcl  iox_$open entry (ptr, fixed bin, bit (1) aligned, fixed bin (35));
dcl  iox_$put_chars entry (ptr, ptr, fixed bin (21), fixed bin (35));
dcl  iox_$write_record entry (ptr, ptr, fixed bin (21), fixed bin (35));
dcl  iox_$close entry (ptr, fixed bin (35));
dcl  iox_$detach_iocb entry (ptr, fixed bin (35));
dcl  iox_$destroy_iocb entry (ptr, fixed bin (35));
dcl  hcs_$fs_move_seg entry (ptr, ptr, fixed bin (1), fixed bin (35));
dcl  hcs_$status_mins entry (ptr, fixed bin (2), fixed bin (24), fixed bin (35));
dcl  hcs_$set_bc_seg entry (ptr, fixed bin (24), fixed bin (35));

	
%include iocb;
	

/* must always initiate original file so we can look at it */

	call hcs_$initiate (dir, ent, "", 0, 0, old_ptr, code);
	if old_ptr = null then return;

	if old_ptr -> random_string.header.flag ^= (18)"1"b then do; /* terminal format file */
	     call hcs_$terminate_noname (old_ptr, code);
	     code = error_table_$not_done;		/* special code to indicate no conversion necessary */
	     return;
	end;

	iocb_ptr, new_ptr = null;
	on cleanup call clean_up;

	arrayp = addr (new_ptr);
	code = 0;			/* temporary  kludge for get_temp_segments_ */
	call get_temp_segments_ ("convert_old_basic_file_", based_array, code);
	if code ^= 0 then goto finish;

	call hcs_$fs_get_path_name (new_ptr, dirname, dlng, entname, code);
	if code ^= 0 then goto finish;
	k = index (entname, " ");
	if k = 0 then k = 33;
	new_path = substr (dirname, 1, dlng) || ">" || substr (entname, 1, k-1);

/* get switchname; use unique ionames so program will be reentrant */

	unique_count = unique_count + 1;
	unique_value.count = unique_count;
	i = 1;

	if old_ptr -> random_numeric.header = (36)"1"b then do;
	     call iox_$attach_ioname (string (unique_value), iocb_ptr, "vfile_ "
		|| new_path || " -no_trunc -header 1 -ssf", code);
	     if code ^= 0 then goto finish;

	     call iox_$open (iocb_ptr, stream_input_output, "0"b, code);
	     if code ^= 0 then goto finish;

	     call iox_$put_chars (iocb_ptr, addr (old_ptr -> random_numeric.value (1)), 
		4 * old_ptr -> random_numeric.count, code);
	     if code ^= 0 then goto finish;
	end;

	else if old_ptr -> d_random_numeric.header = "111111111111111111010101010101010101"b then do;

	     call iox_$attach_ioname (string (unique_value), iocb_ptr, "vfile_ " ||
		new_path || " -no_trunc -header 2 -ssf", code);
	     if code ^= 0 then goto finish;

	     call iox_$open (iocb_ptr, stream_input_output, "0"b, code);
	     if code ^= 0 then goto finish;

	     call iox_$put_chars (iocb_ptr, addr (old_ptr -> random_numeric.value (1)), 
		8 * old_ptr -> d_random_numeric.count, code);
	     if code ^= 0 then goto finish;
	end;

	else do;					/* must be random string file */

	     margin = old_ptr -> random_string.header.max_length;
	     fixed_dec_value = convert (fixed_dec_value, margin);
	     k = verify (substr (fixed_digits, 2), "0");

	     call iox_$attach_ioname (string (unique_value), iocb_ptr, "vfile_ " ||
		new_path || " -blocked " || substr (fixed_digits, k+1) || " -ssf", code);
	     if code ^= 0 then goto finish;

	     call iox_$open (iocb_ptr, sequential_update, "0"b, code);
	     if code ^= 0 then goto finish;

	     do i = 1 to old_ptr -> random_string.count;
		call iox_$write_record (iocb_ptr, addr (old_ptr -> random_string.value (i).vstring),
		     min (old_ptr -> random_string.value (i).vlng, margin), code);
		if code ^= 0 then goto finish;
	     end;
	end;


finish:	call clean_up;
	return;



clean_up:	proc;

dcl  ecode fixed bin (35);				/* don't want to disturb returned code */

	     ecode = -1;
	     if iocb_ptr ^= null then do;		/* clean up iox stuff */
		if iocb_ptr -> iocb.open_descrip_ptr ^= null
		then call iox_$close (iocb_ptr, ecode);

		if ecode <= 0
		then if iocb_ptr -> iocb.attach_descrip_ptr ^= null
		     then call iox_$detach_iocb (iocb_ptr, ecode);

		if ecode = 0 then call iox_$destroy_iocb (iocb_ptr, ecode);

		if code = 0 then do;		/* assume file was converted */
		     call hcs_$fs_move_seg (new_ptr, old_ptr, 1, code); /* replace file */
		     if code = 0 then do;
			call hcs_$status_mins (new_ptr, type, bitcnt, ecode); /* important to get bit count */
			call hcs_$set_bc_seg (old_ptr, bitcnt, ecode); /* tells vfile_ how much info */
		     end;
		end;

	     end;

	     call hcs_$terminate_noname (old_ptr, ecode);

	     if new_ptr ^= null then do;
		call hcs_$set_bc_seg (new_ptr, 0, ecode);
		call release_temp_segments_ ("convert_old_basic_file_", based_array, ecode);
	     end;

	     return;
	end;

     end;




		    bull_copyright_notice.txt       08/30/05  1008.4r   08/30/05  1007.3    00020025

                                          -----------------------------------------------------------


Historical Background

This edition of the Multics software materials and documentation is provided and donated
to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. 
as a contribution to computer science knowledge.  
This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology,
Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull
and Bull HN Information Systems Inc. to the development of this operating system. 
Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970),
renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership
of Professor Fernando Jose Corbato.Users consider that Multics provided the best software architecture for 
managing computer hardware properly and for executing programs. Many subsequent operating systems
incorporated Multics principles.
Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., 
as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. .

                                          -----------------------------------------------------------

Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without
fee is hereby granted,provided that the below copyright notice and historical background appear in all copies
and that both the copyright notice and historical background and this permission notice appear in supporting
documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining
to distribution of the programs without specific prior written permission.
    Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc.
    Copyright 2006 by Bull HN Information Systems Inc.
    Copyright 2006 by Bull SAS
    All Rights Reserved
