prog = (qc_program*)mem_a(sizeof(qc_program));
if (!prog) {
file_close(file);
- printf("failed to allocate program data\n");
+ fprintf(stderr, "failed to allocate program data\n");
return NULL;
}
memset(prog, 0, sizeof(*prog));
{
if (e >= (qcint)vec_size(prog->entitypool)) {
prog->vmerror++;
- printf("Accessing out of bounds edict %i\n", (int)e);
+ fprintf(stderr, "Accessing out of bounds edict %i\n", (int)e);
e = 0;
}
return (qcany*)(prog->entitydata + (prog->entityfields * e));
{
if (!e) {
prog->vmerror++;
- printf("Trying to free world entity\n");
+ fprintf(stderr, "Trying to free world entity\n");
return;
}
if (e >= (qcint)vec_size(prog->entitypool)) {
prog->vmerror++;
- printf("Trying to free out of bounds entity\n");
+ fprintf(stderr, "Trying to free out of bounds entity\n");
return;
}
if (!prog->entitypool[e]) {
prog->vmerror++;
- printf("Double free on entity\n");
+ fprintf(stderr, "Double free on entity\n");
return;
}
prog->entitypool[e] = false;
#define CheckArgs(num) do { \
if (prog->argc != (num)) { \
prog->vmerror++; \
- printf("ERROR: invalid number of arguments for %s: %i, expected %i\n", \
+ fprintf(stderr, "ERROR: invalid number of arguments for %s: %i, expected %i\n", \
__FUNCTION__, prog->argc, (num)); \
return -1; \
} \
static int qc_error(qc_program *prog)
{
- printf("*** VM raised an error:\n");
+ fprintf(stderr, "*** VM raised an error:\n");
qc_print(prog);
prog->vmerror++;
return -1;
qcany out;
if (prog->argc != 2 && prog->argc != 3) {
- printf("ERROR: invalid number of arguments for strcmp/strncmp: %i, expected 2 or 3\n",
+ fprintf(stderr, "ERROR: invalid number of arguments for strcmp/strncmp: %i, expected 2 or 3\n",
prog->argc);
return -1;
}
arg->string = prog_tempstring(prog, main_params[i].value);
break;
default:
- printf("error: unhandled parameter type: %i\n", main_params[i].vtype);
+ fprintf(stderr, "error: unhandled parameter type: %i\n", main_params[i].vtype);
break;
}
}
}
else if (argv[1][0] != '-') {
if (progsfile) {
- printf("only 1 program file may be specified\n");
+ fprintf(stderr, "only 1 program file may be specified\n");
usage();
exit(1);
}
}
else
{
- printf("unknown parameter: %s\n", argv[1]);
+ fprintf(stderr, "unknown parameter: %s\n", argv[1]);
usage();
exit(1);
}
}
if (!progsfile) {
- printf("must specify a program to execute\n");
+ fprintf(stderr, "must specify a program to execute\n");
usage();
exit(1);
}
prog = prog_load(progsfile, noexec);
if (!prog) {
- printf("failed to load program '%s'\n", progsfile);
+ fprintf(stderr, "failed to load program '%s'\n", progsfile);
exit(1);
}
prog_exec(prog, &prog->functions[fnmain], xflags, VM_JUMPS_DEFAULT);
}
else
- printf("No main function found\n");
+ fprintf(stderr, "No main function found\n");
}
prog_delete(prog);