MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl/samples/string/main.c:65–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65int main(void)
66{
67 char *src = acl_mystrdup("hello \tworld! you're welcome to China!");
68 char *ptr, *src_saved;
69 ACL_VSTRING* buf;
70 const char* s = "hello";
71 unsigned int n1 = (unsigned int) -1;
72 unsigned long n2 = (unsigned long) -1;
73 unsigned long long n3 = (unsigned long long) -1;
74 const char *str2 = "hello world, you're welcome!";
75 ACL_ARGV *tokens = acl_argv_split(str2, " \t,'!");
76 ACL_ITER iter;
77
78 printf("----------------------------------------------\r\n");
79 acl_foreach(iter, tokens)
80 printf("tokens[%d]: %s\r\n", iter.i, (const char*) iter.data);
81 printf("total: %d\r\n", iter.size);
82 acl_argv_free(tokens);
83 printf("----------------------------------------------\r\n");
84
85 src_saved = src;
86 printf("src: %s\r\n", src);
87 while ((ptr = acl_mystrtok(&src, " \t!'")) != NULL)
88 {
89 printf("--------------------------------------\r\n");
90 printf("ptr: |%s|\r\n", ptr);
91 printf("src: |%s|\r\n", src);
92 printf("src_saved: |%s|\r\n", src_saved);
93 }
94
95 acl_myfree(src_saved);
96
97 printf("----------------------------------------------\r\n");
98
99 buf = acl_vstring_alloc(1);
100 acl_vstring_sprintf(buf, "%*lu, s: %s, n1: %20u, n2: %20lu, n3: %20llu\n",
101 (int) sizeof(unsigned long) * 4, (unsigned long) getpid(),
102 s, n1, n2, n3);
103 printf("buf: %s\r\n", acl_vstring_str(buf));
104 acl_vstring_free(buf);
105
106 printf("Enter any key to continue ...\r\n");
107 getchar();
108
109 test_quote_split();
110
111 test_path_correct();
112
113 printf("sizeof(ACL_VSTRING)=%zd\r\n", sizeof(ACL_VSTRING));
114 return 0;
115}

Callers

nothing calls this directly

Calls 8

acl_argv_splitFunction · 0.85
acl_argv_freeFunction · 0.85
acl_vstring_allocFunction · 0.85
acl_vstring_sprintfFunction · 0.85
acl_vstring_freeFunction · 0.85
test_quote_splitFunction · 0.85
test_path_correctFunction · 0.85
acl_foreachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…