- if (strcmp (output_format, "sav") && strcmp (output_format, "sys"))
- error (1, 0, _("can only convert encrypted data file to sav or sys "
- "format"));
+ if (encrypted_file_is_sav (enc))
+ {
+ if (strcmp (output_format, "sav") && strcmp (output_format, "sys"))
+ error (1, 0, _("can only convert encrypted data file to sav or "
+ "sys format"));
+ }
+ else
+ {
+ if (strcmp (output_format, "sps"))
+ error (1, 0, _("can only convert encrypted syntax file to sps "
+ "format"));
+ }
+
+ if (! decrypt_file (enc, input_fh, output_fh, password))
+ goto error;