Ignore:
Timestamp:
Aug 26, 2007, 12:26:06 PM (13 years ago)
Author:
Bruno Cornec
Message:

Use of conf file entries (iso_burning_*, media_device, media_size)
and adapatation of the rest of the code to that (including bkpinfo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/mondoarchive/mondo-cli.c

    r1582 r1594  
    9393        flag_set[i] = FALSE;
    9494    }
    95     bkpinfo->media_size = (long)650;
    96     res =
    97         retrieve_switches_from_command_line(argc, argv, flag_val,
     95    res = retrieve_switches_from_command_line(argc, argv, flag_val,
    9896                                            flag_set);
    9997    retval += res;
     
    152150    assert(value != NULL);
    153151
    154     bkpinfo->media_size = 0L;   /* dummy value */
    155152    mr_asprintf(&tmp, value);
    156153    q = strchr(tmp, ',');
     
    211208
    212209    /* compulsory */
    213     i = flag_set['c'] + flag_set['i'] + flag_set['n'] +
     210    i = flag_set['i'] + flag_set['n'] +
    214211        flag_set['t'] + flag_set['u'] + flag_set['r'] +
    215212        flag_set['w'] + flag_set['C'] + flag_set['U'];
     
    316313
    317314    if (g_kernel_version >= 2.6 && !flag_set['d']
    318         && (flag_set['c'] || flag_set['w'])) {
     315        && flag_set['w']) {
    319316        fatal_error
    320317            ("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
     
    331328    }
    332329
    333     if (flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) {
     330    if (flag_set['w'] || flag_set['C'] || flag_set['r']) {
    334331        if (!flag_set['r'] && g_kernel_version <= 2.5
    335332            && strstr(flag_val['d'], "/dev/")) {
     
    352349                ("Please install dvdrecord/cdrecord and try again.");
    353350        }
    354         if (flag_set['C']) {
    355             bkpinfo->cdrw_speed = atoi(flag_val['C']);
    356             if (bkpinfo->cdrw_speed < 1) {
    357                 fatal_error
    358                     ("You specified a silly speed for a CD-R[W] drive");
    359             }
    360             if (!flag_set['L']) {
    361                 log_to_screen
    362                     (_("You must use -L with -C. Therefore I am setting it for you."));
    363                 flag_set['L'] = 1;
    364                 flag_val['L'][0] = '\0';
    365             }
    366         } else {
    367             mr_msg(3, "flag_val['c'] = %s", flag_val['c']);
     351        if (flag_set['w']) {
    368352            mr_msg(3, "flag_val['w'] = %s", flag_val['w']);
    369             if (flag_set['c']) {
    370                 bkpinfo->cdrw_speed = atoi(flag_val['c']);
    371             } else if (flag_set['w']) {
    372                 bkpinfo->cdrw_speed = atoi(flag_val['w']);
    373             } else if (flag_set['r']) {
    374                 bkpinfo->cdrw_speed = 1;    /*atoi(flag_val['r']); */
    375             }
    376 
    377             if (bkpinfo->cdrw_speed < 1) {
    378                 fatal_error
    379                     ("You specified a silly speed for a CD-R[W] drive");
    380             }
     353            bkpinfo->writer_speed = atoi(flag_val['w']);
     354        }
     355
     356        if (bkpinfo->writer_speed < 1) {
     357            fatal_error
     358                ("You specified a silly speed for a burner");
    381359        }
    382360    }
     
    431409            fatal_error
    432410                ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    433         }
    434         if (!flag_set['s']) {
    435             sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4482 MB
    436             strcat(flag_val['s'], "m");
    437             log_to_screen
    438                 (_("You did not specify a size (-s) for DVD. I'm guessing %s."),
    439                  flag_val['s']);
    440             flag_set['s'] = 1;
    441411        }
    442412    }
     
    457427                }
    458428            } else if (flag_set['u'] || flag_set['t']) {
     429                /* Force autidetection */
    459430                bkpinfo->media_size = 0L;
    460431            } else {
     
    492463    }
    493464
    494     if (flag_set['c']) {
    495         bkpinfo->backup_media_type = cdr;
    496     }
    497465    if (flag_set['C']) {
    498466        bkpinfo->backup_media_type = cdstream;
     
    659627            strncpy(bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN);
    660628        } else {                /* backup device (if tape/CD-R/CD-RW) */
    661             strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4);
     629            mr_asprintf(&tmp2,flag_val['d']);
     630            mr_free(bkpinfo->media_device);
     631            bkpinfo->media_device = tmp2;
    662632        }
    663633    }
     
    678648
    679649    if (!flag_set['d']
    680         && (flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['U'])) {
    681         if (g_kernel_version >= 2.6) {
    682             if (popup_and_get_string
    683                 (_("Device"), _("Please specify the device"),
    684                  bkpinfo->media_device, MAX_STR_LEN / 4)) {
    685                 retval++;
    686                 log_to_screen(_("User opted to cancel."));
    687             }
    688         } else if (find_cdrw_device(bkpinfo->media_device)) {
    689             retval++;
    690             log_to_screen
    691                 (_("Tried and failed to find CD-R[W] drive automatically.\n"));
     650        && (flag_set['w'] || flag_set['C'] || flag_set['U'])) {
     651        if (bkpinfo->media_device) {
     652            mr_msg(4, "Using device %s", bkpinfo->media_device);
     653            strncpy(flag_val['d'], bkpinfo->media_device, MAX_STR_LEN / 4);
     654            flag_set['d'] = TRUE;
    692655        } else {
    693             flag_set['d'] = TRUE;
    694             strncpy(flag_val['d'], bkpinfo->media_device, MAX_STR_LEN / 4);
     656            fatal_error(_("No device provided either on command line or in the configuration file"));
    695657        }
    696658    }
Note: See TracChangeset for help on using the changeset viewer.