122 program = strrchr(argv[0],
'/');
130 memset(¶ms, 0,
sizeof(params));
133 while ((opt =
getopt(argc, argv,
"adhsv")) != EOF) {
169 printf(
"Try `%s -h' for a complete list of options.\n",
178 if (compiler == NULL) {
179 fprintf(stderr,
"wsc: could not create compiler\n");
183 for (i =
optind; i < argc; i++) {
187 ifp = fopen(argv[i],
"rb");
189 fprintf(stderr,
"wsc: could not open input file `%s': %s'\n",
190 argv[i], strerror(errno));
195 outname =
malloc(strlen(argv[i]) + 1 + 1);
196 if (outname == NULL) {
197 fprintf(stderr,
"wmlsc: could not create output file name: %s\n",
201 strcpy(outname, argv[i]);
202 strcat(outname,
"c");
204 ofp = fopen(outname,
"wb");
206 fprintf(stderr,
"wsc: could not create output file `%s': %s\n",
207 outname, strerror(errno));
215 unsigned char *output;
218 if (stat(argv[i], &stat_st) == -1) {
219 fprintf(stderr,
"wsc: could not stat input file `%s': %s\n",
220 argv[i], strerror(errno));
225 data =
malloc(stat_st.st_size);
227 fprintf(stderr,
"wsc: could not allocate input buffer: %s\n",
231 if (fread(data, 1, stat_st.st_size, ifp) < (
size_t) stat_st.st_size) {
232 fprintf(stderr,
"wsc: could not read data: %s\n",
237 &output, &output_len);
238 if (result ==
WS_OK) {
240 if (fwrite(output, 1, output_len, ofp) != output_len) {
242 "wsc: could not save output to file `%s': %s\n",
243 outname, strerror(errno));
258 if (result !=
WS_OK) {
260 fprintf(stderr,
"wsc: compilation failed: %s\n",
static void pragma_meta(const WsUtf8String *property_name, const WsUtf8String *content, const WsUtf8String *scheme, void *context)
unsigned int print_symbolic_assembler
void ws_free_byte_code(unsigned char *byte_code)
WsResult ws_compile_file(WsCompilerPtr compiler, const char *input_name, FILE *input, FILE *output)
WsCompilerPtr ws_create(WsCompilerParams *params)
unsigned int use_latin1_strings
int getopt(int argc, char **argv, char *opts)
void ws_destroy(WsCompilerPtr compiler)
WsResult ws_compile_data(WsCompilerPtr compiler, const char *input_name, const unsigned char *input, size_t input_len, unsigned char **output_return, size_t *output_len_return)
unsigned int print_assembler
void * meta_name_cb_context
WsPragmaMetaProc meta_name_cb
WsPragmaMetaProc meta_http_equiv_cb
const char * ws_result_to_string(WsResult result)
void * meta_http_equiv_cb_context