|
|
|
Below is a sample program illustrating the usage of the Magneto-Optical AIFs.
It allocates the first available drive that can access the media labeled
MYMEDIA, mounts the media MYMEDIA on this drive, accesses files on the media
and then dismounts the media and deallocates the drive.
To compile the source code for HFSPATH:
pasxl hfspath.pas
link from=$oldpass;to=hfspathp.pub;cap=ia,pm
This is the source code for program DIRMO:
or
View in browser
Runtime Example Output
$standard_level 'ext_modcal'$
$list off$
Program MO_Sample ( input, output );
Type
media_label_type = record
media_name : packed array [1..32] of char;
subname1 : packed array [1..16] of char;
subname2 : packed array [1..16] of char;
end;
name_type = packed array [1..16] of char;
status_type = record
case boolean of
true : (all: integer);
false : (info: shortint;
subsys: shortint );
end;
item_status_array_type = array [1..4] of status_type;
Var
drive_ldev : integer;
itemnum_array : packed array [1..4] of integer;
item_array : packed array [1..4] of globalanyptr;
item_status_array : item_status_array_type;
media_id : media_label_type;
overall_status : status_type;
user_id : integer;
volume_set : packed array[1..8] of char;
procedure GETPRIVMODE; intrinsic;
procedure QUIT; intrinsic;
$sysintr 'aifintr.pub.sys'$
procedure AIFMOALLOCATE; intrinsic;
procedure AIFMODEALLOCATE; intrinsic;
procedure AIFMOMOUNT; intrinsic;
procedure AIFMODISMOUNT; intrinsic;
{-------------------- Print error and bail out --------------------}
procedure ERROR_IN_CALL ( status : status_type;
name : name_type;
item_status_array : item_status_array_type);
Var
local_status : status_type;
begin
writeln('Error in ', name);
if (status.all < 0) then
writeln ( 'Overall status info = ', status.info, ' subsys= ',
status.subsys )
else
begin
local_status.all := item_status_array[status.info].all;
writeln ( 'Item #: ', status.info:1, ' status info = ',
local_status.info:1, ' subsys = ',
local_status.subsys:1 );
end;
QUIT(999);
end;
begin
{--------------------------- Get AIF user ID ----------------------}
GETPRIVMODE;
writeln('Enter a valid user id:');
readln (user_id);
{--- Allocate a drive that can access the media labeled MYMEDIA ---}
itemnum_array[1] := 17103; { Allocate by media name }
media_id.media_name := 'MYMEDIA';
media_id.subname1 := '@'; { Ignore subname1 }
media_id.subname2 := '@'; { Ignore subname2 }
item_array[1] := addr(media_id);
item_status_array[1].all := 0;
itemnum_array[2] := 0;
AIFMOALLOCATE ( overall_status,
drive_ldev, {The allocated drive is returned in}
itemnum_array, {drive_ldev}
item_array,
item_status_array,
user_id );
if overall_status.all <> 0 then
ERROR_IN_CALL (overall_status, 'AIFMOALLOCATE',
item_status_array);
{---- Mount the media labeled MYMEDIA in the allocated drive ------}
{---- and return the volume set name for this media. --------------}
itemnum_array[1] := 17303; { Return volume set name }
item_array[1] := addr(volume_set);
item_status_array[1].all := 0;
itemnum_array[2] := 0;
AIFMOMOUNT ( overall_status,
drive_ldev,
media_id,
itemnum_array,
item_array,
item_status_array,
user_id );
if overall_status.all <> 0 then
ERROR_IN_CALL(overall_status, 'AIFMOMOUNT',
item_status_array);
{------------------------------------------------------------------}
{------------------------------------------------------------------}
{ At this point, the media (volume set) is mounted and can be used }
{ like any other user volume set. Groups and accounts can be }
{ created programmatically or through commands }
{ (for example, NEWGROUP;ONVS= ) }
{ and files can also be created on the media (for example, }
{ HPFOPEN, BUILD). }
{------------------------------------------------------------------}
{------------------------------------------------------------------}
{----------------------- Dismount the media -----------------------}
AIFMODISMOUNT ( overall_status,
drive_ldev,
,
,
,
user_id );
if overall_status.all <> 0 then
ERROR_IN_CALL (overall_status, 'AIFMODISMOUNT',
item_status_array);
{-------------------- Deallocate the drive ------------------------}
AIFMODEALLOCATE ( overall_status,
drive_ldev,
,
,
,
user_id );
if overall_status.all <> 0 then
ERROR_IN_CALL ( overall_status, 'AIFMODEALLOCATE',
item_status_array );
end.
|