IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 1, 2008, 9:05:29 AM (18 years ago)
Author:
Paul Price
Message:

Need to check return value of fgets to avoid compiler warnings on some
systems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pxadmin.c

    r18777 r18850  
    128128        psString dbName = psMetadataLookupStr(&status, config->modules->complete, "DBNAME");
    129129
    130         fprintf (stdout, "*** delete the tables from database %s? ***\n", dbName);
    131         fprintf (stdout, "*** to delete the tables, answer YES, and give password ***\n");
    132         fprintf (stdout, "*** WARNING: this action is permanent ***\n\n");
    133 
    134         fprintf (stdout, "delete the tables (YES/[n]): ");
    135         fgets (line, 128, stdin);
    136         sscanf (line, "%s", answer);
     130        fprintf(stdout, "*** delete the tables from database %s? ***\n", dbName);
     131        fprintf(stdout, "*** to delete the tables, answer YES, and give password ***\n");
     132        fprintf(stdout, "*** WARNING: this action is permanent ***\n\n");
     133
     134        fprintf(stdout, "delete the tables (YES/[n]): ");
     135        if (!fgets(line, 128, stdin)) {
     136            psError(PS_ERR_IO, true, "Unable to read response.");
     137            return false;
     138        }
     139        sscanf(line, "%s", answer);
    137140        if (strcmp (answer, "YES"))  {
    138141            psError(PS_ERR_UNKNOWN, true, "tables NOT deleleted");
     
    140143        }
    141144
    142         fprintf (stdout, "enter dbh connection password: ");
    143         fgets (line, 128, stdin);
    144         sscanf (line, "%s", answer);
     145        fprintf(stdout, "enter dbh connection password: ");
     146        if (!fgets(line, 128, stdin)) {
     147            psError(PS_ERR_IO, true, "Unable to read response.");
     148            return false;
     149        }
     150        sscanf(line, "%s", answer);
    145151
    146152        psString dbPassword = psMetadataLookupStr(&status, config->modules->complete, "DBPASSWORD");
Note: See TracChangeset for help on using the changeset viewer.