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

Diff of /MITgcm/tools/mpack-1.6/uudecode.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 <ctype.h>  #include <ctype.h>
27  #include <string.h>  #include <string.h>
 #include <unistd.h>  
28  #include "xmalloc.h"  #include "xmalloc.h"
29  #include "common.h"  #include "common.h"
30  #include "part.h"  #include "part.h"
# Line 34  Line 32 
32  extern char *os_idtodir(char *id);  extern char *os_idtodir(char *id);
33  extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);  extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);
34  extern FILE *os_createnewfile(char *fname);  extern FILE *os_createnewfile(char *fname);
 extern int os_binhex(struct part *inpart, int part, int nparts);  
 extern void os_closetypedfile(FILE *outfile);  
 extern void os_donewithdir(char *dir);  
 extern void os_perror(char *str);  
 extern void chat(char *s);  
   
 extern void part_ungets(char *s, struct part *part);  
 extern void part_close(struct part *part);  
 extern int handleMessage(struct part *inpart, char *defaultContentType,  
                          int inAppleDouble, int extractText);  
35    
36  static FILE *startDescFile(char *fname);  static FILE *startDescFile(char *fname);
 static void uudecodeline(char *line, FILE *outfile);  
37    
 int parseSubject(char *subject, char **fnamep, int *partp, int *npartsp);  
 int saveUuFile(struct part *inpart, char *fname, int part, int nparts,  
                char *firstline);  
 int descEnd(char *line);  
 int uudecodefiles(char *dir, int nparts);  
38    
39  /* Length of a normal uuencoded line, including newline */  /* Length of a normal uuencoded line, including newline */
40  #define UULENGTH 62  #define UULENGTH 62
# Line 284  int handleUuencode(struct part *inpart, Line 266  int handleUuencode(struct part *inpart,
266          }          }
267          else if (part == 1 && fname && !descfile &&          else if (part == 1 && fname && !descfile &&
268                   !strncasecmp(buf, "x-file-desc: ", 13)) {                   !strncasecmp(buf, "x-file-desc: ", 13)) {
269              if ((descfile = startDescFile(fname))) {              if (descfile = startDescFile(fname)) {
270                  fputs(buf+13, descfile);                  fputs(buf+13, descfile);
271                  fclose(descfile);                  fclose(descfile);
272                  descfile = 0;                  descfile = 0;
# Line 472  saveUuFile(struct part *inpart, char *fn Line 454  saveUuFile(struct part *inpart, char *fn
454      /* Retrieve any previously saved number of the last part */      /* Retrieve any previously saved number of the last part */
455      if (nparts == 0) {      if (nparts == 0) {
456          sprintf(buf, "%sCT", dir);          sprintf(buf, "%sCT", dir);
457          if ((partfile = fopen(buf, "r"))) {          if (partfile = fopen(buf, "r")) {
458              if (fgets(buf, sizeof(buf), partfile)) {              if (fgets(buf, sizeof(buf), partfile)) {
459                  nparts = atoi(buf);                  nparts = atoi(buf);
460                  if (nparts < 0) nparts = 0;                  if (nparts < 0) nparts = 0;
# Line 740  uudecodefiles(char *dir, int nparts) Line 722  uudecodefiles(char *dir, int nparts)
722                  if (!*fname) return 1;                  if (!*fname) return 1;
723    
724                  /* Guess the content-type of common filename extensions */                  /* Guess the content-type of common filename extensions */
725                  if ((p = strrchr(fname, '.'))) {                  if (p = strrchr(fname, '.')) {
726                      if (!strcasecmp(p, ".gif")) contentType = "image/gif";                      if (!strcasecmp(p, ".gif")) contentType = "image/gif";
727                      if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg";                      if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg";
728                      if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg";                      if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg";
# Line 844  uudecodefiles(char *dir, int nparts) Line 826  uudecodefiles(char *dir, int nparts)
826  /*  /*
827   * Decode a uuencoded line to 'outfile'   * Decode a uuencoded line to 'outfile'
828   */   */
829  static void uudecodeline(char *line, FILE *outfile)  int uudecodeline(char *line, FILE *outfile)
830  {  {
831      int c, len;      int c, len;
832    
# Line 863  static void uudecodeline(char *line, FIL Line 845  static void uudecodeline(char *line, FIL
845          }          }
846          line += 4;          line += 4;
847      }      }
848        return;
849  }  }
850    
851            

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

  ViewVC Help
Powered by ViewVC 1.1.22