{"id":13420364,"url":"https://github.com/dparrish/libcli","last_synced_at":"2025-10-22T06:35:05.542Z","repository":{"id":1596033,"uuid":"723493","full_name":"dparrish/libcli","owner":"dparrish","description":"Libcli provides a shared library for including a Cisco-like command-line interface into other software.  It's a telnet interface which supports command-line editing, history, authentication and callbacks for a user-definable function tree.","archived":false,"fork":false,"pushed_at":"2024-07-04T07:36:05.000Z","size":446,"stargazers_count":289,"open_issues_count":24,"forks_count":144,"subscribers_count":31,"default_branch":"stable","last_synced_at":"2024-07-31T22:54:57.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dparrish.com/link/libcli","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dparrish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-06-16T05:59:18.000Z","updated_at":"2024-06-24T19:40:01.000Z","dependencies_parsed_at":"2024-10-26T17:49:28.695Z","dependency_job_id":"59b6a8b5-05ce-438b-8740-cd802782f14b","html_url":"https://github.com/dparrish/libcli","commit_stats":{"total_commits":209,"total_committers":22,"mean_commits":9.5,"dds":0.5837320574162679,"last_synced_commit":"3034c77438aca37fd5fc58a2bca04265d6d6a819"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dparrish%2Flibcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dparrish%2Flibcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dparrish%2Flibcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dparrish%2Flibcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dparrish","download_url":"https://codeload.github.com/dparrish/libcli/tar.gz/refs/heads/stable","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695455,"owners_count":20332622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:32.133Z","updated_at":"2025-10-22T06:35:00.504Z","avatar_url":"https://github.com/dparrish.png","language":"C","readme":"Libcli provides a shared C library for including a Cisco-like command-line\ninterface into other software.\n\nIt’s a telnet interface which supports command-line editing, history,\nauthentication and callbacks for a user-definable function tree.\n\nTo compile:\n\n```sh\n$ make\n$ make install\n```\n\nNote - as of version 1.10.5 you have a compile time decision on using select()\nor poll() in cli_loop().  The default is to use the legacy 'select()' call.\nIf built with 'CFLAGS=-DLIBCLI_USE_POLL make' then the poll() system call will\nbe used instead.  One additional check is being made now in cli_loop() to \nensure that the passed file descriptor is in range.  If not, an error message\nwill be sent and the cli_loop() will exit in the child process with CLI_ERROR.\n\nThis will install `libcli.so` into `/usr/local/lib`. If you want to change the\nlocation, edit Makefile.\n\nThere is a test application built called clitest. Run this and telnet to port\n8000.\n\nBy default, a single username and password combination is enabled.\n\n```\nUsername: fred\nPassword: nerk\n```\n\nGet help by entering `help` or hitting `?`.\n\nlibcli provides support for using the arrow keys for command-line editing. Up\nand Down arrows will cycle through the command history, and Left \u0026 Right can be\nused for editing the current command line.\n\nlibcli also works out the shortest way of entering a command, so if you have a\ncommand `show users | grep foobar` defined, you can enter `sh us | g foobar` if that\nis the shortest possible way of doing it.\n\nEnter `sh?` at the command line to get a list of commands starting with `sh`\n\nA few commands are defined in every libcli program:\n\n* `help`\n* `quit`\n* `exit`\n* `logout`\n* `history`\n\nUse in your own code:\n\nFirst of all, make sure you `#include \u003clibcli.h\u003e` in your C code, and link with\n`-lcli`.\n\nIf you have any trouble with this, have a look at clitest.c for a\ndemonstration.\n\nStart your program off with a `cli_init()`.\nThis sets up the internal data structures required.\n\nWhen a user connects, they are presented with a greeting if one is set using the\n`cli_set_banner(banner)` function.\n\nBy default, the command-line session is not authenticated, which means users\nwill get full access as soon as they connect. As this may not be always the best\nthing, 2 methods of authentication are available.\n\nFirst, you can add username / password combinations with the\n`cli_allow_user(username, password)` function. When a user connects, they can\nconnect with any of these username / password combinations.\n\nSecondly, you can add a callback using the `cli_set_auth_callback(callback)`\nfunction. This function is passed the username and password as `char *`, and must\nreturn `CLI_OK` if the user is to have access and `CLI_ERROR` if they are not.\n\nThe library itself will take care of prompting the user for credentials.\n\nCommands are built using a tree-like structure. You define commands with the\n`cli_register_command(parent, command, callback, privilege, mode, help)` function.\n\n`parent` is a `cli_command *` reference to a previously added command. Using a\nparent you can build up complex commands.\n\ne.g. to provide commands `show users`, `show sessions` and `show people`, use\nthe following sequence:\n\n```c\ncli_command *c = cli_register_command(NULL, \"show\", NULL, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, NULL);\ncli_register_command(c, \"sessions\", fn_sessions, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, \"Show the sessions connected\");\ncli_register_command(c, \"users\", fn_users, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, \"Show the users connected\");\ncli_register_command(c, \"people\", fn_people, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, \"Show a list of the people I like\");\n```\n\nIf callback is `NULL`, the command can be used as part of a tree, but cannot be\nindividually run. \n\nIf you decide later that you don't want a command to be run, you can call\n`cli_unregister_command(command)`.\nYou can use this to build dynamic command trees.\n\nIt is possible to carry along a user-defined context to all command callbacks\nusing `cli_set_context(cli, context)` and `cli_get_context(cli)` functions.\n\n\nYou are responsible for accepting a TCP connection, and for creating a\nprocess or thread to run the cli.  Once you are ready to process the\nconnection, call `cli_loop(cli, sock)` to interact with the user on the\ngiven socket.  Note that as mentioned above, if the select() call is used and \nsock is out of range (\u003e= FD_SETSIZE) then cli_loop() will display an error in\nboth the parent process and to the remote TCP connection before exiting that routine.\n\nThis function will return when the user exits the cli, either by breaking the\nconnection or entering `quit`.\n\nCall `cli_done()` to free the data structures.\n\n","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdparrish%2Flibcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdparrish%2Flibcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdparrish%2Flibcli/lists"}