INT CommandDelete (LPTSTR param) { /*cmd is the command that was given, in this case it will always be "del" or "delete" param is whatever is given after the command*/ LPTSTR *arg = NULL; INT args; INT i; INT nEvalArgs = 0; /* nunber of evaluated arguments */ DWORD dwFlags = 0; DWORD dwAttrFlags = 0; DWORD dwFiles = 0; LONG ch; TCHAR szOrginalArg[MAX_PATH]; /*checks the first two chars of param to see if it is /? this however allows the following command to not show help "del frog.txt /?" */ if (!StringsLoaded) { LoadStrings(); } if (!_tcsncmp (param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_DEL_HELP1); return 0; } nErrorLevel = 0; arg = split (param, &args, FALSE); if (args == 0) { /* only command given */ error_req_param_missing (); freep (arg); return 1; } /* check for options anywhere in command line */ for (i = 0; i < args; i++) { if (*arg[i] == _T('/')) { /*found a command, but check to make sure it has something after it*/ if (_tcslen (arg[i]) >= 2) { ch = _totupper (arg[i][1]); if (ch == _T('N')) { dwFlags |= DEL_NOTHING; } else if (ch == _T('P')) { dwFlags |= DEL_PROMPT; } else if (ch == _T('Q')) { dwFlags |= DEL_QUIET; } else if (ch == _T('F')) { dwFlags |= DEL_FORCE; } else if (ch == _T('S')) { dwFlags |= DEL_SUBDIR; } else if (ch == _T('T')) { dwFlags |= DEL_TOTAL; } else if (ch == _T('W')) { dwFlags |= DEL_WIPE; } else if (ch == _T('Y')) { dwFlags |= DEL_YES; } else if (ch == _T('A')) { dwFlags |= DEL_ATTRIBUTES; /*the proper syntax for /A has a min of 4 chars i.e. /A:R or /A:-H */ if (_tcslen (arg[i]) < 4) { error_invalid_parameter_format(arg[i]); return 0; } ch = _totupper (arg[i][3]); if (_tcslen (arg[i]) == 4) { if(ch == _T('A')) { dwAttrFlags |= ATTR_ARCHIVE; } if(ch == _T('H')) { dwAttrFlags |= ATTR_HIDDEN; } if(ch == _T('S')) { dwAttrFlags |= ATTR_SYSTEM; } if(ch == _T('R')) { dwAttrFlags |= ATTR_READ_ONLY; } } if (_tcslen (arg[i]) == 5) { if(ch == _T('-')) { ch = _totupper (arg[i][4]); if(ch == _T('A')) { dwAttrFlags |= ATTR_N_ARCHIVE; } if(ch == _T('H')) { dwAttrFlags |= ATTR_N_HIDDEN; } if(ch == _T('S')) { dwAttrFlags |= ATTR_N_SYSTEM; } if(ch == _T('R')) { dwAttrFlags |= ATTR_N_READ_ONLY; } } } } } nEvalArgs++; } } /* there are only options on the command line --> error!!! there is the same number of args as there is flags, so none of the args were filenames*/ if (args == nEvalArgs) { error_req_param_missing (); freep (arg); return 1; } /* keep quiet within batch files */ if (bc != NULL) dwFlags |= DEL_QUIET; /* check for filenames anywhere in command line */ for (i = 0; i < args && !(dwFiles & 0x80000000); i++) { /*this checks to see if it isnt a flag, if it isnt, we assume it is a file name*/ if((*arg[i] == _T('/')) || (*arg[i] == _T('-'))) continue; /* We want to make a copies of the argument */ if(_tcslen(arg[i]) == 2 && arg[i][1] == _T(':')) { /* Check for C: D: ... */ GetRootPath(arg[i],szOrginalArg,MAX_PATH); } else { _tcscpy(szOrginalArg,arg[i]); } dwFiles += ProcessDirectory(szOrginalArg, &dwFlags, dwAttrFlags); } freep (arg); /*Based on MS cmd, we only tell what files are being deleted when /S is used */ if (dwFlags & DEL_TOTAL) { dwFiles &= 0x7fffffff; if (dwFiles < 2) { ConOutResPrintf(STRING_DEL_HELP3, dwFiles); } else { ConOutResPrintf(STRING_DEL_HELP4, dwFiles); } } return 0; }
INT cmd_move (LPTSTR param) { LPTSTR *arg; INT argc, i, nFiles; LPTSTR pszDest; TCHAR szDestPath[MAX_PATH]; TCHAR szFullDestPath[MAX_PATH]; TCHAR szSrcDirPath[MAX_PATH]; TCHAR szSrcPath[MAX_PATH]; TCHAR szFullSrcPath[MAX_PATH]; DWORD dwFlags = 0; INT nOverwrite = 0; WIN32_FIND_DATA findBuffer; HANDLE hFile; /* used only when source and destination directories are on different volume*/ HANDLE hDestFile; WIN32_FIND_DATA findDestBuffer; TCHAR szMoveDest[MAX_PATH]; TCHAR szMoveSrc[MAX_PATH]; LPTSTR pszDestDirPointer; LPTSTR pszSrcDirPointer; INT nDirLevel = 0; LPTSTR pszFile; BOOL OnlyOneFile; BOOL FoundFile; BOOL MoveStatus; DWORD dwMoveFlags = 0; DWORD dwMoveStatusFlags = 0; if (!_tcsncmp (param, _T("/?"), 2)) { #if 0 ConOutPuts (_T("Moves files and renames files and directories.\n\n" "To move one or more files:\n" "MOVE [/N][/Y|/-Y][drive:][path]filename1[,...] destination\n" "\n" "To rename a directory:\n" "MOVE [/N][/Y|/-Y][drive:][path]dirname1 dirname2\n" "\n" " [drive:][path]filename1 Specifies the location and name of the file\n" " or files you want to move.\n" " /N Nothing. Don everthing but move files or direcories.\n" " /Y\n" " /-Y\n" "...")); #else ConOutResPaging(TRUE,STRING_MOVE_HELP2); #endif return 0; } nErrorLevel = 0; arg = splitspace(param, &argc); /* read options */ for (i = 0; i < argc; i++) { if (!_tcsicmp(arg[i], _T("/N"))) dwFlags |= MOVE_NOTHING; else if (!_tcsicmp(arg[i], _T("/Y"))) dwFlags |= MOVE_OVER_YES; else if (!_tcsicmp(arg[i], _T("/-Y"))) dwFlags |= MOVE_OVER_NO; else break; } nFiles = argc - i; if (nFiles < 1) { /* there must be at least one pathspec */ error_req_param_missing(); freep(arg); return 1; } if (nFiles > 2) { /* there are more than two pathspecs */ error_too_many_parameters(param); freep(arg); return 1; } /* If no destination is given, default to current directory */ pszDest = (nFiles == 1) ? _T(".") : arg[i + 1]; /* check for wildcards in source and destination */ if (_tcschr(pszDest, _T('*')) != NULL || _tcschr(pszDest, _T('?')) != NULL) { /* '*'/'?' in dest, this doesnt happen. give folder name instead*/ error_invalid_parameter_format(pszDest); freep(arg); return 1; } if (_tcschr(arg[i], _T('*')) != NULL || _tcschr(arg[i], _T('?')) != NULL) { dwMoveStatusFlags |= MOVE_SOURCE_HAS_WILD; } /* get destination */ GetFullPathName (pszDest, MAX_PATH, szDestPath, NULL); TRACE ("Destination: %s\n", debugstr_aw(szDestPath)); /* get source folder */ GetFullPathName(arg[i], MAX_PATH, szSrcDirPath, &pszFile); if (pszFile != NULL) *pszFile = _T('\0'); TRACE ("Source Folder: %s\n", debugstr_aw(szSrcDirPath)); hFile = FindFirstFile (arg[i], &findBuffer); if (hFile == INVALID_HANDLE_VALUE) { ErrorMessage (GetLastError (), arg[i]); freep (arg); return 1; } /* check for special cases "." and ".." and if found skip them */ FoundFile = TRUE; while(FoundFile && (_tcscmp(findBuffer.cFileName,_T(".")) == 0 || _tcscmp(findBuffer.cFileName,_T("..")) == 0)) FoundFile = FindNextFile (hFile, &findBuffer); if (!FoundFile) { /* what? we don't have anything to move? */ error_file_not_found(); FindClose(hFile); freep(arg); return 1; } OnlyOneFile = TRUE; /* check if there can be found files as files have first priority */ if (findBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) dwMoveStatusFlags |= MOVE_SOURCE_IS_DIR; else dwMoveStatusFlags |= MOVE_SOURCE_IS_FILE; while(OnlyOneFile && FindNextFile(hFile,&findBuffer)) { if (!(findBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { ConOutPrintf(_T("")); if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE) OnlyOneFile = FALSE; else { /* this has been done this way so that we don't disturb other settings if they have been set before this */ dwMoveStatusFlags |= MOVE_SOURCE_IS_FILE; dwMoveStatusFlags &= ~MOVE_SOURCE_IS_DIR; } } } FindClose(hFile); TRACE ("Do we have only one file: %s\n", OnlyOneFile ? "TRUE" : "FALSE"); /* we have to start again to be sure we don't miss any files or folders*/ hFile = FindFirstFile (arg[i], &findBuffer); if (hFile == INVALID_HANDLE_VALUE) { ErrorMessage (GetLastError (), arg[i]); freep (arg); return 1; } /* check for special cases "." and ".." and if found skip them */ FoundFile = TRUE; while(FoundFile && (_tcscmp(findBuffer.cFileName,_T(".")) == 0 || _tcscmp(findBuffer.cFileName,_T("..")) == 0)) FoundFile = FindNextFile (hFile, &findBuffer); if (!FoundFile) { /* huh? somebody removed files and/or folders which were there */ error_file_not_found(); FindClose(hFile); freep(arg); return 1; } /* check if source and destination paths are on different volumes */ if (szSrcDirPath[0] != szDestPath[0]) dwMoveStatusFlags |= MOVE_PATHS_ON_DIF_VOL; /* move it */ do { TRACE ("Found file/directory: %s\n", debugstr_aw(findBuffer.cFileName)); nOverwrite = 1; dwMoveFlags = 0; dwMoveStatusFlags &= ~MOVE_DEST_IS_FILE & ~MOVE_DEST_IS_DIR & ~MOVE_SRC_CURRENT_IS_DIR & ~MOVE_DEST_EXISTS; _tcscpy(szFullSrcPath,szSrcDirPath); if(szFullSrcPath[_tcslen(szFullSrcPath) - 1] != _T('\\')) _tcscat (szFullSrcPath, _T("\\")); _tcscat(szFullSrcPath,findBuffer.cFileName); _tcscpy(szSrcPath, szFullSrcPath); if (IsExistingDirectory(szSrcPath)) { /* source is directory */ if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE) { dwMoveStatusFlags |= MOVE_SRC_CURRENT_IS_DIR; /* source is file but at the current round we found a directory */ continue; } TRACE ("Source is dir: %s\n", debugstr_aw(szSrcPath)); dwMoveFlags = MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED; } /* if source is file we don't need to do anything special */ if (IsExistingDirectory(szDestPath)) { /* destination is existing directory */ TRACE ("Destination is directory: %s\n", debugstr_aw(szDestPath)); dwMoveStatusFlags |= MOVE_DEST_IS_DIR; /*build the dest string(accounts for *)*/ _tcscpy (szFullDestPath, szDestPath); /*check to see if there is an ending slash, if not add one*/ if(szFullDestPath[_tcslen(szFullDestPath) - 1] != _T('\\')) _tcscat (szFullDestPath, _T("\\")); _tcscat (szFullDestPath, findBuffer.cFileName); if (IsExistingFile(szFullDestPath) || IsExistingDirectory(szFullDestPath)) dwMoveStatusFlags |= MOVE_DEST_EXISTS; dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED; } if (IsExistingFile(szDestPath)) { /* destination is a file */ TRACE ("Destination is file: %s\n", debugstr_aw(szDestPath)); dwMoveStatusFlags |= MOVE_DEST_IS_FILE | MOVE_DEST_EXISTS; _tcscpy (szFullDestPath, szDestPath); dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED; } TRACE ("Move Status Flags: 0x%X\n",dwMoveStatusFlags); if (dwMoveStatusFlags & MOVE_SOURCE_IS_DIR && dwMoveStatusFlags & MOVE_DEST_IS_DIR && dwMoveStatusFlags & MOVE_SOURCE_HAS_WILD) { /* We are not allowed to have existing source and destination dir when there is wildcard in source */ error_syntax(NULL); FindClose(hFile); freep(arg); return 1; } if (!(dwMoveStatusFlags & (MOVE_DEST_IS_FILE | MOVE_DEST_IS_DIR))) { /* destination doesn't exist */ _tcscpy (szFullDestPath, szDestPath); if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE) dwMoveStatusFlags |= MOVE_DEST_IS_FILE; if (dwMoveStatusFlags & MOVE_SOURCE_IS_DIR) dwMoveStatusFlags |= MOVE_DEST_IS_DIR; dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED; } if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE && dwMoveStatusFlags & MOVE_DEST_IS_FILE && !OnlyOneFile) { /*source has many files but there is only one destination file*/ error_invalid_parameter_format(pszDest); FindClose(hFile); freep (arg); return 1; } /*checks to make sure user wanted/wants the override*/ if((dwFlags & MOVE_OVER_NO) && (dwMoveStatusFlags & MOVE_DEST_EXISTS)) continue; if(!(dwFlags & MOVE_OVER_YES) && (dwMoveStatusFlags & MOVE_DEST_EXISTS)) nOverwrite = MoveOverwrite (szFullDestPath); if (nOverwrite == PROMPT_NO || nOverwrite == PROMPT_BREAK) continue; if (nOverwrite == PROMPT_ALL) dwFlags |= MOVE_OVER_YES; ConOutPrintf (_T("%s => %s "), szSrcPath, szFullDestPath); /* are we really supposed to do something */ if (dwFlags & MOVE_NOTHING) continue; /*move the file*/ if (!(dwMoveStatusFlags & MOVE_SOURCE_IS_DIR && dwMoveStatusFlags & MOVE_PATHS_ON_DIF_VOL)) /* we aren't moving source folder to different drive */ MoveStatus = MoveFileEx (szSrcPath, szFullDestPath, dwMoveFlags); else { /* we are moving source folder to different drive */ _tcscpy(szMoveDest, szFullDestPath); _tcscpy(szMoveSrc, szSrcPath); DeleteFile(szMoveDest); MoveStatus = CreateDirectory(szMoveDest, NULL); /* we use default security settings */ if (MoveStatus) { _tcscat(szMoveDest,_T("\\")); _tcscat(szMoveSrc,_T("\\")); nDirLevel = 0; pszDestDirPointer = szMoveDest + _tcslen(szMoveDest); pszSrcDirPointer = szMoveSrc + _tcslen(szMoveSrc); _tcscpy(pszSrcDirPointer,_T("*.*")); hDestFile = FindFirstFile(szMoveSrc, &findDestBuffer); if (hDestFile == INVALID_HANDLE_VALUE) MoveStatus = FALSE; else { BOOL FirstTime = TRUE; FoundFile = TRUE; MoveStatus = FALSE; while(FoundFile) { if (FirstTime) FirstTime = FALSE; else FoundFile = FindNextFile (hDestFile, &findDestBuffer); if (!FoundFile) { /* Nothing to do in this folder so we stop working on it */ FindClose(hDestFile); (pszSrcDirPointer)--; (pszDestDirPointer)--; _tcscpy(pszSrcDirPointer,_T("")); _tcscpy(pszDestDirPointer,_T("")); if (nDirLevel > 0) { TCHAR szTempPath[MAX_PATH]; INT nDiff; FoundFile = TRUE; /* we need to continue our seek for files */ nDirLevel--; RemoveDirectory(szMoveSrc); GetDirectory(szMoveSrc,szTempPath,0); nDiff = _tcslen(szMoveSrc) - _tcslen(szTempPath); pszSrcDirPointer = pszSrcDirPointer - nDiff; _tcscpy(pszSrcDirPointer,_T("")); GetDirectory(szMoveDest,szTempPath,0); nDiff = _tcslen(szMoveDest) - _tcslen(szTempPath); pszDestDirPointer = pszDestDirPointer - nDiff; _tcscpy(pszDestDirPointer,_T("")); if(szMoveSrc[_tcslen(szMoveSrc) - 1] != _T('\\')) _tcscat (szMoveSrc, _T("\\")); if(szMoveDest[_tcslen(szMoveDest) - 1] != _T('\\')) _tcscat (szMoveDest, _T("\\")); pszDestDirPointer = szMoveDest + _tcslen(szMoveDest); pszSrcDirPointer = szMoveSrc + _tcslen(szMoveSrc); _tcscpy(pszSrcDirPointer,_T("*.*")); hDestFile = FindFirstFile(szMoveSrc, &findDestBuffer); if (hDestFile == INVALID_HANDLE_VALUE) continue; FirstTime = TRUE; } else { MoveStatus = TRUE; /* we moved everything so lets tell user about it */ RemoveDirectory(szMoveSrc); } continue; } /* if we find "." or ".." we'll skip them */ if (_tcscmp(findDestBuffer.cFileName,_T(".")) == 0 || _tcscmp(findDestBuffer.cFileName,_T("..")) == 0) continue; _tcscpy(pszSrcDirPointer, findDestBuffer.cFileName); _tcscpy(pszDestDirPointer, findDestBuffer.cFileName); if (IsExistingFile(szMoveSrc)) { FoundFile = CopyFile(szMoveSrc, szMoveDest, FALSE); if (!FoundFile) continue; DeleteFile(szMoveSrc); } else { FindClose(hDestFile); CreateDirectory(szMoveDest, NULL); _tcscat(szMoveDest,_T("\\")); _tcscat(szMoveSrc,_T("\\")); nDirLevel++; pszDestDirPointer = szMoveDest + _tcslen(szMoveDest); pszSrcDirPointer = szMoveSrc + _tcslen(szMoveSrc); _tcscpy(pszSrcDirPointer,_T("*.*")); hDestFile = FindFirstFile(szMoveSrc, &findDestBuffer); if (hDestFile == INVALID_HANDLE_VALUE) { FoundFile = FALSE; continue; } FirstTime = TRUE; } } } } } if (MoveStatus) ConOutResPrintf(STRING_MOVE_ERROR1); else ConOutResPrintf(STRING_MOVE_ERROR2); } while ((!OnlyOneFile || dwMoveStatusFlags & MOVE_SRC_CURRENT_IS_DIR ) && !(dwMoveStatusFlags & MOVE_SOURCE_IS_DIR) && FindNextFile (hFile, &findBuffer)); FindClose (hFile); freep (arg); return 0; }
INT CommandAttrib (LPTSTR param) { LPTSTR *arg; INT argc, i; TCHAR szPath[MAX_PATH]; TCHAR szFileName [MAX_PATH]; BOOL bRecurse = FALSE; BOOL bDirectories = FALSE; DWORD dwAttrib = 0; DWORD dwMask = 0; /* initialize strings */ szPath[0] = _T('\0'); szFileName[0] = _T('\0'); /* print help */ if (!_tcsncmp (param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_ATTRIB_HELP); return 0; } nErrorLevel = 0; /* build parameter array */ arg = split (param, &argc, FALSE, FALSE); /* check for options */ for (i = 0; i < argc; i++) { if (_tcsicmp (arg[i], _T("/s")) == 0) bRecurse = TRUE; else if (_tcsicmp (arg[i], _T("/d")) == 0) bDirectories = TRUE; } /* create attributes and mask */ for (i = 0; i < argc; i++) { if (*arg[i] == _T('+')) { if (_tcslen (arg[i]) != 2) { error_invalid_parameter_format (arg[i]); freep (arg); return -1; } switch ((TCHAR)_totupper (arg[i][1])) { case _T('A'): dwMask |= FILE_ATTRIBUTE_ARCHIVE; dwAttrib |= FILE_ATTRIBUTE_ARCHIVE; break; case _T('H'): dwMask |= FILE_ATTRIBUTE_HIDDEN; dwAttrib |= FILE_ATTRIBUTE_HIDDEN; break; case _T('R'): dwMask |= FILE_ATTRIBUTE_READONLY; dwAttrib |= FILE_ATTRIBUTE_READONLY; break; case _T('S'): dwMask |= FILE_ATTRIBUTE_SYSTEM; dwAttrib |= FILE_ATTRIBUTE_SYSTEM; break; default: error_invalid_parameter_format (arg[i]); freep (arg); return -1; } } else if (*arg[i] == _T('-')) { if (_tcslen (arg[i]) != 2) { error_invalid_parameter_format (arg[i]); freep (arg); return -1; } switch ((TCHAR)_totupper (arg[i][1])) { case _T('A'): dwMask |= FILE_ATTRIBUTE_ARCHIVE; dwAttrib &= ~FILE_ATTRIBUTE_ARCHIVE; break; case _T('H'): dwMask |= FILE_ATTRIBUTE_HIDDEN; dwAttrib &= ~FILE_ATTRIBUTE_HIDDEN; break; case _T('R'): dwMask |= FILE_ATTRIBUTE_READONLY; dwAttrib &= ~FILE_ATTRIBUTE_READONLY; break; case _T('S'): dwMask |= FILE_ATTRIBUTE_SYSTEM; dwAttrib &= ~FILE_ATTRIBUTE_SYSTEM; break; default: error_invalid_parameter_format (arg[i]); freep (arg); return -1; } } } if (argc == 0) { DWORD len; len = GetCurrentDirectory (MAX_PATH, szPath); if (szPath[len-1] != _T('\\')) { szPath[len] = _T('\\'); szPath[len + 1] = 0; } _tcscpy (szFileName, _T("*.*")); PrintAttribute (szPath, szFileName, bRecurse); freep (arg); return 0; } /* get full file name */ for (i = 0; i < argc; i++) { if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/'))) { LPTSTR p; GetFullPathName (arg[i], MAX_PATH, szPath, NULL); p = _tcsrchr (szPath, _T('\\')) + 1; _tcscpy (szFileName, p); *p = _T('\0'); if (dwMask == 0) PrintAttribute (szPath, szFileName, bRecurse); else ChangeAttribute (szPath, szFileName, dwMask, dwAttrib, bRecurse, bDirectories); } } freep (arg); return 0; }
static INT ServiceActivate (LPTSTR param, HWND hWnd) { LPTSTR *p = 0, p_tmp; INT argc = 0, i; INT iAction = 0; LPTSTR title = 0; WINDOWPLACEMENT wp; RECT pos; LPTSTR tmp; if (*param) p = split(param, &argc, FALSE); for (i = 0; i < argc; i++) { p_tmp = p[i]; if (*p_tmp == _T('/')) p_tmp++; if (_tcsicmp(p_tmp, _T("min")) == 0) { iAction |= A_MIN; continue; } if (_tcsicmp(p_tmp, _T("max")) == 0) { iAction |= A_MAX; continue; } if (_tcsicmp(p_tmp, _T("restore")) == 0) { iAction |= A_RESTORE; continue; } if (_tcsicmp(p_tmp, _T("close")) == 0) { iAction |= A_CLOSE; continue; } if (_tcsnicmp(p_tmp, _T("pos"), 3) == 0) { iAction |= A_POS; tmp = p_tmp+3; if (*tmp == _T('=')) tmp++; pos.left= _ttoi(tmp); if(!(tmp=_tcschr(tmp, _T(',')))) { error_invalid_parameter_format(p[i]); freep(p); return 1; } pos.top = _ttoi (++tmp); if(!(tmp=_tcschr(tmp, _T(',')))) { error_invalid_parameter_format(p[i]); freep(p); return 1; } pos.right = _ttoi(++tmp) + pos.left; if (!(tmp = _tcschr(tmp, _T(',')))) { error_invalid_parameter_format(p[i]); freep(p); return 1; } pos.bottom = _ttoi(++tmp) + pos.top; continue; } if (_tcsnicmp(p_tmp, _T("size"), 4)==0) { iAction |=A_SIZE; continue; } /* none of them=window title */ if (title) { error_invalid_parameter_format(p[i]); freep(p); return 1; } if (p_tmp[0] == _T('"')) { title = (p_tmp + 1); *_tcschr(p_tmp + 1, _T('"')) = 0; continue; } title = p_tmp; } if (title) SetWindowText(hWnd, title); wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hWnd, &wp); if (iAction & A_POS) wp.rcNormalPosition = pos; if (iAction & A_MIN) wp.showCmd = SW_MINIMIZE; if (iAction & A_MAX) wp.showCmd = SW_SHOWMAXIMIZED; /*if no actions are specified default is SW_RESTORE*/ if ((iAction & A_RESTORE) || (!iAction)) wp.showCmd = SW_RESTORE; if (iAction & A_CLOSE) { printf("!!!FIXME: CLOSE Not implemented!!!\n"); } wp.length = sizeof(WINDOWPLACEMENT); SetWindowPlacement(hWnd, &wp); if (p) freep(p); return 0; }