static int action_get_title_group_settings(const char *path, const char *label, unsigned menu_type, char *s, size_t len) { char elem0[PATH_MAX_LENGTH] = {0}; char elem1[PATH_MAX_LENGTH] = {0}; struct string_list *list_label = string_split(label, "|"); if (list_label) { if (list_label->size > 0) { strlcpy(elem0, list_label->elems[0].data, sizeof(elem0)); if (list_label->size > 1) strlcpy(elem1, list_label->elems[1].data, sizeof(elem1)); } string_list_free(list_label); } strlcpy(s, string_to_upper(elem0), len); if (elem1[0] != '\0') { strlcat(s, " - ", len); strlcat(s, string_to_upper(elem1), len); } return 0; }
void Box::RemoveProgramRecorded() { string name; int aux = -1; bool found = false; cout << "Insert a Program's name: "; cin.clear(); cin.ignore(); getline(cin, name); cout << endl << endl << endl; for (int i = 0; i < recordList.size(); i++) { if (string_to_upper(recordList[i].getName()) == string_to_upper(name)) { recordList.erase(recordList.begin() + i); saveRecorded(); cout << "The program \"" << name; cout << "\", was sucefully removed from the list\n"; cout << "of recorded programs." << endl << endl << endl << endl; found = true; } } if (found == false) { cout << "The program \"" << name << "\", isn't in the list of recorded programs." << endl << endl << endl << endl; } }
void Box::rentMovies(const string &title){ bool mfound = false, sfound = false; for (int i = 0; i < movieClub.size(); i++) { if (string_to_upper(title) == string_to_upper(movieClub[i].getTitle())) { mfound = true; movieClub[i].addTimesRented(); seenMovies.push_back(movieClub[i]); movieClub.erase(movieClub.begin() + i); cout << "The movie \"" << seenMovies[seenMovies.size() - 1].getTitle() << "\" was rent by the MovieClub."; cout << endl << endl << endl << endl; break; } } if (!mfound) for (int i = 0; i < seenMovies.size(); i++) { if (string_to_upper(title) == string_to_upper(seenMovies[i].getTitle())) { sfound = true; seenMovies[i].addTimesRented(); cout << "The movie \"" << seenMovies[i].getTitle() << "\" was rent again."; cout << endl << endl << endl << endl; break; } } if (!mfound && !sfound) cout << "The movie \"" << title << "\"" << " doesn't exist." << endl << endl << endl << endl; }
bool Box::Whatched(const string &title){ for (int i = 0; i < seenMovies.size(); i++) { if (string_to_upper(title) == string_to_upper(seenMovies[i].getTitle())) { return true; } } return false; }
bool Box::exist_in_movieClub(const string &title){ for (int i = 0; i < movieClub.size(); i++) { if (string_to_upper(title) == string_to_upper(movieClub[i].getTitle())) { return true; } } return false; }
int Box::searchChannel(string &channel_name){ for (int i = 0; i < channels.size(); i++) { if (string_to_upper(channels[i].getName()) == string_to_upper(channel_name) || channels[i].getName() == string_to_upper(channel_name)) { return i; } } return -1; }
void Box::show_timesWhatched(const string &title){ for (int i = 0; i < seenMovies.size(); i++) { if (string_to_upper(title) == string_to_upper(seenMovies[i].getTitle())) { cout << "NAME" << setw(40) << "COST (EUR)" << setw(20) << "TIMES WATCHED" << endl; cout << seenMovies.at(i).getTitle() << setw(40 - seenMovies.at(i).getTitle().length()) << seenMovies.at(i).getCost(); cout << setw(15) << seenMovies.at(i).getTimesRented() << endl; break; } } }
vector<Program> Box::listByType(string &type){ vector<Program> listByType; for (int i = 0; i < channels.size(); i++) { for (int j = 0; j < channels[i].getPrograms().size(); j++) if (string_to_upper(channels[i].getPrograms()[j].getType()) == string_to_upper(type)) { listByType.push_back(channels[i].getPrograms()[j]); } } sort(listByType.begin(), listByType.end(), compareDate); return listByType; }
int Box::searchProgram(string &program_name, Channel &channel){ // Se encontrar o programa na lista de programas, retorna a posição do programa no vetor, senão retorna -1 for (int i = 0; i < channel.getPrograms().size(); i++) { if (string_to_upper(channel.getPrograms()[i].getName()) == string_to_upper(program_name)) { return i; } } return -1; }
void Box::SetProgramRecorded() { string name; int aux=-1; int i = 0; cout << "Insert a Program's name: "; cin.clear(); cin.ignore(); getline(cin, name); cout << endl << endl << endl; int existInRecord = false; for (int j = 0; j < recordList.size(); j++) { if (string_to_upper(name) == string_to_upper(recordList[j].getName())) { existInRecord = true; cout << "The program \"" << name << "\", is in the list of recorded programs." << endl << endl << endl << endl; break; } } if (!existInRecord) { for (i; i < channels.size(); i++) { aux = searchProgram(string_to_upper(name), channels[i]); if (aux >= 0) { break; } } if (aux >= 0) { if (compDates(GetCurrentDate(), channels[i].getPrograms()[aux].getDate())) { cout << "The program \"" << channels[i].getPrograms()[aux].getName(); cout << "\", from the channel \"" << channels[i].getName() << "\", was sucefully\n"; cout << "set to be recorded." << endl << endl << endl << endl; recordList.push_back(channels[i].getPrograms()[aux]); } else { cout << "The program \"" << channels[i].getPrograms()[aux].getName(); cout << "\", from the channel \"" << channels[i].getName() << "\", has been reproduced." << endl << endl << endl << endl; } } else cout << "The program \"" << name << "\" doesn't exist." << endl << endl << endl << endl; } }
int select_flag( char *flag ) { static int result; int i = 0; int found = FALSE; char *p; //p = strupr( plain_text( flag ) ); p = plain_text( flag ); string_to_upper( p ); while ( !found && i < flag_count ) { if ( 0 == strcmp( p, FLAGS[ i ].name ) ){ found = TRUE; result = i; } i++; } if ( !found ) { create_new_flag( p ); result = flag_count - 1; } return result; }
static GC* gc_unique_decide_collection_algo(char* unique_algo, Boolean has_los) { /* if unique_algo is not set, gc_gen_decide_collection_algo is called. */ assert(unique_algo); GC_PROP = ALGO_POOL_SHARE | ALGO_DEPTH_FIRST | ALGO_IS_UNIQUE; assert(!has_los); /* currently unique GCs don't use LOS */ if(has_los) GC_PROP |= ALGO_HAS_LOS; Boolean use_default = FALSE; GC* gc; string_to_upper(unique_algo); if(!strcmp(unique_algo, "MOVE_COMPACT")){ GC_PROP |= ALGO_COMPACT_MOVE; gc = gc_mc_create(); }else if(!strcmp(unique_algo, "MARK_SWEEP")){ GC_PROP |= ALGO_MS_NORMAL; gc = gc_ms_create(); }else{ LWARN(48, "\nGC algorithm setting incorrect. Will use default value.\n"); GC_PROP |= ALGO_COMPACT_MOVE; gc = gc_mc_create(); } return gc; }
static String _xml_decode_tag(XmlParser *parser, const char *tag) { auto newstr = xml_utf8_decode((const XML_Char*)tag, strlen(tag), parser->target_encoding); if (parser->case_folding) { string_to_upper(newstr); } return newstr; }
static void test_string_to_upper() { char *string = string_duplicate("Hello World"); string_to_upper(string); CU_ASSERT_STRING_EQUAL(string, "HELLO WORLD"); free(string); }
static INLINE void sanitize_to_string(char *s, const char *label, size_t len) { char new_label[PATH_MAX_LENGTH] = {0}; strlcpy(new_label, label, sizeof(new_label)); strlcpy(s, string_to_upper(new_label), len); replace_chars(s, '_', ' '); }
vector<string> Box::EveryTypes() { vector<string> types; for (int i = 0; i < channels.size(); i++) { for (int j = 0; j < channels[i].getPrograms().size(); j++) { bool found=false; for (int z = 0; z < types.size(); z++) { if (string_to_upper(channels[i].getPrograms()[j].getType()) == string_to_upper(types[z])) found = true; } if (!found) types.push_back(channels[i].getPrograms()[j].getType()); } } return types; }
static char *_xml_decode_tag(XmlParser *parser, const char *tag) { char *newstr; int out_len; newstr = xml_utf8_decode((const XML_Char*)tag, strlen(tag), &out_len, parser->target_encoding); if (parser->case_folding) { newstr = string_to_upper(newstr, out_len); } return newstr; }
DynamicParMetis::EdgeSource DynamicParMetis::stringToEdgeSource( std::string s ) { string_to_upper( s ); string_trim( s ); if( s == "EDGES_FROM_FOREST" ) return PARMETIS_EDGES_FROM_FOREST; else if( s == "EDGES_FROM_EDGE_WEIGHTS" ) return PARMETIS_EDGES_FROM_EDGE_WEIGHTS; else WALBERLA_ABORT( "Illegal ParMetis weights usage specified (" << s << ")! Valid choices are: \"EDGES_FROM_FOREST\" or \"EDGES_FROM_EDGE_WEIGHTS\"" ); }
void gc_decide_con_algo(char* concurrent_algo) { string_to_upper(concurrent_algo); GC_PROP &= ~ALGO_CON_MASK; if(!strcmp(concurrent_algo, "OTF_OBJ")){ GC_PROP |= ALGO_CON_OTF_OBJ; }else if(!strcmp(concurrent_algo, "MOSTLY_CON")){ GC_PROP |= ALGO_CON_MOSTLY; }else if(!strcmp(concurrent_algo, "OTF_SLOT")){ GC_PROP |= ALGO_CON_OTF_REF; } }
void Box::updateChannel(string &name) { system("CLS"); cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Update a channel" << endl << endl; string newname; cout << "Insert a new name to this channel: "; cin.clear(); cin.ignore(); getline(cin, newname); if (string_to_upper(name) == string_to_upper(newname)) { cout << endl << endl << "The channel \"" << name << "\" already have this name." << endl << endl << endl; } else { cout << endl << endl << "The name of the channel \"" << name << "\" was change to \"" << newname << "\"." << endl << endl << endl; } }
DynamicParMetis::WeightsToUse DynamicParMetis::stringToWeightsToUse( std::string s ) { string_to_upper( s ); string_trim( s ); if( s == "NO_WEIGHTS" ) return PARMETIS_NO_WEIGHTS; else if( s == "EDGE_WEIGHTS" ) return PARMETIS_EDGE_WEIGHTS; else if( s == "VERTEX_WEIGHTS" ) return PARMETIS_VERTEX_WEIGHTS; else if( s == "BOTH_WEIGHTS" ) return PARMETIS_BOTH_WEIGHTS; else WALBERLA_ABORT( "Illegal ParMetis weights usage specified (" << s << ")! Valid choices are: \"NO_WEIGHTS\", \"EDGE_WEIGHTS\", \"VERTEX_WEIGHTS\", or \"BOTH_WEIGHTS\"." ); }
static void initialize (void) { struct var *var; PRE (!initialized); for (var = vars; var->name != NULL; var++) { char *envname; envname = string_to_upper (var->name); initialize_var (var, envname); free (envname); } initialized = true; }
std::string unhide_letters(std::string s, std::vector<char> letters) { std::string c = string_to_upper(s); bool presente; for (unsigned int i = 0; i < s.length(); i++) { presente = 0; if (c[i] != ' ') { for (unsigned int j = 0; j < letters.size(); j++) { if (letters[j] == c[i]) { presente = 1; break; } } if (presente == 0) s[i]='*'; } } return s; }
DynamicParMetis::Algorithm DynamicParMetis::stringToAlgorithm( std::string s ) { string_to_upper( s ); string_trim( s ); if( s == "PART_GEOM_KWAY" ) return PARMETIS_PART_GEOM_KWAY; else if( s == "PART_GEOM" ) return PARMETIS_PART_GEOM; else if( s == "PART_KWAY" ) return PARMETIS_PART_KWAY; else if( s == "ADAPTIVE_REPART" ) return PARMETIS_ADAPTIVE_REPART; else if( s == "REFINE_KWAY" ) return PARMETIS_REFINE_KWAY; else WALBERLA_ABORT( "Illegal ParMetis algorithm specified (" << s << ")! Valid choices are: \"PART_GEOM_KWAY\", \"PART_GEOM\", \"PART_KWAY\", \"ADAPTIVE_REPART\", or \"REFINE_KWAY\"." ); }
String StringUtil::ToUpper(CStrRef input, ToUpperType type /*= ToUpperAll */) { if (input.empty()) return input; int len = input.size(); char *ret = nullptr; switch (type) { case ToUpperAll: ret = string_to_upper(input.data(), len); break; case ToUpperFirst: ret = string_to_upper_first(input.data(), len); break; case ToUpperWords: ret = string_to_upper_words(input.data(), len); break; default: assert(false); break; } return String(ret, len, AttachString); }
/*-------------------------------------------------------------------*/ int main (int argc, char *argv[]) { char *pgm; /* less any extension (.ext) */ int rc; /* Return code */ int i=0; /* Arument index */ U16 len; /* Record length */ U32 cyl; /* Cylinder number */ U8 head; /* Head number */ U8 rec; /* Record number */ u_int trk; /* Relative track number */ char *fname; /* -> CKD image file name */ char *sfname=NULL; /* -> CKD shadow file name */ char dsnama[45]; /* Dataset name (ASCIIZ) */ int noext; /* Number of extents */ DSXTENT extent[16]; /* Extent descriptor array */ BYTE *blkptr; /* -> PDS directory block */ BYTE dirblk[256]; /* Copy of directory block */ CIFBLK *cif; /* CKD image file descriptor */ INITIALIZE_UTILITY( UTILITY_NAME, "PDS unload", &pgm ); /* Check the number of arguments */ if (argc < 3 || argc > 5) { FWRMSG( stderr, HHC02463, "I", pgm, " pdsname [ascii]" ); return -1; } /* The first argument is the name of the CKD image file */ fname = argv[1]; /* The next argument may be the shadow file name */ if (!memcmp (argv[2], "sf=", 3)) { sfname = argv[2]; i = 1; } /* The second argument is the dataset name */ memset (dsnama, 0, sizeof(dsnama)); strncpy (dsnama, argv[2|+i], sizeof(dsnama)-1); string_to_upper (dsnama); /* The third argument is an optional keyword */ if (argc > 3+i && argv[3+i] != NULL) { if (strcasecmp(argv[3+i], "ascii") == 0) asciiflag = 1; else { FWRMSG( stderr, HHC02465, "E", argv[3+i] ); FWRMSG( stderr, HHC02463, "I", argv[0], " pdsname [ascii]" ); return -1; } } /* Open the CKD image file */ cif = open_ckd_image (fname, sfname, O_RDONLY|O_BINARY, IMAGE_OPEN_NORMAL); if (cif == NULL) return -1; /* Build the extent array for the requested dataset */ rc = build_extent_array (cif, dsnama, extent, &noext); if (rc < 0) return -1; #ifdef EXTERNALGUI /* Calculate ending relative track */ if (extgui) { int bcyl; /* Extent begin cylinder */ int btrk; /* Extent begin head */ int ecyl; /* Extent end cylinder */ int etrk; /* Extent end head */ int trks; /* total tracks in dataset */ int i; /* loop control */ for (i = 0, trks = 0; i < noext; i++) { bcyl = (extent[i].xtbcyl[0] << 8) | extent[i].xtbcyl[1]; btrk = (extent[i].xtbtrk[0] << 8) | extent[i].xtbtrk[1]; ecyl = (extent[i].xtecyl[0] << 8) | extent[i].xtecyl[1]; etrk = (extent[i].xtetrk[0] << 8) | extent[i].xtetrk[1]; trks += (((ecyl * cif->heads) + etrk) - ((bcyl * cif->heads) + btrk)) + 1; } EXTGUIMSG( "ETRK=%d\n", trks-1 ); } #endif /*EXTERNALGUI*/ /* Point to the start of the directory */ trk = 0; rec = 1; /* Read the directory */ while (1) { EXTGUIMSG( "CTRK=%d\n", trk ); /* Convert relative track to cylinder and head */ rc = convert_tt (trk, noext, extent, cif->heads, &cyl, &head); if (rc < 0) return -1; /* Read a directory block */ WRMSG( HHC02466, "I", cyl, head, rec ); rc = read_block (cif, cyl, head, rec, NULL, NULL, &blkptr, &len); if (rc < 0) return -1; /* Move to next track if block not found */ if (rc > 0) { trk++; rec = 1; continue; } /* Exit at end of directory */ if (len == 0) break; /* Copy the directory block */ memcpy (dirblk, blkptr, sizeof(dirblk)); /* Process each member in the directory block */ rc = process_dirblk (cif, noext, extent, dirblk); if (rc < 0) return -1; if (rc > 0) break; /* Point to the next directory block */ rec++; } /* end while */ WRMSG( HHC02467, "I" ); /* Close the CKD image file and exit */ rc = close_ckd_image (cif); return rc; } /* end function main */
int do_cat(CIFBLK *cif, char *file) { int rc = 0; DSXTENT extent[16]; int noext; char buff[100]; /* must fit max length DSNAME/MEMBER..OPTS */ char dsname[45]; unsigned long optflags = 0; char *p; char *pdsmember = 0; if ((rc = get_volser( cif )) != 0) return rc; strncpy(buff, file, sizeof(buff)); buff[sizeof(buff)-1] = 0; p = strchr(buff, ':'); if (p) { *p++ = 0; for (; *p; p++) { if (*p == 'a') optflags |= OPT_ASCIIFY; else if (*p == 'c') optflags |= OPT_CARDS; else if (*p == 's') optflags |= OPT_SEQNO; else if (*p == '?') optflags |= OPT_MEMINFO_ONLY; else { char buf[2]; buf[0] = *p; buf[1] = 0; // "Unknown 'member:flags' formatting option %s" FWRMSG( stderr, HHC02402, "E", buf ); rc = -1; } } } if (rc != 0) return rc; p = strchr(buff, '/'); if (p) { *p = 0; pdsmember = p + 1; string_to_upper(pdsmember); } strncpy(dsname, buff, sizeof(dsname)); dsname[sizeof(dsname)-1] = 0; string_to_upper(dsname); rc = build_extent_array(cif, dsname, extent, &noext); if (rc < 0) return -1; #ifdef EXTERNALGUI /* Calculate ending relative track */ if (extgui) { int bcyl; /* Extent begin cylinder */ int btrk; /* Extent begin head */ int ecyl; /* Extent end cylinder */ int etrk; /* Extent end head */ int trks; /* total tracks in dataset */ int i; /* loop control */ for (i = 0, trks = 0; i < noext; i++) { bcyl = (extent[i].xtbcyl[0] << 8) | extent[i].xtbcyl[1]; btrk = (extent[i].xtbtrk[0] << 8) | extent[i].xtbtrk[1]; ecyl = (extent[i].xtecyl[0] << 8) | extent[i].xtecyl[1]; etrk = (extent[i].xtetrk[0] << 8) | extent[i].xtetrk[1]; trks += (((ecyl*cif->heads)+etrk)-((bcyl*cif->heads)+btrk))+1; } EXTGUIMSG( "ETRK=%d\n", trks-1 ); } #endif /*EXTERNALGUI*/ if (pdsmember) { if (!strcmp(pdsmember, "*")) optflags |= OPT_PDS_WILDCARD; else if (!strcmp(pdsmember, "?")) optflags |= OPT_PDS_LISTONLY; rc = do_cat_pdsmember(cif, extent, noext, dsname, pdsmember, optflags); if (!(optflags & (OPT_PDS_LISTONLY | OPT_PDS_WILDCARD)) && !found) { // "Member '%s' not found in dataset '%s' on volume '%s'" FWRMSG( stderr, HHC02406, "E", pdsmember, dsname, volser ); rc = 1; } } else { // "Non-PDS-members not yet supported" FWRMSG( stderr, HHC02401, "E" ); rc = 1; } return rc; }
int getF1dscb( CIFBLK *cif, char *pdsn[], FORMAT1_DSCB *f1dscb, DSXTENT *vtocext[], int verbose) { char zdsn[sizeof(f1dscb->ds1dsnam) + 1]; // zASCII dsn BYTE edsn[sizeof(f1dscb->ds1dsnam)]; // EBCDIC dsn void *f1key, *f1data; int f1kl, f1dl; int cyl, head, rec, rc; int vtocextents = 1; // VTOC has only one extent // Locate dataset's F1 DSCB memset(zdsn, 0, sizeof(zdsn)); strncpy(zdsn, *pdsn, sizeof(zdsn) - 1); string_to_upper(zdsn); convert_to_ebcdic(edsn, sizeof(edsn), zdsn); if (verbose) fprintf(stderr, "getF1dscb searching VTOC for %s\n", zdsn); rc = search_key_equal(cif, edsn, sizeof(edsn), vtocextents, (DSXTENT *)vtocext, &cyl, &head, &rec); if (rc) { fprintf(stderr, "getF1dscb search_key_equal rc %d\n", rc); if (verbose) { fprintf(stderr, "getF1dscb key\n"); data_dump(edsn, sizeof(edsn)); } if (rc == 1) fprintf(stderr, "getF1dscb no DSCB found for %s\n", zdsn); return 1; } // Read F1 DSCB describing dataset if (verbose) fprintf(stderr, "getF1dscb reading F1 DSCB\n"); rc = read_block(cif, cyl, head, rec, (void *)&f1key, &f1kl, (void *) &f1data, &f1dl); if (rc) { fprintf(stderr, "getF1dscb error reading F1 DSCB, rc %d\n", rc); return 2; } // Return data to caller if ((f1kl == sizeof(f1dscb->ds1dsnam)) && (f1dl == (sizeof(FORMAT1_DSCB) - sizeof(f1dscb->ds1dsnam)))) { memcpy((void *) &f1dscb->ds1dsnam, f1key, f1kl); // copy F1 key to buffer memcpy((void *) &f1dscb->ds1fmtid, f1data, f1dl); // copy F1 data to buffer } else { fprintf(stderr, "getF1dscb bad key %d or data length %d\n", f1kl, f1dl); return 3; } if (verbose > 1) { fprintf(stderr, "getF1dscb F1 DSCB\n"); data_dump((void *) f1dscb, sizeof(FORMAT1_DSCB)); } // Verify DS1FMTID byte = x'F1' // Do this after copying data to caller's buffer so we can use struct fields // rather than having to calculate offset to verified data; little harm done // if it doesn't verify since we're toast if it's bad. if (f1dscb->ds1fmtid != 0xf1) { fprintf(stderr, "getF1dscb " "F1 DSCB format id byte invalid (DS1IDFMT) %2.2X\n", f1dscb->ds1fmtid); return 4; } return 0; } /* getF1dscb */
/*-------------------------------------------------------------------*/ int main ( int argc, char *argv[] ) { int altcylflag = 0; /* Alternate cylinders flag */ int rawflag = 0; /* Raw format flag */ int volsize_argnum = 4; /* argc value of size option */ U32 size = 0; /* Volume size */ U32 altsize = 0; /* Alternate cylinders */ U32 heads = 0; /* Number of tracks/cylinder */ U32 maxdlen = 0; /* Maximum R1 data length */ U32 sectsize = 0; /* Sector size */ U16 devtype = 0; /* Device type */ BYTE comp = 0xff; /* Compression algoritm */ BYTE type = 0; /* C=CKD, F=FBA */ char fname[1024]; /* File name */ char volser[7]; /* Volume serial number */ BYTE c; /* Character work area */ CKDDEV *ckd; /* -> CKD device table entry */ FBADEV *fba; /* -> FBA device table entry */ int lfs = 0; /* 1 = Build large file */ int nullfmt = CKDDASD_NULLTRK_FMT1; /* Null track format type */ int rc; /* Return code */ INITIALIZE_UTILITY("dasdinit"); /* Display program identification and help */ if (argc <= 1 || (argc == 2 && !strcmp(argv[1], "-v"))) argexit(-1, NULL); /* Process optional arguments */ for ( ; argc > 1 && argv[1][0] == '-'; argv++, argc--) { if (strcmp("0", &argv[1][1]) == 0) comp = CCKD_COMPRESS_NONE; #ifdef HAVE_LIBZ else if (strcmp("z", &argv[1][1]) == 0) comp = CCKD_COMPRESS_ZLIB; #endif #ifdef CCKD_BZIP2 else if (strcmp("bz2", &argv[1][1]) == 0) comp = CCKD_COMPRESS_BZIP2; #endif else if (strcmp("a", &argv[1][1]) == 0) altcylflag = 1; else if (strcmp("r", &argv[1][1]) == 0) rawflag = 1; else if (strcmp("lfs", &argv[1][1]) == 0 && sizeof(off_t) > 4) lfs = 1; else if (strcmp("linux", &argv[1][1]) == 0) nullfmt = CKDDASD_NULLTRK_FMT2; else argexit(0, argv[1]); } /* Check remaining number of arguments */ if (argc < (rawflag ? 3 : 4) || argc > (rawflag ? 4 : 5)) argexit(5, NULL); /* The first argument is the file name */ if (argv[1] == NULL || strlen(argv[1]) == 0 || strlen(argv[1]) > sizeof(fname)-1) argexit(1, argv[1]); strcpy (fname, argv[1]); /* The second argument is the device type. Model number may also be specified */ if (argv[2] == NULL) argexit(2, argv[2]); ckd = dasd_lookup (DASD_CKDDEV, argv[2], 0, 0); if (ckd != NULL) { type = 'C'; devtype = ckd->devt; size = ckd->cyls; altsize = ckd->altcyls; heads = ckd->heads; maxdlen = ckd->r1; } else { fba = dasd_lookup (DASD_FBADEV, argv[2], 0, 0); if (fba != NULL) { type = 'F'; devtype = fba->devt; size = fba->blks; altsize = 0; sectsize = fba->size; } } if (!type) /* Specified model not found */ argexit(2, argv[2]); /* If -r option specified, then there is not volume serial argument and volume size argument is actually argument number 3 and not argument number 4 as otherwise */ if (rawflag) volsize_argnum = 3; else { volsize_argnum = 4; /* The third argument is the volume serial number */ if (argv[3] == NULL || strlen(argv[3]) == 0 || strlen(argv[3]) > sizeof(volser)-1) argexit(3, argv[3]); strcpy (volser, argv[3]); string_to_upper (volser); } /* The fourth argument (or third for -r) is the volume size */ if (argc > volsize_argnum) { if (argc > (volsize_argnum+1)) argexit(5, NULL); if (!argv[volsize_argnum] || strlen(argv[volsize_argnum]) == 0 || sscanf(argv[volsize_argnum], "%u%c", &size, &c) != 1) argexit(4, argv[volsize_argnum]); altcylflag = 0; } /* `-linux' only supported for 3390 device type */ if (nullfmt == CKDDASD_NULLTRK_FMT2 && devtype != 0x3390) argexit(6, NULL); if (altcylflag) size += altsize; /* Create the device */ if (type == 'C') rc = create_ckd (fname, devtype, heads, maxdlen, size, volser, comp, lfs, 0, nullfmt, rawflag); else rc = create_fba (fname, devtype, sectsize, size, volser, comp, lfs, 0, rawflag); /* Display completion message */ if (rc == 0) { fprintf (stderr, _("HHCDI001I DASD initialization successfully " "completed.\n")); } else { fprintf (stderr, _("HHCDI002I DASD initialization unsuccessful" "\n")); } return rc; } /* end function main */