/[winpt]/trunk/Src/wptFileManager.cpp
ViewVC logotype

Diff of /trunk/Src/wptFileManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 462 by twoaday, Sat Apr 7 11:50:43 2012 UTC revision 463 by twoaday, Tue Oct 9 09:07:28 2012 UTC
# Line 208  static const char* Line 208  static const char*
208  fm_check_armor_type (const char *fname, int *r_type)  fm_check_armor_type (const char *fname, int *r_type)
209  {  {
210      FILE *fp;      FILE *fp;
211      char header[512], *p;      char header[512];
212        int n;
213            
214      if (r_type)      if (r_type)
215          *r_type = PGP_NONE;          *r_type = PGP_NONE;
216        
217      fp = fopen (fname, "rb");      fp = fopen (fname, "rb");
218      if (!fp)      if (!fp)
219          return "UNKNOWN";          return "UNKNOWN";
220      p = fgets (header, DIM (header) - 1, fp);      n = fread(header, 1, DIM(header) - 12, fp);
221      fclose (fp);      fclose (fp);    
222      if (!p)      if (!n)
223          return "UNKNOWN";          return "UNKNOWN";
224        header[n] = 0;
225    
226      if (strncmp (header, "-----", 5))      if (strstr (header, "-----BEGIN PGP PUBLIC KEY" )) {
227          goto leave;          if (r_type)
228      if (strstr (header, "BEGIN PGP PUBLIC KEY" )) {              *r_type = PGP_PUBKEY;
         if (r_type) *r_type = PGP_PUBKEY;  
229          return "PUBKEY";          return "PUBKEY";
230      }      }
231      else if (strstr (header, "BEGIN PGP PRIVATE KEY") ||      else if (strstr (header, "-----BEGIN PGP PRIVATE KEY") ||
232               strstr (header, "BEGIN PGP SECRET KEY")) {               strstr (header, "-----BEGIN PGP SECRET KEY")) {
233          if (r_type) *r_type = PGP_SECKEY;          if (r_type)
234                *r_type = PGP_SECKEY;
235          return "SECKEY";          return "SECKEY";
236      }      }
237      else if (strstr (header, "BEGIN PGP MESSAGE")) {      else if (strstr (header, "-----BEGIN PGP MESSAGE")) {
238          if (r_type) *r_type = PGP_MESSAGE;          if (r_type)
239                *r_type = PGP_MESSAGE;
240          return "ENCRYPTED";          return "ENCRYPTED";
241      }      }
242      else if (strstr( header, "BEGIN PGP SIGNED MESSAGE")) {      else if (strstr(header, "-----BEGIN PGP SIGNED MESSAGE")) {
243          if (r_type) *r_type = PGP_CLEARSIG;          if (r_type)
244                *r_type = PGP_CLEARSIG;
245          return "SIGNED-CLEAR";          return "SIGNED-CLEAR";
246      }      }
247      else if (strstr(header, "BEGIN PGP SIGNATURE")) {      else if (strstr(header, "-----BEGIN PGP SIGNATURE")) {
248          if (r_type) *r_type = PGP_SIG;          if (r_type)
249                *r_type = PGP_SIG;
250          return "SIGNED-DETACH";          return "SIGNED-DETACH";
251      }      }
252    
 leave:  
253      return "UNKNOWN";      return "UNKNOWN";
254  }  }
255    
# Line 805  fm_set_status (listview_ctrl_t lv, int p Line 810  fm_set_status (listview_ctrl_t lv, int p
810          else          else
811              strcpy (status, "SIGNED");              strcpy (status, "SIGNED");
812          break;          break;
813            
814      case FM_VERIFY:      case FM_VERIFY:
815          update = 0;          update = 0;
816          break;          break;

Legend:
Removed from v.462  
changed lines
  Added in v.463

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26