Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:1069] Patch: .global, convert.c



Fixed a problem in tools/convert.c where convert would not create a
new .global file if one didn't exist.  This problem was evident on new
installations of the server.  Also made it return success when
appropiate; before it was always returning 1.

-Jeff

*** ../../base/Server/tools/convert.c	Tue Dec 26 03:06:40 1995
--- tools/convert.c	Mon Sep 14 23:03:26 1998
***************
*** 34,39 ****
--- 34,44 ----
      if (glfd < 0) {
          fprintf(stderr, "No global file.  Resetting all stats\n");
          MZERO((char *) &old_stats, sizeof(struct old_status));
+ 		glfd = open(Global, O_RDWR|O_CREAT, 0744);
+ 		if (glfd < 0) {
+ 			fprintf(stderr, "Unable to create new global file.");
+ 			exit(1);
+ 		}
      } else {
  	fstat(glfd, &gl_stat);
  	if (gl_stat.st_size == sizeof(struct status)) {
***************
*** 42,48 ****
  	}
          if ((c=read(glfd, (char *) &old_stats, sizeof(struct old_status))) !=
          	sizeof(struct old_status)) {
!             fprintf(stderr, "Global file wrong size.  exitting\n");
          }
      }
  
--- 47,53 ----
  	}
          if ((c=read(glfd, (char *) &old_stats, sizeof(struct old_status))) !=
          	sizeof(struct old_status)) {
!             fprintf(stderr, "Global file wrong size.  Creating new one.\n");
          }
      }
  
***************
*** 70,78 ****
      printf("Writing new global\n");
      if (glfd >= 0) {
          (void) lseek(glfd, (off_t) 0, SEEK_SET);
!         (void) write(glfd, (char *) &status, sizeof(struct status));
      }
      close(glfd);
!     return 1;		/* satisfy lint */
  }
  
--- 75,86 ----
      printf("Writing new global\n");
      if (glfd >= 0) {
          (void) lseek(glfd, (off_t) 0, SEEK_SET);
!         if (write(glfd, (char *) &status, sizeof(struct status)) < 0) {
! 			fprintf(stderr, "Write failed.\n");
! 			exit(1);
! 		}
      }
      close(glfd);
!     return 0;
  }
  
+
++ Vanilla-l Mailing List ++
To unsubscribe: send "unsubscribe vanilla-l" to majordomo@real-time.com
For more information: http://archives.real-time.com