/[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.2 by jmc, Sat Feb 23 01:28:27 2008 UTC revision 1.3 by jmc, Sat Feb 23 03:30:03 2008 UTC
# Line 23  Line 23 
23   * SOFTWARE.   * SOFTWARE.
24   */   */
25  #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  
26  #include <string.h>  #include <string.h>
27    
28  extern char *magic_look(FILE *infile);  extern char *magic_look(FILE *infile);
29  extern char *os_genid(void);  extern char *os_genid(void);
30  extern FILE *os_createnewfile(char *fname);  extern FILE *os_createnewfile(char *fname);
31  extern char *md5digest(FILE *infile, long int *len);  extern char *md5digest(FILE *infile, long int *len);
 extern void os_perror(char *str);  
 extern int to64(FILE *infile, FILE *outfile, long int limit);  
32    
33  #define NUMREFERENCES 4  #define NUMREFERENCES 4
 int attachment;  
34    
35  /*  /*
36   * Encode a file into one or more MIME messages, each   * Encode a file into one or more MIME messages, each
# Line 47  int encode(FILE *infile, FILE *applefile Line 43  int encode(FILE *infile, FILE *applefile
43      char *type;      char *type;
44      FILE *outfile;      FILE *outfile;
45      char *cleanfname, *p;      char *cleanfname, *p;
46      char *digest, *appledigest = NULL;      char *digest, *appledigest;
47      long filesize, l, written;      long filesize, l, written;
48      int thispart, numparts = 1;      int thispart, numparts = 1;
49      int wrotefiletype = 0;      int wrotefiletype = 0;
# Line 61  int encode(FILE *infile, FILE *applefile Line 57  int encode(FILE *infile, FILE *applefile
57      /* This filename-cleaning knowledge will probably      /* This filename-cleaning knowledge will probably
58       * be moved to the os layer in a future version.       * be moved to the os layer in a future version.
59       */       */
60      if ((p = strrchr(cleanfname, '.'))) cleanfname = p+1;      if (p = strrchr(cleanfname, '.')) cleanfname = p+1;
61  #else  #else
62      if ((p = strrchr(cleanfname, '/'))) cleanfname = p+1;      if (p = strrchr(cleanfname, '/')) cleanfname = p+1;
63      if ((p = strrchr(cleanfname, '\\'))) cleanfname = p+1;      if (p = strrchr(cleanfname, '\\')) cleanfname = p+1;
64  #endif  #endif
65      if ((p = strrchr(cleanfname, ':'))) cleanfname = p+1;      if (p = strrchr(cleanfname, ':')) cleanfname = p+1;
66    
67      /* Find file type */      /* Find file type */
68      if (typeoverride) {      if (typeoverride) {
# Line 193  int encode(FILE *infile, FILE *applefile Line 189  int encode(FILE *infile, FILE *applefile
189          "Content-Type: multipart/appledouble; boundary=\"=\"; name=\"%s\"\n",          "Content-Type: multipart/appledouble; boundary=\"=\"; name=\"%s\"\n",
190                          cleanfname);                          cleanfname);
191                  fprintf(outfile,                  fprintf(outfile,
192                          "Content-Disposition: %s; filename=\"%s\"\n",                          "Content-Disposition: inline; filename=\"%s\"\n",
193                          attachment ? "attachment" : "inline", cleanfname);                          cleanfname);
194                  fprintf(outfile, "\n\n--=\n");                  fprintf(outfile, "\n\n--=\n");
195                  fprintf(outfile, "Content-Type: application/applefile\n");                  fprintf(outfile, "Content-Type: application/applefile\n");
196                  fprintf(outfile, "Content-Transfer-Encoding: base64\n");                  fprintf(outfile, "Content-Transfer-Encoding: base64\n");
# Line 223  int encode(FILE *infile, FILE *applefile Line 219  int encode(FILE *infile, FILE *applefile
219              fprintf(outfile, "Content-Type: %s; name=\"%s\"\n", type,              fprintf(outfile, "Content-Type: %s; name=\"%s\"\n", type,
220                      cleanfname);                      cleanfname);
221              fprintf(outfile, "Content-Transfer-Encoding: base64\n");              fprintf(outfile, "Content-Transfer-Encoding: base64\n");
222              fprintf(outfile, "Content-Disposition: %s; filename=\"%s\"\n",              fprintf(outfile, "Content-Disposition: inline; filename=\"%s\"\n",
223                      attachment ? "attachment" : "inline", cleanfname);                      cleanfname);
224              fprintf(outfile, "Content-MD5: %s\n\n", digest);              fprintf(outfile, "Content-MD5: %s\n\n", digest);
225              free(digest);              free(digest);
226              written += 80;              written += 80;

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

  ViewVC Help
Powered by ViewVC 1.1.22