From: Maarten Bosma Date: Sat, 16 Apr 2005 11:11:52 +0000 (+0000) Subject: PackageManager: Converted cmdline interface to C X-Git-Tag: backups/powerpc@14753~98 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=58096a81e62e9e96ea0b7552df984b26621b232c;hp=1eb9c1db51c58de0e80455e86557ac219e77864a PackageManager: Converted cmdline interface to C svn path=/trunk/; revision=14632 --- diff --git a/rosapps/packmgr/cmd-line/main.c b/rosapps/packmgr/cmd-line/main.c new file mode 100644 index 00000000000..07e9f0e2acf --- /dev/null +++ b/rosapps/packmgr/cmd-line/main.c @@ -0,0 +1,207 @@ +//////////////////////////////////////////////////////// +// +// main.cpp +// +// Implementation of a Commandlne Interface +// for the ReactOs Package Manager +// +// Maarten Bosma, 09.01.2004 +// maarten.paul@bosma.de +// +//////////////////////////////////////////////////////////////////// + +#include "main.h" +#include + + +int main (int argc, char **argv) +{ + wprintf(L"ReactOs PackageManager %d.%d.%d Commandline Interface \n\n", PACKMGR_VERSION_MAJOR, PACKMGR_VERSION_MINOR, PACKMGR_VERSION_PATCH_LEVEL); + Argv = argv; Argc = argc; + + if(argc<2) + return Help(); + + + // install a package + if (argv[1] == "install") + Install(); + + // install a package from source + else if (argv[1] == "src-inst") + { + wprintf(L"Sorry but I can't do that yet. \n"); + } + + // update a package + else if (argv[1] == "update") + { + wprintf(L"Sorry but I can't do that yet. \n"); + } + + // update everything + else if (argv[1] == "dist-upgrade") + { + wprintf(L"Sorry but I can't do that yet. \n"); + } + + // remove a package + else if (argv[1] == "remove") + { + wprintf(L"Sorry but I can't do that yet. \n"); + } + + // search for a package + else if (argv[1] == "show") + { + Show(); + } + + // search for a package + else if (argv[1] == "search") + { + wprintf(L"Sorry but I can't do that yet. \n"); + } + + else + Help(); + + // + wprintf(L"\n"); + + + return 0; +} + +int Help (void) +{ + wprintf(L"Usage: ros-get [command] \n\n"); + + wprintf(L"Possible commands: \n"); + wprintf(L" install [package name] \t Installs a package \n\n"); + wprintf(L" show [package name] \t\t Shows you detailed information about a package \n"); + + wprintf(L"Currently unimplemented commands: \n"); + wprintf(L" src-install [package name] \t Installs a package from source code \n"); + wprintf(L" update [package name] \t Updates a package \n"); + wprintf(L" dist-update [package name] \t Updates a package \n"); + wprintf(L" remove [package name] \t Uninstalls a package \n\n"); + + wprintf(L" search [search agrument] \t Finds a package \n"); + wprintf(L" list \t\t\t\t Lists all installed programs \n"); + + return 0; +} + +int Ask (const WCHAR* question) +{ + // ask the user + wprintf(L"%s [y/n] ", question); + char answer = getchar(); + + // clear keybuffer + while(getchar()!='\n'); + wprintf(L"\n"); + + // prozess answer + if (answer == 'y') + return 1; + + else if (answer == 'n') + return 0; + + return Ask(question); +} + +int SetStatus (int status1, int status2, WCHAR* text) +{ + if(text) + wprintf(L"%s\n", text); + + // If the Status is 1000 things are done + if(status1==1000) + { + wprintf(L"%s\n", PML_TransError(status2)); + done = TRUE; + } + + return 0; +} + +int Install (void) +{ + pTree tree; + int i, error; + + // load the tree + error = PML_LoadTree (&tree, "tree.xml", NULL); + if(error) + { + wprintf(PML_TransError(error)); + return 0; + } + + // look up the item + for (i=2; i> answer; - cout << endl; - - if (answer[0]=='y') - return 1; - - else if (answer[0]=='n') - return 0; - - return Ask(question); -} - -int SetStatus (int status1, int status2, WCHAR* text) -{ - if(text) - wprintf(L"%s\n", text); - - // If the Status is 1000 things are done - if(status1==1000) - { - wprintf(L"%s\n", PML_TransError(status2)); - done = true; - } - - return 0; -} - -int Install (void) -{ - pTree tree; - int i, error; - - // load the tree - error = PML_LoadTree (&tree, "tree.xml", NULL); - if(error) - { - cout << PML_TransError(error); - return 0; - } - - // look up the item - for (i=1; (UINT)i -#include - - -vector cmdline; -bool done = false; +int Argc; +char **Argv; +BOOL done = FALSE; int Help (void); int Install (void); diff --git a/rosapps/packmgr/lib/download.cpp b/rosapps/packmgr/lib/download.cpp index 8d450f318a1..51ab7714740 100644 --- a/rosapps/packmgr/lib/download.cpp +++ b/rosapps/packmgr/lib/download.cpp @@ -53,7 +53,8 @@ char* PML_Download (const char* url, const char* server = "tree", const char* fi // get the url - if (!server); + if (!server) + strcpy(downl, ""); else if(!strcmp(server, "tree")) strcpy(downl, tree_server); diff --git a/rosapps/packmgr/lib/en.rc b/rosapps/packmgr/lib/en.rc index c7484abb9f0..0eb49624c0c 100644 --- a/rosapps/packmgr/lib/en.rc +++ b/rosapps/packmgr/lib/en.rc @@ -17,7 +17,7 @@ BEGIN ERR_DEP1 "To install this package you have to install the following package(s) as well:\n\n" ERR_DEP2 "\nDo you want this ?" - ERR_READY "You choosen to install %d package(s). To install them you have to read and agree with each of thier licences.\n\n Do you want still want to ?" + ERR_READY "You choosen to install %d package(s). To install them you have to read and agree with each of thier licences. \n\nDo you want still want to ?" END /* EOF */