cv.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. static char rcsid[] = "$Id$";
  2. /*
  3. * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. *
  5. * This product is part of the Amsterdam Compiler Kit.
  6. *
  7. * Permission to use, sell, duplicate or disclose this software must be
  8. * obtained in writing. Requests for such permissions may be sent to
  9. *
  10. * Dr. Andrew S. Tanenbaum
  11. * Wiskundig Seminarium
  12. * Vrije Universiteit
  13. * Postbox 7161
  14. * 1007 MC Amsterdam
  15. * The Netherlands
  16. *
  17. */
  18. #include <stdio.h>
  19. #include <a.out.h>
  20. /*
  21. * NOTE: Beware that the a.out.h file included here should be the a.out.h
  22. * file of the TARGET machine, not of the SOURCE machine.
  23. */
  24. struct bhdr s_exec;
  25. main(argc,argv) char **argv; {
  26. unsigned short losh,hish;
  27. long addr,maxaddr;
  28. short count;
  29. maxaddr=0;
  30. if (argc != 3) {
  31. fprintf(stderr,"Usage: %s VU-a.out Bleasdale-a.out\n",argv[0]);
  32. exit(-1);
  33. }
  34. if (freopen(argv[1],"r",stdin)==NULL) {
  35. perror(argv[1]);
  36. exit(-1);
  37. }
  38. if (freopen(argv[2],"w",stdout)==NULL) {
  39. perror(argv[2]);
  40. exit(-1);
  41. }
  42. while (fread(&hish,sizeof(short),1,stdin)==1) {
  43. if (fread(&losh,sizeof(short),1,stdin)!=1)
  44. exit(fprintf(stderr,"foo\n"));
  45. addr=losh+(((long)hish)*65536L);
  46. addr -= 0x20000; /* entry point is 0x20000 on Bleasdale */
  47. if (fread(&count,sizeof(short),1,stdin)!=1)
  48. exit(fprintf(stderr,"bar\n"));
  49. fseek(stdout,addr+sizeof(s_exec),0);
  50. while (count--) {
  51. putchar(getchar());
  52. addr++;
  53. }
  54. if (addr>maxaddr)
  55. maxaddr = addr;
  56. }
  57. s_exec.fmagic = FMAGIC;
  58. s_exec.dsize = maxaddr;
  59. s_exec.entry = 0x20000;
  60. fseek(stdout,0L,0);
  61. fwrite(&s_exec,sizeof(s_exec),1,stdout);
  62. chmod(argv[2],0755);
  63. return 0;
  64. }