/[MITgcm]/MITgcm/tools/mpack-1.6/encode.c
ViewVC logotype

Diff of /MITgcm/tools/mpack-1.6/encode.c

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

revision 1.3 by jmc, Sat Feb 23 03:30:03 2008 UTC revision 1.4 by jmc, Tue Feb 26 17:05:00 2008 UTC
# Line 23  Line 23 
23   * SOFTWARE.   * SOFTWARE.
24   */   */
25  #include <stdio.h>  #include <stdio.h>
26    #include <stdlib.h>
27  #include <string.h>  #include <string.h>
28    
29  extern char *magic_look(FILE *infile);  extern char *magic_look(FILE *infile);
30  extern char *os_genid(void);  extern char *os_genid(void);
31  extern FILE *os_createnewfile(char *fname);  extern FILE *os_createnewfile(char *fname);
32  extern char *md5digest(FILE *infile, long int *len);  extern char *md5digest(FILE *infile, long int *len);
33    extern void os_perror(char *str);
34    extern int to64(FILE *infile, FILE *outfile, long int limit);
35    
36  #define NUMREFERENCES 4  #define NUMREFERENCES 4
37    int attachment;
38    
39  /*  /*
40   * Encode a file into one or more MIME messages, each   * Encode a file into one or more MIME messages, each
# Line 43  int encode(FILE *infile, FILE *applefile Line 47  int encode(FILE *infile, FILE *applefile
47      char *type;      char *type;
48      FILE *outfile;      FILE *outfile;
49      char *cleanfname, *p;      char *cleanfname, *p;
50      char *digest, *appledigest;      char *digest, *appledigest = NULL;
51      long filesize, l, written;      long filesize, l, written;
52      int thispart, numparts = 1;      int thispart, numparts = 1;
53      int wrotefiletype = 0;      int wrotefiletype = 0;
# Line 57  int encode(FILE *infile, FILE *applefile Line 61  int encode(FILE *infile, FILE *applefile
61      /* This filename-cleaning knowledge will probably      /* This filename-cleaning knowledge will probably
62       * be moved to the os layer in a future version.       * be moved to the os layer in a future version.
63       */       */
64      if (p = strrchr(cleanfname, '.')) cleanfname = p+1;      if ((p = strrchr(cleanfname, '.'))) cleanfname = p+1;
65  #else  #else
66      if (p = strrchr(cleanfname, '/')) cleanfname = p+1;      if ((p = strrchr(cleanfname, '/'))) cleanfname = p+1;
67      if (p = strrchr(cleanfname, '\\')) cleanfname = p+1;      if ((p = strrchr(cleanfname, '\\'))) cleanfname = p+1;
68  #endif  #endif
69      if (p = strrchr(cleanfname, ':')) cleanfname = p+1;      if ((p = strrchr(cleanfname, ':'))) cleanfname = p+1;
70    
71      /* Find file type */      /* Find file type */
72      if (typeoverride) {      if (typeoverride) {
# Line 189  int encode(FILE *infile, FILE *applefile Line 193  int encode(FILE *infile, FILE *applefile
193          "Content-Type: multipart/appledouble; boundary=\"=\"; name=\"%s\"\n",          "Content-Type: multipart/appledouble; boundary=\"=\"; name=\"%s\"\n",
194                          cleanfname);                          cleanfname);
195                  fprintf(outfile,                  fprintf(outfile,
196                          "Content-Disposition: inline; filename=\"%s\"\n",                          "Content-Disposition: %s; filename=\"%s\"\n",
197                          cleanfname);                          attachment ? "attachment" : "inline", cleanfname);
198                  fprintf(outfile, "\n\n--=\n");                  fprintf(outfile, "\n\n--=\n");
199                  fprintf(outfile, "Content-Type: application/applefile\n");                  fprintf(outfile, "Content-Type: application/applefile\n");
200                  fprintf(outfile, "Content-Transfer-Encoding: base64\n");                  fprintf(outfile, "Content-Transfer-Encoding: base64\n");
# Line 219  int encode(FILE *infile, FILE *applefile Line 223  int encode(FILE *infile, FILE *applefile
223              fprintf(outfile, "Content-Type: %s; name=\"%s\"\n", type,              fprintf(outfile, "Content-Type: %s; name=\"%s\"\n", type,
224                      cleanfname);                      cleanfname);
225              fprintf(outfile, "Content-Transfer-Encoding: base64\n");              fprintf(outfile, "Content-Transfer-Encoding: base64\n");
226              fprintf(outfile, "Content-Disposition: inline; filename=\"%s\"\n",              fprintf(outfile, "Content-Disposition: %s; filename=\"%s\"\n",
227                      cleanfname);                      attachment ? "attachment" : "inline", cleanfname);
228              fprintf(outfile, "Content-MD5: %s\n\n", digest);              fprintf(outfile, "Content-MD5: %s\n\n", digest);
229              free(digest);              free(digest);
230              written += 80;              written += 80;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22