Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.1 KiB

  1. /* File: C:\WACKER\xfer\mdmx.c (Created: 17-Jan-1994)
  2. * created from HAWIN source file
  3. * mdmx.c
  4. *
  5. * Copyright 1989,1994 by Hilgraeve Inc. -- Monroe, MI
  6. * All rights reserved
  7. *
  8. * $Revision: 3 $
  9. * $Date: 7/12/02 8:09a $
  10. */
  11. #include <windows.h>
  12. #pragma hdrstop
  13. #include <setjmp.h>
  14. #define BYTE unsigned char
  15. #include <tdll\stdtyp.h>
  16. #include <tdll\session.h>
  17. #include <tdll\xfer_msc.h>
  18. #include <tdll\file_io.h>
  19. #include "xfr_srvc.h"
  20. #include "xfr_todo.h"
  21. #include "xfr_dsp.h"
  22. #include "xfer_tsc.h"
  23. #include "foo.h"
  24. #include "xfer.h"
  25. #include "xfer.hh"
  26. #include "mdmx.h"
  27. #include "mdmx.hh"
  28. /*lint -e502*/ /* lint seems to want the ~ operator applied
  29. * only to unsigned, wer'e using uchar
  30. */
  31. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  32. * mdmx_progress
  33. *
  34. * DESCRIPTION:
  35. *
  36. *
  37. * ARGUMENTS:
  38. *
  39. *
  40. * RETURNS:
  41. *
  42. */
  43. void mdmx_progress(ST_MDMX *pX, int status)
  44. {
  45. long ttime;
  46. long stime = -1;
  47. long etime = -1;
  48. long bytes_sent;
  49. long cps = -1;
  50. int k_sent;
  51. // static long displayed_time = -1L;
  52. if (pX == NULL || pX->xfertimer == -1L)
  53. {
  54. return;
  55. }
  56. ttime = bittest(status, TRANSFER_DONE) ?
  57. pX->xfertime : (long)interval(pX->xfertimer);
  58. if ((stime = ttime / 10L) != pX->displayed_time ||
  59. bittest(status, FILE_DONE | TRANSFER_DONE))
  60. {
  61. bytes_sent = pX->file_bytes + pX->total_bytes;
  62. if (bittest(status, TRANSFER_DONE))
  63. k_sent = (int)PART_HUNKS(bytes_sent, 1024);
  64. else
  65. k_sent = (int)FULL_HUNKS(bytes_sent, 1024);
  66. if ((stime > 2 ||
  67. ttime > 0 && bittest(status, FILE_DONE | TRANSFER_DONE)) &&
  68. (cps = (bytes_sent * 10L) / ttime) > 0)
  69. {
  70. if (pX->nbytes > 0)
  71. {
  72. etime = ((pX->nbytes - bytes_sent) / cps);
  73. if (pX->nfiles > 0)
  74. etime += pX->nfiles - pX->filen;
  75. }
  76. else if (pX->filesize > 0)
  77. {
  78. etime = ((pX->filesize - pX->file_bytes) / cps);
  79. }
  80. }
  81. pX->displayed_time = stime;
  82. mdmxdspProgress(pX,
  83. stime,
  84. etime,
  85. cps,
  86. pX->file_bytes,
  87. bytes_sent);
  88. }
  89. }
  90. /* end of mdmx.c */