1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
/*
|| ----------------------------------------------------------------------------
||
|| HETLIB.C (c) Copyright Leland Lucius, 2000-2003
|| Released under terms of the Q Public License.
||
|| Creates IEHINITT or NL format Hercules Emulated Tapes.
||
|| ----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "hetlib.h"
#include "sllib.h"
#include "hercules.h"
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
/*
|| Local constant data
*/
static const char help[] =
"%s - Initialize a tape\n\n"
"Usage: %s [options] filename [volser] [owner]\n\n"
"Options:\n"
" -d disable compression\n"
" -h display usage summary\n"
" -i create an IEHINITT formatted tape (default: on)\n"
" -n create an NL tape\n";
#ifdef EXTERNALGUI
/* Special flag to indicate whether or not we're being
run under the control of the external GUI facility. */
int extgui = 0;
#endif /*EXTERNALGUI*/
/*
|| Prints usage information
*/
static void
usage( char *name )
{
printf( help, name, name );
}
/*
|| Standard main() function
*/
int
main( int argc, char *argv[] )
{
int rc;
SLLABEL lab;
HETB *hetb;
int o_iehinitt;
int o_nl;
int o_compress;
char *o_filename;
char *o_owner;
char *o_volser;
#ifdef EXTERNALGUI
if (argc >= 1 && strncmp(argv[argc-1],"EXTERNALGUI",11) == 0)
{
extgui = 1;
argc--;
}
#endif /*EXTERNALGUI*/
hetb = NULL;
o_filename = NULL;
o_iehinitt = TRUE;
o_nl = FALSE;
o_compress = TRUE;
o_owner = NULL;
o_volser = NULL;
/* Display the program identification message */
display_version (stderr, "Hercules HET IEHINITT program ");
while( TRUE )
{
rc = getopt( argc, argv, "dhin" );
if( rc == -1 )
{
break;
}
switch( rc )
{
case 'd':
o_compress = FALSE;
break;
case 'h':
usage( argv[ 0 ] );
goto exit;
break;
case 'i':
o_iehinitt = TRUE;
o_nl = FALSE;
break;
case 'n':
o_iehinitt = FALSE;
o_nl = TRUE;
break;
default:
usage( argv[ 0 ] );
goto exit;
break;
}
}
argc -= optind;
if( argc < 1 )
{
usage( argv[ 0 ] );
goto exit;
}
o_filename = argv[ optind ];
if( o_iehinitt )
{
if( argc == 2 )
{
o_volser = argv[ optind + 1 ];
}
else if( argc == 3 )
{
o_volser = argv[ optind + 1 ];
o_owner = argv[ optind + 2 ];
}
else
{
usage( argv[ 0 ] );
goto exit;
}
}
if( o_nl )
{
if( argc != 1 )
{
usage( argv[ 0 ] );
goto exit;
}
}
rc = het_open( &hetb, o_filename, HETOPEN_CREATE );
if( rc < 0 )
{
printf( "het_open() returned %d\n", rc );
goto exit;
}
rc = het_cntl( hetb, HETCNTL_SET | HETCNTL_COMPRESS, o_compress );
if( rc < 0 )
{
printf( "het_cntl() returned %d\n", rc );
goto exit;
}
if( o_iehinitt )
{
sl_vol1( &lab, o_volser, o_owner );
rc = het_write( hetb, &lab, sizeof( lab ) );
if( rc < 0 )
{
printf( "het_write() for VOL1 returned %d\n", rc );
goto exit;
}
sl_hdr1( &lab, SL_INITDSN, NULL, 0, 0, NULL, 0 );
rc = het_write( hetb, &lab, sizeof( lab ) );
if( rc < 0 )
{
printf( "het_write() for HDR1 returned %d\n", rc );
goto exit;
}
}
else if( o_nl )
{
rc = het_tapemark( hetb );
if( rc < 0 )
{
printf( "het_tapemark() returned %d\n", rc );
goto exit;
}
}
rc = het_tapemark( hetb );
if( rc < 0 )
{
printf( "het_tapemark() returned %d\n", rc );
goto exit;
}
exit:
het_close( &hetb );
return( rc < 0 );
}
|