home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 192_01 / mkvolume.c < prev    next >
Text File  |  1979-12-31  |  2KB  |  102 lines

  1. /* DECLARE VARIABLES */
  2. char fat[1050];
  3. char directry[4096];
  4. unsigned int offset, cluster, nxtclust, direntry, noncontig=0;
  5. unsigned int i,j,cl,numin,tot,sector, bytedata, *pint, nsects, svcluster;
  6. char *cfrom, drive, resp, chgflag;
  7. char file[11], cmpflag, evenflag, col, foundflag;
  8. char ds=0;
  9. char vol[35];
  10. char volget[20];
  11.  
  12.  
  13. /* EXECUTABLE CODE STARTS HERE */
  14.   
  15. main()
  16. {
  17.  char c, s[10]; 
  18.  int i,j,sectindx;
  19.  
  20. /* print heading and prompt for drive */
  21.  printf("Modify DS/DD diskette to give it a volume name - by Joe Kilar.\n");
  22.  printf("Enter letter of drive to be accessed/used: ");
  23.  scanf("%c",&drive);
  24.  
  25. /* convert drive from ASCII to binary */
  26.  drive = drive - 0x41;
  27.  if (drive > 26)
  28.    drive = drive - 0x20;
  29.  
  30. /* prompt for and get volume name */
  31.  printf("Enter volume name desired (11 chars max): ");
  32.  gets(volget);
  33.  
  34.  printf("\nGetting directory from diskette ..... \n");
  35.  for (i = 0; i < 7; i++)
  36.    getsect(&directry[(i*512)],drive,(i+5));
  37.  
  38.  volume();
  39. }
  40.  
  41.  
  42. /* --- volume - do the actual diskette operation to create volume name --- */
  43.  
  44. volume()
  45. {
  46.  int i;
  47.  char *p;
  48.  
  49.  nsects = chgflag = 0;
  50.  
  51.  
  52.  
  53. /* SET UP VOLUME ENTRY */
  54.  for (i = 0; i < 11; i++)     /* initialize name to spaces */
  55.    vol[i] = ' ';
  56.  
  57.  for (i = 11; i < 32; i++)     /* place zeroes in remainder */
  58.    vol[i] = 0;
  59.  
  60.  vol[11] = 8;                  /* set up codes DOS uses for volumes */
  61.  vol[22] = 0x65;
  62.  vol[24] = 0x21;
  63.  
  64. /* TRANSFER VOLUME NAME TO VOLUME ENTRY */
  65.  i = 0;
  66.  p = volget;
  67.  while (*p)
  68.    vol[i++] = *p++;
  69.  
  70.  
  71. /* SEARCH FOR EMPTY DIRECTORY ENTRY TO MOVE FIRST ONE TO */
  72.  i = cmpflag = 0;
  73.  while (!cmpflag)
  74.   {
  75.    direntry = i * 32;
  76.    if (directry[direntry] == 0)
  77.      cmpflag = 1;
  78.    else if (i > 112)
  79.     {
  80.      printf("No directory space left, terminating to DOS \n");
  81.      return;
  82.     }
  83.    else
  84.      i++;
  85.   }
  86.  
  87. /* MOVE FIRST DIRECTORY ENTRY TO THIS BLANK ONE */
  88.  for (i = 0; i < 32; i++)
  89.    directry[(direntry + i)] = directry[i];
  90.  
  91. /* MOVE VOLUME NAME TO FIRST ENTRY */
  92.  for (i = 0; i < 32; i++)
  93.    directry[i] = vol[i];
  94.  
  95.  printf("\n Writing revised directory with volume name to diskette ..... \n");
  96.  
  97.  for (i = 0; i < 7; i++)
  98.    putsect(&directry[(i*512)],drive,(i+5));
  99. }
  100.  
  101. 
  102.