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.

110 lines
2.2 KiB

  1. /*
  2. * History
  3. * 17-SEP-90 w-barry Ported to Cruiser
  4. */
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include <ctype.h>
  8. #include <string.h>
  9. #include <process.h>
  10. #include <windows.h>
  11. #include <tools.h>
  12. #define BS 0x08
  13. #define CTRLC 0x03
  14. #define ENTER 0x0d
  15. // Define external function calls..
  16. extern flagType delnode( char * );
  17. void
  18. Usage (
  19. void
  20. )
  21. {
  22. fputs("Usage: delnode [/q] nodes\n"
  23. " /q quiet, no confirm\n",
  24. stderr);
  25. exit (1);
  26. }
  27. flagType
  28. fConfirm (
  29. char *psz
  30. )
  31. {
  32. int ch, chLast;
  33. chLast = 0;
  34. printf ("\nDELNODE: Delete node \"%s\" and all its subdirectories? [yn] ", psz);
  35. while ( TRUE ) {
  36. ch = _getch();
  37. ch = tolower( ch );
  38. if (ch == 0x03) {
  39. printf( "^C Aborted\n" );
  40. exit( 1 );
  41. }
  42. if (ch == ENTER && (chLast == 'y' || chLast == 'n')) {
  43. putchar('\n');
  44. return (flagType)(chLast == 'y');
  45. }
  46. if (ch != 0) {
  47. if (ch == 'y' || ch == 'n') {
  48. putchar(ch);
  49. putchar('\b');
  50. }
  51. }
  52. chLast = ch;
  53. }
  54. }
  55. int
  56. __cdecl
  57. main(
  58. int c,
  59. char *v[]
  60. )
  61. {
  62. char sz[MAX_PATH];
  63. flagType fAsk = TRUE;
  64. ConvertAppToOem( c, v );
  65. SHIFT (c, v);
  66. while (c && fSwitChr (**v)) {
  67. if (!strcmp (*v+1, "q"))
  68. fAsk = FALSE;
  69. else
  70. Usage ();
  71. SHIFT (c, v);
  72. }
  73. if (c == 0)
  74. Usage ();
  75. while (c) {
  76. if (strlen( *v ) == 0) {
  77. printf( "DELNODE: invalid null argument\n" );
  78. } else if (!fAsk || fConfirm (*v)) {
  79. if (!fileext (*v, sz)) {
  80. upd ("*.*", *v, sz);
  81. } else {
  82. strcpy (sz, *v);
  83. if (!strcmp ("..", sz) || !strcmp (".", sz)) {
  84. pathcat (sz, "*.*");
  85. }
  86. }
  87. if (fAsk) {
  88. printf( "DELNODE: deleting ... \n", sz );
  89. }
  90. delnode (sz);
  91. } else if (fAsk) {
  92. printf("DELNODE: ** nothing ** deleted\n");
  93. }
  94. SHIFT (c, v);
  95. }
  96. return( 0 );
  97. }