home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / vmsnet / internal / 1442 < prev    next >
Encoding:
Text File  |  1992-10-13  |  6.9 KB  |  213 lines

  1. Path: sparky!uunet!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32
  2. From: Ehud Gavron 602-570-2546 <GAVRON@IT.SUNQUEST.COM>
  3. Newsgroups: vmsnet.internals
  4. Subject: Help!  (sys$init_vol)
  5. Message-ID: <921013142454.261@IT.SUNQUEST.COM>
  6. Date: Tue, 13 Oct 1992 14:24:54 -0700 (MST)
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 202
  10.  
  11. Date sent:  13-OCT-1992 14:22:55
  12.  
  13.  
  14.         I'm trying to create a piece of code to initialize a disk or
  15.         tape volume.  However, when I call sys$init_vol I get back
  16.         ss$_badparam.  Can anyone either
  17.                 a. tell me what I'm doing wrong
  18.                 b. show me how to do it right?
  19.  
  20.         Thanks
  21.  
  22.         Ehud
  23.  
  24. --
  25. Ehud Gavron        (EG76)
  26. gavron@vesta.sunquest.com                                       This was sent
  27. "The world bores you when you're cool."                         from an Alpha
  28.  
  29. init.c:
  30. #include <descrip.h>
  31. #include "initdef.h"
  32. #include "itemlist.h"
  33. #include <ssdef.h>
  34. #define check_status(x) {if ((sav_stat = x) != SS$_NORMAL) sys$exit(sav_stat);}
  35. unsigned long sav_stat;
  36. static $DESCRIPTOR(one,"1");
  37. struct dsc$descriptor_s errdsc;
  38. char errbuf[128];
  39.  
  40. #define DSMexit if (!(sav_stat &1))  \
  41.                 return((long)lib$scopy_dxdx(&errdsc,vmsstatus));
  42. #define ISMexit *vmsstatus = one;                              \
  43.                 if (!(sav_stat &1)) *vmsstatus = errdsc;                \
  44.                 return(SS$_NORMAL);
  45. #ifdef DSM
  46. #define mumps_return    DSMexit
  47. #define mumps_descriptor dsc$descriptor_d
  48. #else
  49. #define mumps_return    ISMexit
  50. #define mumps_descriptor dsc$descriptor_s
  51. #endif
  52.  
  53. #ifdef __alpha
  54. int sys$exit(),sys$init_vol(),strchr(),strncpy(),strcat(),strlen(),
  55.         sprintf(),atoi(),printf(),scanf(),initvol();
  56. #endif
  57. #ifdef STANDALONE
  58. main()
  59. {
  60. struct dsc$descriptor_s devnam,label,density,owner,stat;
  61. char devbuf[64],labbuf[64],densbuf[20],ownbuf[20],statbuf[128];
  62. int ss_status;
  63. devnam.dsc$b_class = DSC$K_CLASS_S;
  64. devnam.dsc$b_dtype = DSC$K_DTYPE_T;
  65. devnam.dsc$a_pointer = (char *)&devbuf;
  66. devnam.dsc$w_length = sizeof(devbuf);
  67.  
  68. label.dsc$b_class = DSC$K_CLASS_S;
  69. label.dsc$b_dtype = DSC$K_DTYPE_T;
  70. label.dsc$a_pointer = (char *)&labbuf;
  71. label.dsc$w_length = sizeof(labbuf);
  72.  
  73. density.dsc$b_class = DSC$K_CLASS_S;
  74. density.dsc$b_dtype = DSC$K_DTYPE_T;
  75. density.dsc$a_pointer = (char *)&densbuf;
  76. density.dsc$w_length = sizeof(densbuf);
  77.  
  78. owner.dsc$b_class = DSC$K_CLASS_S;
  79. owner.dsc$b_dtype = DSC$K_DTYPE_T;
  80. owner.dsc$a_pointer = (char *)&ownbuf;
  81. owner.dsc$w_length = sizeof(ownbuf);
  82.  
  83. stat.dsc$b_class = DSC$K_CLASS_S;
  84. stat.dsc$b_dtype = DSC$K_DTYPE_T;
  85. stat.dsc$a_pointer = (char *)&statbuf;
  86. stat.dsc$w_length = sizeof(statbuf);
  87.  
  88.         printf("Enter device name: ");
  89.         scanf("%s",(char *)&devbuf);
  90.         devnam.dsc$w_length = strlen(devbuf);
  91.  
  92.         printf("\nEnter volume label: ");
  93.         scanf("%s",(char *)&labbuf);
  94.         label.dsc$w_length = strlen(labbuf);
  95.  
  96.         printf("\nEnter optional owner uic: (\\ for none)");
  97.         scanf("%s",(char *)&ownbuf);
  98.         owner.dsc$w_length = strlen(ownbuf);
  99.         if (ownbuf[0] == '\\') owner.dsc$w_length = 0;
  100.  
  101.         printf("\nEnter optional density: (\\ for none)");
  102.         scanf("%s",(char *)&densbuf);
  103.         density.dsc$w_length = strlen(densbuf);
  104.         if (densbuf[0] == '\\') density.dsc$w_length = 0;
  105.  
  106.         ss_status = initvol(&devnam,&label,&density,&owner,&stat);
  107.         printf("\nReturn status string was %s\n",stat);
  108.         }
  109. #endif  /* Standalone */
  110. initvol(device_name,volume_label,density_str,owner,vmsstatus)
  111. struct dsc$descriptor_s *device_name;
  112. struct dsc$descriptor_s *volume_label;
  113. struct dsc$descriptor_s *density_str;
  114. struct dsc$descriptor_s *owner;
  115. struct mumps_descriptor *vmsstatus;
  116. {
  117.         ITEMLIST initlist[3];
  118.         int owner_uic;
  119.         int density;
  120.         int density_value;
  121.         char *list_pointer;
  122.         char *p,*q;
  123.         char tmp[128];
  124.         int i;
  125.         q = (char *)&tmp;
  126.         errdsc.dsc$b_class = DSC$K_CLASS_S;
  127.         errdsc.dsc$b_dtype = DSC$K_DTYPE_T;
  128.         errdsc.dsc$a_pointer = (char *)&errbuf;
  129.         errdsc.dsc$w_length  = sizeof(errbuf);
  130.  
  131.  
  132. /*      sys$init_vol(input_device_name_desc,input_label_desc,item_list); */
  133.  
  134.  
  135.         initlist[0].itemcode = INIT$_OWNER;
  136.         initlist[0].bufaddr  = (char *)&owner_uic;
  137.         initlist[0].buflen   = sizeof(owner_uic);
  138.         initlist[0].retlen  = 0;
  139.  
  140.         initlist[1].itemcode = INIT$_DENSITY;
  141.         initlist[1].bufaddr  = (char *)&density;
  142.         initlist[1].buflen   = sizeof(density);
  143.         initlist[1].retlen  = 0;
  144.  
  145.         initlist[2].end      = 0;
  146.  
  147.  
  148.         if (density_str->dsc$w_length  != 0) {
  149.           density_value = atoi((char *)density_str->dsc$a_pointer);
  150.           if ((density_value != 800) &&
  151.               (density_value != 1600) &&
  152.               (density_value != 6250)) {
  153.              sprintf((char *)&errbuf,"MZF:initvol(): invalid density %d\n",
  154.                 density_value);
  155.              errdsc.dsc$w_length = strlen((char *)&errbuf);
  156.              sav_stat = 0;
  157.              mumps_return;
  158.              }
  159.           switch(density_value) {
  160.              case  800: density = INIT$K_DENSITY_800_BPI;
  161.                         break;
  162.              case 1600: density = INIT$K_DENSITY_1600_BPI;
  163.                         break;
  164.              case 6250: density = INIT$K_DENSITY_6250_BPI;
  165.                         break;
  166.              }
  167.           }
  168.         else {  /* no density specified */
  169.           initlist[1].end = 0;  /* terminate item list after owner */
  170.         }
  171.  
  172.         if (owner->dsc$w_length == 0) {
  173.            list_pointer = (char *)&initlist[1];
  174.            }
  175.         else {
  176.            list_pointer = (char *)&initlist[0];
  177.            p = owner->dsc$a_pointer;            /* pointer to [x,y] */
  178.            *(p+owner->dsc$w_length) = ']';      /* pointer to [x,y]] */
  179.            if (*p == '[') p++;                  /* pointer to x,y]] */
  180.            i = (int)strchr(p,',')-(int)p;                       /* i = index(,)
  181. */
  182.            strncpy(q,p,i);                      /* q = 'x' */
  183.            *(q+i) = '\0';
  184.            owner_uic = 0x10000 * atoi(q);       /* uic = left part */
  185.            p +=i;                               /* pointer to ,y]] */
  186.            p++;                                 /* pointer to y]] */
  187.            i = (int)strchr(p,']')-(int)p;                       /* i = index(])
  188. */
  189.            strncpy(q,p,i);                      /* q = 'y' */
  190.            *(q+i) = '\0';
  191.            owner_uic += atoi(q);
  192.            }
  193.  
  194.         i =sys$init_vol((char *)device_name,(char *)volume_label,&list_pointer);
  195.         sav_stat = i;
  196.         mumps_return;
  197. }
  198.  
  199. itemlist.h:
  200. typedef union {
  201.         struct {
  202.                 short s_buflen;
  203.                 short s_itemcode;
  204.                 char *s_bufaddr;
  205.                 int *s_retlen;
  206.                 } s;
  207.         unsigned long end;
  208.         } ITEMLIST;
  209. #define buflen          s.s_buflen
  210. #define itemcode        s.s_itemcode
  211. #define bufaddr         s.s_bufaddr
  212. #define retlen          s.s_retlen
  213.