- Timestamp:
- Mar 28, 2003, 12:22:18 PM (22 years ago)
- Location:
- trunk/src/kShell
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kShell/kShell.c
r23 r44 254 254 #define KSHELL_WILDCHAR(ch) ( (ch) == '*' || (ch) == '?' ) 255 255 256 /** 257 * the a default kShell slash. 258 */ 259 #define KSHELL_SLASH '/' 260 261 /** 262 * Checks if the character is a slash or not. 263 */ 264 #define KSHELL_ISSLASH(ch) ( (ch) == KSHELL_SLASH ) 256 265 257 266 … … 432 441 pWords = kshellWordsParse(pszCmd, 1, NULL); 433 442 if (!pWords) 434 return KSHELL_ERROR_NOT_ENOUGH T_MEMORY;443 return KSHELL_ERROR_NOT_ENOUGH_MEMORY; 435 444 if (!pWords->cWords) 436 445 return 0; … … 455 464 pWords = kshellWordsParse(pszCmd, aCmds[i].cWords, pWords); 456 465 if (!pWords) 457 return KSHELL_ERROR_NOT_ENOUGH T_MEMORY;466 return KSHELL_ERROR_NOT_ENOUGH_MEMORY; 458 467 } 459 468 rc = aCmds[i].pfnCmd(pszCmd, pWords); … … 688 697 int kshellCmd_copy(const char *pszCmd, PKSHELLWORDS pWords) 689 698 { 699 int iDst = pWords->cWords - 1; /* Last word is destination. */ 700 KBOOL fDstDir = -1; 701 int iSrc; 702 703 /* 704 * Syntax validation. 705 */ 706 if (pWords->cWords < 3) 707 return kshellSyntaxError("copy", "too few arguments."); 708 709 /* 710 * Figure out if the destion is a directory or file specification. 711 */ 712 if (KSHELL_ISSLASH(pWords->aWords[iDst].pszWord[pWords->aWords[iDst].cchWord - 1])) 713 { 714 fDstDir = TRUE; 715 while (KSHELL_ISSLASH(pWords->aWords[iDst].pszWord[pWords->aWords[iDst].cchWord - 1])) 716 pWords->aWords[iDst].cchWord--; 717 pWords->aWords[iDst].pszWord[pWords->aWords[iDst].cchWord] = '\0'; 718 } 719 else 720 fDstDir = kDirExist(pWords->aWords[iDst].pszWord); 721 722 /* 723 * Copy sources to destination. 724 */ 725 for (iSrc = 1; iSrc < iDst && !rc; iSrc++) 726 { 727 if (pWords->aWords[iSrc].fFlags & KSWORD_FLAGS_PATTERN) 728 { 729 /* 730 * 731 */ 732 } 733 else 734 { /* 735 * Construct destination name. 736 */ 737 char *pszDst; 738 KBOOL fDstFree = FALSE; 739 if (fDstDir) 740 { 741 fDstFree = TRUE; 742 pszDst = malloc(pWords->aWords[iDst].cchWord + 1 + pWords->aWords[iSrc].cchWord + 1); 743 if (pszDst) 744 return KSHELL_ERROR_NOT_ENOUGH_MEMORY; 745 kMemCpy(pszDst, pWords->aWords[iDst].pszWord, pWords->aWords[iDst].cchWord); 746 pszDst[pWords->aWords[iDst].cchWord] = KSHELL_SLASH; 747 kMemCpy(pszDst + pWords->aWords[iDst].cchWord + 1, 748 pWords->aWords[iSrc].pszWord 749 pWords->aWords[iSrc].cchWord + 1); 750 } 751 else 752 pszDst = pWords->aWords[iDst].pszWord; 753 754 /* 755 * Do the copy. 756 */ 757 rc = kFileCopy(pWords->aWords[iSrc].pszWord, pszDst); 758 if (rc) 759 { 760 kshellError("copy", "failed to copy '%s' to '%s' rc=%d.", 761 pWords->aWords[iSrc].pszWord, 762 pDst, rc); 763 } 764 765 if (fDstFree) 766 free(pszDst); 767 } 768 } 769 690 770 return -1; 691 771 } … … 787 867 if (pWords->cWords >= 2) 788 868 { 789 unsigned uMsgLevel = kStrToU nsigned(pWords->aWords[1].pszWord, -2);869 unsigned uMsgLevel = kStrToUDef(pWords->aWords[1].pszWord, -2, 0); 790 870 if (uMsgLevel != -2) 791 871 { 792 if (uMsgLevel <= kEnvGetU nsigned("KBUILD_MSG_LEVEL", 0))872 if (uMsgLevel <= kEnvGetUDef("KBUILD_MSG_LEVEL", 0, 0)) 793 873 { 794 874 /* output all the words forcing one space separation */ -
trunk/src/kShell/kShell.h
r19 r44 31 31 */ 32 32 #define KSHELL_ERROR_SYNTAX_ERROR 1700 33 #define KSHELL_ERROR_NOT_ENOUGH T_MEMORY170833 #define KSHELL_ERROR_NOT_ENOUGH_MEMORY 1708 34 34 #define KSHELL_ERROR_PROGRAM_NOT_FOUND 1742 35 35 #define KSHELL_ERROR_COMMAND_TOO_LONG 1743 -
trunk/src/kShell/makefile
r23 r44 2 2 3 3 #CC = icc /Q /Ti+ /I../kLib/Generic/include 4 CC = icc /Q /Ti+ -DOS2 -D__i386__ -DDEBUG /I g:/ktaskmgr/tree/Generic/include5 CC = icc /Q /Ti+ /O /Oi+ -DOS2 -D__i386__ -DDEBUG /I g:/ktaskmgr/tree/Generic/include4 CC = icc /Q /Ti+ -DOS2 -D__i386__ -DDEBUG /I/ktaskmgr/tree/Generic/include 5 CC = icc /Q /Ti+ /O /Oi+ -DOS2 -D__i386__ -DDEBUG /I/ktaskmgr/tree/Generic/include 6 6 7 7 … … 10 10 11 11 kShellMain.exe: kShellMain.c kShell.c kShell.h 12 $(CC) kShellmain.c kShell.c 12 $(CC) kShellmain.c kShell.c /ktaskmgr/tree/lib/debug/klib.lib 13 13 14 14 kShellMain.obj: kShellMain.c kShell.h
Note:
See TracChangeset
for help on using the changeset viewer.