/[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.1 by edhill, Tue Aug 26 20:45:25 2003 UTC revision 1.2 by jmc, Sat Feb 23 01:28:27 2008 UTC
# Line 23  Line 23 
23   * SOFTWARE.   * SOFTWARE.
24   */   */
25  #include <stdio.h>  #include <stdio.h>
26    #include <stdlib.h>
27  #include <ctype.h>  #include <ctype.h>
28  #include <string.h>  #include <string.h>
29    #include <unistd.h>
30  #include "xmalloc.h"  #include "xmalloc.h"
31  #include "common.h"  #include "common.h"
32  #include "part.h"  #include "part.h"
# Line 32  Line 34 
34  extern char *os_idtodir(char *id);  extern char *os_idtodir(char *id);
35  extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);  extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);
36  extern FILE *os_createnewfile(char *fname);  extern FILE *os_createnewfile(char *fname);
37    extern int os_binhex(struct part *inpart, int part, int nparts);
38    extern void os_closetypedfile(FILE *outfile);
39    extern void os_donewithdir(char *dir);
40    extern void os_perror(char *str);
41    extern void chat(char *s);
42    
43    extern void part_ungets(char *s, struct part *part);
44    extern void part_close(struct part *part);
45    extern int handleMessage(struct part *inpart, char *defaultContentType,
46                             int inAppleDouble, int extractText);
47    
48  static FILE *startDescFile(char *fname);  static FILE *startDescFile(char *fname);
49    static void uudecodeline(char *line, FILE *outfile);
50    
51    int parseSubject(char *subject, char **fnamep, int *partp, int *npartsp);
52    int saveUuFile(struct part *inpart, char *fname, int part, int nparts,
53                   char *firstline);
54    int descEnd(char *line);
55    int uudecodefiles(char *dir, int nparts);
56    
57  /* Length of a normal uuencoded line, including newline */  /* Length of a normal uuencoded line, including newline */
58  #define UULENGTH 62  #define UULENGTH 62
# Line 266  int handleUuencode(struct part *inpart, Line 284  int handleUuencode(struct part *inpart,
284          }          }
285          else if (part == 1 && fname && !descfile &&          else if (part == 1 && fname && !descfile &&
286                   !strncasecmp(buf, "x-file-desc: ", 13)) {                   !strncasecmp(buf, "x-file-desc: ", 13)) {
287              if (descfile = startDescFile(fname)) {              if ((descfile = startDescFile(fname))) {
288                  fputs(buf+13, descfile);                  fputs(buf+13, descfile);
289                  fclose(descfile);                  fclose(descfile);
290                  descfile = 0;                  descfile = 0;
# Line 454  saveUuFile(struct part *inpart, char *fn Line 472  saveUuFile(struct part *inpart, char *fn
472      /* Retrieve any previously saved number of the last part */      /* Retrieve any previously saved number of the last part */
473      if (nparts == 0) {      if (nparts == 0) {
474          sprintf(buf, "%sCT", dir);          sprintf(buf, "%sCT", dir);
475          if (partfile = fopen(buf, "r")) {          if ((partfile = fopen(buf, "r"))) {
476              if (fgets(buf, sizeof(buf), partfile)) {              if (fgets(buf, sizeof(buf), partfile)) {
477                  nparts = atoi(buf);                  nparts = atoi(buf);
478                  if (nparts < 0) nparts = 0;                  if (nparts < 0) nparts = 0;
# Line 722  uudecodefiles(char *dir, int nparts) Line 740  uudecodefiles(char *dir, int nparts)
740                  if (!*fname) return 1;                  if (!*fname) return 1;
741    
742                  /* Guess the content-type of common filename extensions */                  /* Guess the content-type of common filename extensions */
743                  if (p = strrchr(fname, '.')) {                  if ((p = strrchr(fname, '.'))) {
744                      if (!strcasecmp(p, ".gif")) contentType = "image/gif";                      if (!strcasecmp(p, ".gif")) contentType = "image/gif";
745                      if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg";                      if (!strcasecmp(p, ".jpg")) contentType = "image/jpeg";
746                      if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg";                      if (!strcasecmp(p, ".jpeg")) contentType = "image/jpeg";
# Line 826  uudecodefiles(char *dir, int nparts) Line 844  uudecodefiles(char *dir, int nparts)
844  /*  /*
845   * Decode a uuencoded line to 'outfile'   * Decode a uuencoded line to 'outfile'
846   */   */
847  int uudecodeline(char *line, FILE *outfile)  static void uudecodeline(char *line, FILE *outfile)
848  {  {
849      int c, len;      int c, len;
850    
# Line 845  int uudecodeline(char *line, FILE *outfi Line 863  int uudecodeline(char *line, FILE *outfi
863          }          }
864          line += 4;          line += 4;
865      }      }
     return;  
866  }  }
867    
868            

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

  ViewVC Help
Powered by ViewVC 1.1.22