home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / pcmail / part07 / rmtname.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  3KB  |  103 lines

  1. /*++
  2. /* NAME
  3. /*    rmtname 3
  4. /* SUMMARY
  5. /*    mapping between local and remote spool-file names
  6. /* PROJECT
  7. /*    pc-mail
  8. /* PACKAGE
  9. /*    cico
  10. /* SYNOPSIS
  11. /*    #include "params.h"
  12. /*    #include "comm.h"
  13. /*
  14. /*    char *rmtname(head,tail)
  15. /*    int head;
  16. /*    char *tail;
  17. /*
  18. /*    char *locname(rname)
  19. /*    char *rname;
  20. /* DESCRIPTION
  21. /*    locname() translates a remote spool-file name to one suitable
  22. /*    for the local file system. Remote X.* file names are converted
  23. /*    to the name of the local null device. All other remote file 
  24. /*    names are mapped to names of the form n<seqno> in the local 
  25. /*    spool directory.
  26. /*
  27. /*    rmtname() constructs a remote spool file name from its arguments,
  28. /*    which are a sort of broken-down local spool file name.
  29. /*    "head" specifies the type of file (Data or eXecute file).
  30. /*    "tail" is a character string holding a sequence number.
  31. /*
  32. /*    The output for D files is: D.<rmtsys>S<xseq>
  33. /*
  34. /*    The output for X files is: X.<thissys>X<xseq>
  35. /*
  36. /*    xseq is the four-digit hexadecimal representation of 
  37. /*    the sequence number in tail.
  38. /* SEE ALSO
  39. /*    getwork()
  40. /* DIAGNOSTICS
  41. /*    rmtname() returns via longjmp(systrap,E_CONFUSED) if its
  42. /*    arguments are incorrect.
  43. /* BUGS
  44. /*    locname() and rmtname() store their result in a static area which 
  45. /*    is overwritten upon each call.
  46. /* AUTHOR(S)
  47. /*    W.Z. Venema
  48. /*    Eindhoven University of Technology
  49. /*    Department of Mathematics and Computer Science
  50. /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  51. /* CREATION DATE
  52. /*    Thu Mar 26 14:08:07 GMT+1:00 1987
  53. /* LAST MODIFICATION
  54. /*    Mon Apr  4 23:48:20 MET 1988
  55. /* VERSION/RELEASE
  56. /*    1.3
  57. /*--*/
  58.  
  59. #include "defs.h"
  60. #include "params.h"
  61. #include "comm.h"
  62. #include "logs.h"
  63. #include "status.h"
  64. #include "path.h"
  65.  
  66. hidden char buf[BUFSIZ];            /* storage for the result */
  67.  
  68. /* rmtname - map local spool file name to remote spool file name */
  69.  
  70. public char *rmtname(head,tail)
  71. register int head;
  72. register char *tail;
  73. {
  74.     int seqno;
  75.  
  76.     sscanf(tail,"%d",&seqno);            /* get sequence number */
  77.     seqno &= 0xffff;                /* truncate to four hex digs */
  78.  
  79.     switch(head) {
  80.     case 'D':                    /* data file */
  81.     sprintf(buf,"D.%sS%04x",rmthost,seqno);
  82.     return(buf);
  83.     case 'X':                    /* execute file */
  84.     sprintf(buf,"X.%sX%04x",LOGIN_NAME,seqno);
  85.     return(buf);
  86.     default:                    /* oops */
  87.     trap(E_CONFUSED,"INTERNAL ERROR (unexpected file type: %c)",head);
  88.     /* NOTREACHED */
  89.     }
  90. }
  91.  
  92. /* locname - map remote spool-file name to local name */
  93.  
  94. char *locname(rname)
  95. char *rname;
  96. {
  97.     if (strncmp(rname,"X.",2) == 0) {        /* X. files are ignored */
  98.     return(NULLDEV);
  99.     } else {                    /* everything else is kept */
  100.     return(new_mesg(newseqno()));
  101.     }
  102. }
  103.