MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / get_statement

Function get_statement

examples/api/apifull.c:506–551  ·  view source on GitHub ↗

* Prompt for and get input. * Statements are terminated by a semicolon. */

Source from the content-addressed store, hash-verified

504 * Statements are terminated by a semicolon.
505 */
506int get_statement (char *buf)
507{
508 short c;
509 char *p;
510 int cnt;
511
512 p = buf;
513 cnt = 0;
514 printf("SQL> ");
515
516 for (;;)
517 {
518 if ((c = getchar()) == EOF)
519 return 1;
520
521 if (c == '\n')
522 {
523 /* accept "quit" or "exit" to terminate application */
524
525 if (!strncmp(buf, "exit", 4))
526 return 1;
527 if (!strncmp(buf, "quit", 4))
528 return 1;
529
530 /* Search back through white space looking for ';'.*/
531 while (cnt && isspace(*(p - 1)))
532 {
533 p--;
534 cnt--;
535 }
536 if (*(p - 1) == ';')
537 {
538 *p++ = '\0';
539
540 return 0;
541 }
542 *p++ = ' ';
543 printf("CON> ");
544 }
545 else
546 {
547 *p++ = (char)c;
548 }
549 cnt++;
550 }
551}
552

Callers 1

mainFunction · 0.85

Calls 1

getcharFunction · 0.85

Tested by

no test coverage detected