7 #include "string_pool.h"
9 int main(int argc
, char **argv
)
14 pool_init(300000, 30000);
15 for (fgets(buffer
, 4096, stdin
);
16 !feof(stdin
); fgets(buffer
, 4096, stdin
)) {
18 cmd
= strtok(buffer
, " ");
19 if (!strcmp(cmd
, "copy")) {
20 a1
= strtok(NULL
, ":");
21 a2
= strtok(NULL
, "\"");
23 a3
= strtok(NULL
, "\"");
24 printf("%s %s:\"", cmd
, a1
);
25 for (a2
= strtok(a2
, "/"); a2
;
26 (a2
= strtok(NULL
, a2
)) && putchar('/')) {
27 printf("%d", pool_intern(a2
));
30 for (a3
= strtok(a3
, "/"); a3
;
31 (a3
= strtok(NULL
, a3
)) && putchar('/')) {
32 printf("%d", pool_intern(a3
));
35 } else if (!strcmp(cmd
, "add") || !strcmp(cmd
, "modify") || !strcmp(cmd
, "delete")) {
36 a1
= strtok(NULL
, "\"");
39 for (a1
= strtok(a1
, "/"); a1
;
40 (a1
= strtok(NULL
, a1
)) && putchar('/')) {
41 printf("%d", pool_intern(a1
));
44 } else if (!strcmp(cmd
, "commit")) {
45 a1
= strtok(NULL
, "\n");
46 printf("%s %s\n", cmd
, a1
);