1 /*===-- helpers.c - tool for testing libLLVM and llvm-c API ---------------===*\
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
8 |*===----------------------------------------------------------------------===*|
10 |* Helper functions *|
12 \*===----------------------------------------------------------------------===*/
17 #define MAX_TOKENS 512
18 #define MAX_LINE_LEN 1024
20 void llvm_tokenize_stdin(void (*cb
)(char **tokens
, int ntokens
)) {
21 char line
[MAX_LINE_LEN
];
22 char *tokbuf
[MAX_TOKENS
];
24 while (fgets(line
, sizeof(line
), stdin
)) {
27 if (line
[0] == ';' || line
[0] == '\n')
30 while (c
< MAX_TOKENS
) {
31 tokbuf
[c
] = strtok(c
? NULL
: line
, " \n");