Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
term.h File Reference
#include "libavrdude.h"
+ Include dependency graph for term.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int terminal_mode (PROGRAMMER *pgm, struct avrpart *p)
 
char * terminal_get_input (const char *prompt)
 

Function Documentation

◆ terminal_get_input()

char * terminal_get_input ( const char *  prompt)
892{
893#if defined(HAVE_LIBREADLINE) && !defined(WIN32NATIVE)
894 char *input;
895 input = readline(prompt);
896 if ((input != NULL) && (strlen(input) >= 1))
897 add_history(input);
898
899 return input;
900#else
901 char input[256];
902 printf("%s", prompt);
903 if (fgets(input, sizeof(input), stdin))
904 {
905 /* FIXME: readline strips the '\n', should this too? */
906 return strdup(input);
907 }
908 else
909 return NULL;
910#endif
911}
static int input(void)

References input().

Referenced by avrdude_main(), and terminal_mode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ terminal_mode()

int terminal_mode ( PROGRAMMER pgm,
struct avrpart p 
)
915{
916 char * cmdbuf;
917 int i;
918 char * q;
919 int rc;
920 int argc;
921 char ** argv;
922
923 rc = 0;
924 while ((cmdbuf = terminal_get_input("avrdude> ")) != NULL) {
925 /*
926 * find the start of the command, skipping any white space
927 */
928 q = cmdbuf;
929 while (*q && isspace((int)*q))
930 q++;
931
932 /* skip blank lines and comments */
933 if (!*q || (*q == '#'))
934 continue;
935
936 /* tokenize command line */
937 argc = tokenize(q, &argv);
938
939 fprintf(stdout, ">>> ");
940 for (i=0; i<argc; i++)
941 fprintf(stdout, "%s ", argv[i]);
942 fprintf(stdout, "\n");
943
944 /* run the command */
945 rc = do_cmd(pgm, p, argc, argv);
946 free(argv);
947 if (rc > 0) {
948 rc = 0;
949 break;
950 }
951 free(cmdbuf);
952 }
953
954 return rc;
955}
void free(void *)
static PROGRAMMER * pgm
Definition main.c:192
char * terminal_get_input(const char *prompt)
Definition term.c:891
static int tokenize(char *s, char ***argv)
Definition term.c:781
static int do_cmd(PROGRAMMER *pgm, struct avrpart *p, int argc, char *argv[])
Definition term.c:858

References do_cmd(), free(), pgm, terminal_get_input(), and tokenize().

Referenced by avrdude_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: