int main(int argc, char *argv[])
{
    int i, j;
    int do_sin = argc > 1 && !strcmp(argv[1], "sin");
    int fixed  = argc > 1 &&  strstr(argv[1], "fixed");
    double (*func)(double) = do_sin ? sin : cos;

    printf("/* This file was automatically generated. */\n");
    printf("#define CONFIG_FFT_FLOAT %d\n", !fixed);
    printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h");
    for (i = 4; i <= BITS; i++) {
        int m = 1 << i;
        double freq = 2*M_PI/m;
        printf("%s(%i) = {\n   ", do_sin ? "SINTABLE" : "COSTABLE", m);
        for (j = 0; j < m/2 - 1; j++) {
            int idx = j > m/4 ? m/2 - j : j;
            if (do_sin && j >= m/4)
                idx = m/4 - j;
            printval(func(idx*freq), fixed);
            if ((j & 3) == 3)
                printf("\n   ");
        }
        printval(func(do_sin ? -(m/4 - 1)*freq : freq), fixed);
        printf("\n};\n");
    }
    return 0;
}
示例#2
0
main(int argc, char **argv)
{
	int val;
	int size = 0;
	unsigned char c;

	printf("gcc2_compiled.:\n");
	printf("__gnu_compiled_c:\n");
	printf("\t.globl linux_compressed_start\n");
	printf("\t.text\n");
	printf("\t.align 2\n");
	printf("\t.type linux_compressed_start,@object\n");
	printf("linux_compressed_start:\n");


	val = getchar();
	while (val != EOF) {
		size++;
		c = (unsigned char) (val & 0x00ff);
		printf("\t.byte  ");
		printval((int) c);
		printf("\n");
		val = getchar();
	}
	printf("\t.size linux_compressed_start,%d\n", size);
	printf("\t.globl linux_compressed_size\n");
	printf("\t.text\n");
	printf("\t.align 2\n");
	printf("\t.type linux_compressed_size,@object\n");
	printf("\t.size linux_compressed_size,4\n");
	printf("linux_compressed_size:\n");
	printf("\t.word %d\n", size);
}
示例#3
0
文件: main.c 项目: bobchin/kozos
int main(void)
{
    init();
    puts("Hello World!\n");

    printval();
    puts("overwrite variables.\n");
    global_data = 0x20;
    global_bss  = 0x30;
    static_data = 0x40;
    static_bss  = 0x50;
    printval();

    while (1)
        ;

    return 0;
}
示例#4
0
void big_menu (m) {

	struct b_field *b;
	register i, j = 1;
	BOX     *left_box;

	b = batch_entry[batch_n]; lines = cols = wid_h = wid_e = 0;
	for (i = 0; b[i].header != NULL; i++) {
		lines++;
		wid_h = max( wid_h, (int) strlen( b[i].header ));
		wid_e = max( wid_e, b[i].width );
	}
	cols = wid_h + 2 + wid_e;
	cols = max (cols, (int) strlen(batch_name[batch_n]));

	r = (LINES - lines) - 5;
	c = m ? 3 : (COLS - cols) - 5;
	endmesg ();
	if (m) {
		if (lines == 0)
			return;
		left_box = VGetBox (r - 1, c - 1, lines + 4, cols + 4);
	}
	else {
		if (right_box != 0) {
			VUngetBox (right_box);
			VFreeBox (right_box);
		}
		right_box = VGetBox (r - 1, c - 1, lines + 4, cols + 4);
	}

	VStandOut ();
	VFillBox (r - 1, c - 1, lines + 4, cols + 4, ' ');
	VStandEnd ();
	VDrawBox (r, c, lines+2, cols+2);
	VMPutString (r, (c + (cols + 2 - strlen(batch_name[batch_n])) / 2),
		     batch_name[batch_n]);
	if (lines == 0)
		return;
	drawhdr (b);
	if (m) {
		for (i = 0; j != 0; i += j) {
			if (i >= lines)
				i = 0;
			else if (i < 0)
				i = lines - 1;
			j = editval1 (b + i, i);
			VStandOut ();
			printval (b + i, i);
			VStandEnd ();
		}
		VUngetBox (left_box);
		VFreeBox (left_box);
	}
	VSync ();
}
示例#5
0
static void printval(void *value, int type, int level, struct printparam* pp){
	struct node pn, cn;
	struct property *p;
	int i;

	pn.iteration = NULL;
	pn.parent = NULL;
	pn.type = type;
	pn.value =  value;

	printstr(pp, "<item>");
	for(p = datatypes[type].properties; p; ) {
		cn.iteration = NULL;
		cn.parent = &pn;
		cn.type = p->type;
		cn.value =  (*p->e_f)(&pn);
		if(cn.value){
			for(i = 0; i < level; i++) printstr(pp, "\t");
			if(strcmp(p->name, "next")){
				printstr(pp, "<parameter>");
				printstr(pp, "<name>");
				printstr(pp, p->name);
				printstr(pp, "</name>");
				printstr(pp, "<type>");
				printstr(pp, datatypes[p->type].type);
				printstr(pp, "</type>");
				printstr(pp, "<description>");
				printstr(pp, p->description);
				printstr(pp, "</description>");
			}
			if(datatypes[p->type].p_f){
				printstr(pp, "<value><![CDATA[");
				(*datatypes[p->type].p_f)(&cn, stdcbf, pp);
				printstr(pp, "]]></value>\n");
				printstr(pp, "</parameter>");
			}
			else {
				if(!strcmp(p->name, "next")){
/*					printstr(pp, "<!-- -------------------- -->\n"); */
					printstr(pp, "</item>\n<item>");
					p = datatypes[type].properties;
					pn.value = value = cn.value;
					continue;
				}
				else {
					printstr(pp, "\n");
					printval(cn.value, cn.type, level+1, pp);
					printstr(pp, "</parameter>");
				}
			}
		}
		p=p->next;
	}
	printstr(pp, "</item>");
}
示例#6
0
文件: print.c 项目: Open343/bitrig
void
pvar(const struct kinfo_proc *kp, VARENT *ve)
{
	VAR *v;

	v = ve->var;
	if ((v->flag & USER) && !kp->p_uvalid)
		(void)printf("%*s", v->width, "-");
	else
		printval((char *)kp + v->off, v);
}
示例#7
0
int main()
{
    int i, proc_count = 0;
    char *cuname;
    char buf[_POSIX2_LINE_MAX];
    const char *execf, *coref;
    static kvm_t *kd;
    struct kinfo_proc *kp;
    static int nproc;
    static struct kinfo_proc *plist;
    
    execf = NULL;
    coref = _PATH_DEVNULL;
    kd = kvm_openfiles(execf, coref, NULL, O_RDONLY, buf);
    plist = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc);

    for (i = 0, kp = plist; i < nproc; i++, kp++) proc_count++;
    
    printf("\n");
    printf("\033[1;31m  ```                        `\033[0;0m       \n");
    printf("\033[1;31m s` `.....---.......--.```   -/\033[0;0m      "); printval("OS", "kern.ostype"); printf(" "); psysctl("hw.machine_arch"); printf("\n");
    printf("\033[1;31m +o   .--`         /y:`      +.\033[0;0m      "); printval("Hostname", "kern.hostname");  printf("\n");
    printf("\033[1;31m  yo`:.            :o      `+-\033[0;0m       "); printval("Kernel", "kern.osrelease");  printf("\n");
    printf("\033[1;31m   y/               -/`   -o/\033[0;0m        "); printuptime(); printf("\n");
    printf("\033[1;31m  .-                  ::/sy+:.\033[0;0m       "); printf("\033[1;31mProcesses:\033[0;0m %d\n", proc_count);
    printf("\033[1;31m  /                     `--  /\033[0;0m       "); printmem(); printf("\n");
    printf("\033[1;31m `:                          :`\033[0;0m      "); printcpu();  printf("\n");
    printf("\033[1;31m `:                          :`\033[0;0m      "); printf("\033[1;31mShell:\033[0;0m ", proc_count); printshell(); printf("\n");
    printf("\033[1;31m  /                          /\033[0;0m       \n");
    printf("\033[1;31m  .-                        -.\033[0;0m       \n");
    printf("\033[1;31m   --                      -.\033[0;0m        \n");
    printf("\033[1;31m    `:`                  `:`\033[0;0m         \n");
    printf("\033[1;31m      .--             `--.\033[0;0m           \n");
    printf("\033[1;31m         .---.....----.\033[0;0m              \n");
    printf("\n");
    return (0);
}
示例#8
0
文件: casen.c 项目: ksen007/casen
void _fun2_fp(_VALUE thisframe, int64_t pc) {
  printval(thisframe);
  LOAD(CL_n);
  LOAD_INT(1);
  APPLY_NUM_TO_BOOL_BINOP(>);
  if (GET_BOOL()) {
    LOAD(CL_n);
    LOAD(CL_SS);
    GET_FIELD(CL_fac);
    LOAD(CL_n);
    LOAD_INT(1);
    APPLY_NUM_TO_NUM_BINOP(-);
    CALL_FUNCTION_FRESH(1);
    APPLY_NUM_TO_NUM_BINOP(*);
    STORE_RETURN;
  } else {
示例#9
0
int printchannel(LALFrameUFrChan * channel, double x0, int fdom)
{
    /* const char *name; */
    double x0ip, x0fp;
    double dx;
    void *data;
    int dtype;
    size_t ndata;
    size_t i;

    if (!channel)
        return -1;

    XLALFrameUFrChanVectorExpand(channel);

    /* name = XLALFrameUFrChanQueryName(channel); */
    if (!fdom)
        x0 += XLALFrameUFrChanQueryTimeOffset(channel);

    ndata = XLALFrameUFrChanVectorQueryNData(channel);
    x0 += XLALFrameUFrChanVectorQueryStartX(channel, 0);
    dx = XLALFrameUFrChanVectorQueryDx(channel, 0);
    data = XLALFrameUFrChanVectorQueryData(channel);
    dtype = XLALFrameUFrChanVectorQueryType(channel);

    x0fp = modf(x0, &x0ip);
    for (i = 0; i < ndata; ++i) {
        double xip, xfp;
        xfp = modf(x0fp + i * dx, &xip);
        xip += x0ip;
        printf("%ld.%09ld", (long)xip, (long)fabs(1e9 * xfp));
        fputs(FS, stdout);
        printval(data, i, dtype);
        fputs(RS, stdout);
    }

    return 0;
}
示例#10
0
int main()
{
    int i, proc_count = 0;
    char *cuname;
    char buf[_POSIX2_LINE_MAX];
    const char *execf, *coref;
    static kvm_t *kd;
    struct kinfo_proc *kp;
    static int nproc;
    static struct kinfo_proc *plist;
    
    execf = NULL;
    coref = _PATH_DEVNULL;
    kd = kvm_openfiles(execf, coref, NULL, O_RDONLY, buf);
    plist = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc);

    for (i = 0, kp = plist; i < nproc; i++, kp++) proc_count++;
    
    printf("\n");
    printf(" \033[0;0;0m         \033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m       \033[0;0;0m\033[38;5;16m00\033[0;0;0m       \n");
    printf("\033[38;5;52m1\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;95m1\033[0;0;0m\033[38;5;52m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;102m1\033[0;0;0m\033[38;5;145m1\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;145m1\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;145m00\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;102m1\033[0;0;0m\033[38;5;102m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;131m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m"); printval("OS", "kern.ostype"); printf(" "); psysctl("hw.machine_arch"); printf("\n");
    printf("\033[38;5;88m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;167m1\033[0;0;0m\033[38;5;210m1\033[0;0;0m\033[38;5;217m0\033[0;0;0m\033[38;5;217m1\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;180m0\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;188m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m000\033[0;0;0m\033[38;5;231m00\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;187m0\033[0;0;0m\033[38;5;144m0\033[0;0;0m\033[38;5;144m1\033[0;0;0m\033[38;5;187m0\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;210m1\033[0;0;0m\033[38;5;167m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m"); printval("Hostname", "kern.hostname");  printf("\n");
    printf("\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;209m0\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m11\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m01\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;230m1\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;173m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;223m1\033[0;0;0m\033[38;5;210m1\033[0;0;0m\033[38;5;167m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;52m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m"); printval("Kernel", "kern.osrelease");  printf("\n");
    printf("\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;230m0\033[0;0;0m\033[38;5;230m0\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;224m11\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;217m0\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;217m0\033[0;0;0m\033[38;5;209m1\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;131m1\033[0;0;0m\033[38;5;52m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m "); printuptime(); printf("\n");
    printf("\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;230m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;230m0\033[0;0;0m\033[38;5;231m1\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;230m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;223m1\033[0;0;0m\033[38;5;223m1\033[0;0;0m\033[38;5;223m0\033[0;0;0m\033[38;5;223m1\033[0;0;0m\033[38;5;217m1\033[0;0;0m\033[38;5;217m1\033[0;0;0m\033[38;5;217m0\033[0;0;0m\033[38;5;217m0\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;173m1\033[0;0;0m\033[38;5;167m0\033[0;0;0m\033[38;5;203m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;131m1\033[0;0;0m\033[38;5;174m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m"); printf("\033[1;31mProcesses:\033[0;0m %d\n", proc_count);
    printf("\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;181m1\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;223m1\033[0;0;0m\033[38;5;223m0\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;230m0\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;230m0\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;223m0\033[0;0;0m\033[38;5;217m1\033[0;0;0m\033[38;5;216m0\033[0;0;0m\033[38;5;209m0\033[0;0;0m\033[38;5;203m0\033[0;0;0m\033[38;5;203m0\033[0;0;0m\033[38;5;202m1\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;131m1\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;138m1\033[0;0;0m\033[38;5;188m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m"); printmem(); printf("\n");
    printf("\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;216m1\033[0;0;0m\033[38;5;216m1\033[0;0;0m\033[38;5;223m0\033[0;0;0m\033[38;5;230m1\033[0;0;0m\033[38;5;231m0\033[0;0;0m\033[38;5;224m0\033[0;0;0m\033[38;5;216m0\033[0;0;0m\033[38;5;209m1\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;196m0\033[0;0;0m\033[38;5;196m1\033[0;0;0m\033[38;5;196m1\033[0;0;0m\033[38;5;196m0\033[0;0;0m\033[38;5;196m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;95m1\033[0;0;0m\033[38;5;95m1\033[0;0;0m\033[38;5;138m0\033[0;0;0m\033[38;5;188m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m"); printcpu();  printf("\n");
    printf("\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;174m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;209m0\033[0;0;0m\033[38;5;215m1\033[0;0;0m\033[38;5;216m1\033[0;0;0m\033[38;5;216m1\033[0;0;0m\033[38;5;209m0\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m11\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;52m1\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;130m0\033[0;0;0m\033[38;5;188m0\033[0;0;0m\033[38;5;102m1\033[0;0;0m "); printf("\033[1;31mShell:\033[0;0m ", proc_count); printshell(); printf("\n");
    printf("\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;188m1\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m111\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;130m1\033[0;0;0m\033[38;5;230m1\033[0;0;0m\033[38;5;138m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m       \n");
    printf("\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;224m1\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1001\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;216m1\033[0;0;0m\033[38;5;230m1\033[0;0;0m\033[38;5;102m1\033[0;0;0m       \n");
    printf("\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m00\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;173m0\033[0;0;0m\033[38;5;222m1\033[0;0;0m\033[38;5;229m1\033[0;0;0m\033[38;5;188m1\033[0;0;0m\033[38;5;16m0\033[0;0;0m        \n");
    printf(" \033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;145m1\033[0;0;0m\033[38;5;174m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;167m1\033[0;0;0m\033[38;5;215m1\033[0;0;0m\033[38;5;223m1\033[0;0;0m\033[38;5;188m0\033[0;0;0m\033[38;5;59m1\033[0;0;0m         \n");
    printf("  \033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;102m0\033[0;0;0m\033[38;5;181m0\033[0;0;0m\033[38;5;88m0\033[0;0;0m\033[38;5;88m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;173m0\033[0;0;0m\033[38;5;217m0\033[0;0;0m\033[38;5;145m1\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m           \n");
    printf("   \033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;145m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;124m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;202m1\033[0;0;0m\033[38;5;202m1\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;209m1\033[0;0;0m\033[38;5;216m1\033[0;0;0m\033[38;5;180m1\033[0;0;0m\033[38;5;59m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m              \n");
    printf("     \033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;95m1\033[0;0;0m\033[38;5;131m1\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;124m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;202m1\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;202m1\033[0;0;0m\033[38;5;208m0\033[0;0;0m\033[38;5;209m1\033[0;0;0m\033[38;5;180m1\033[0;0;0m\033[38;5;137m1\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\n");
    printf("       \033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;16m1\033[0;0;0m\033[38;5;59m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;131m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m1\033[0;0;0m\033[38;5;160m0\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m1\033[0;0;0m\033[38;5;166m0\033[0;0;0m\033[38;5;202m0\033[0;0;0m\033[38;5;172m1\033[0;0;0m\033[38;5;172m0\033[0;0;0m\033[38;5;173m1\033[0;0;0m\033[38;5;137m0\033[0;0;0m\033[38;5;95m0\033[0;0;0m\033[38;5;58m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\n");
    printf("            \033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;52m1\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;52m1\033[0;0;0m\033[38;5;58m1\033[0;0;0m\033[38;5;58m0\033[0;0;0m\033[38;5;58m0\033[0;0;0m\033[38;5;58m0\033[0;0;0m\033[38;5;58m0\033[0;0;0m\033[38;5;58m0\033[0;0;0m\033[38;5;52m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\033[38;5;16m0\033[0;0;0m\n");
    printf("\n");
    return (0);
}
示例#11
0
int argout(int dtype, int dval, int optype)
{
  char *s;

  if (dtype&AGT_VAR) dtype=AGT_VAR;

  if ((optype&3)==1) /* variable */
    dtype=AGT_VAR;
  if (optype&2) {/* NOUN or OBJECT */
    if (dtype>=64 && dtype!=AGT_NUM) 
      dbgprintf("ILL:");
    if (optype==2)
      print_special_obj(0); /* NOUN */
    else 
      print_special_obj(1);  /* OBJECT */
    return 0;
  }

  if (!interp_arg) 
    dbgprintf("%d",dval);
  else {
    if (dtype<64) {
      if (dval==-1) 
	print_special_obj(2); /* NAME */
      else {
	s=getname(dval);
	if (dtype&(AGT_ITEM|AGT_CREAT|AGT_SELF|AGT_WORN)) 
	  dbgprintf("<%d:%s>",dval,s);
	else 
	  dbgprintf("{%d:%s}",dval,s);
	rfree(s);	
      }
    } else if ( (dtype&AGT_VAR)!=0) {
      if (dval==-1) 
	print_tos();
      else
	printval("Var",dval,dbgvarptr);
    } else switch(dtype) 
      {
      case AGT_TIME:
	dbgprintf("%2d:%2d",dval/100,dval%100);break;
      case AGT_NUM:  /* Numeric */
        dbgprintf("%d",dval);break;
      case AGT_FLAG:  /* Flag */
	printval("Flg",dval,dbgflagptr);break;
      case AGT_ROOMFLAG: /* Roomflag */
        dbgprintf("RoomFlag%d",dval);break;
      case AGT_QUEST:  /* Question */
	if (dval<=MaxQuestion && dval>=1 && question!=NULL) {
	  dbgprintf("\nQ%d:%s\n",dval,question[dval-1]);
	  dbgprintf("[A:%s]",answer[dval-1]);      
	} else if (quest_ptr!=NULL) {
	  dbgprintf("\nQ%d: ",dval);
	  print_msg(quest_ptr[dval-1]);
	  dbgprintf("[A:");
	  print_msg(ans_ptr[dval-1]);
	}
	break;
      case AGT_MSG: /* Message */
	if (dval>last_message || dval<1 || msg_ptr==NULL) 
	  dbgprintf("ILLEGAL MESSAGE");
	else {
	  dbgprintf("(Msg%d)",dval);
	  if (!dbg_nomsg)
	    print_msg(msg_ptr[dval-1]);
	}
	break;
      case AGT_ERR: /* Message */
	if (dval>NUM_ERR || dval<1 || err_ptr==NULL) 
	  dbgprintf("ILLEGAL MESSAGE");
	else {
	  dbgprintf("(Std%d)",dval);
	  if (!dbg_nomsg) 
	    print_msg(err_ptr[dval-1]);
	}
	break;
      case AGT_STR: /* String */
	if (dval-1>=MAX_USTR || userstr==NULL) 
	  dbgprintf("ILLEGAL STRING");
	else 
	  dbgprintf("\nStr%d:%s",dval,userstr[dval]);
	break;
      case AGT_CNT: /* Counter */
	printval("Cnt",dval,dbgcntptr);break;
      case AGT_DIR: /* Direction */
	if (dval>=1 && dval<=13) 
	  dbgprintf("%s",exitname[dval-1]);
	else dbgprintf("ILL_DIR(%d)",dval);
	break;
      case AGT_SUB: /* Subroutine */
	dbgprintf("Subroutine %d",dval);break;
      case AGT_PIC: /* Picture */
      case AGT_PIX:
	dbgprintf("Picture #%d",dval);break;
      case AGT_FONT: /* Font */
	dbgprintf("Font #%d",dval);break;
      case AGT_SONG:  /* Song */
	dbgprintf("Song #%d",dval);break;
      case AGT_OBJFLAG: 
	dbgprintf("ObjFlag%d",dval);break;
      case AGT_OBJPROP: 
	dbgprintf("ObjProp%d",dval);break;
      case AGT_ATTR:
	if (dval<0 || dval>=NUM_ATTR) 
	  dbgprintf("UnkownAttr%d",dval);
	else 
	  dbgprintf("%s",attrlist[dval].name);
	break;
      case AGT_PROP:
	if (dval<0 || dval>=NUM_PROP)
	  dbgprintf("UnknownProp%d",dval);
	else 
	  dbgprintf("%s",proplist[dval].name);
	break;
      case AGT_EXIT:
	if (dval>=exitmsg_base) 
	  argout(AGT_MSG,dval-exitmsg_base,0);
	else 
	  argout(AGT_ROOM,dval,0);
	break;
      default:
	dbgprintf("?+%d",dval);
      }
  }
  return 1;
}
int main(void) {
  static char buf[16];
  static long size = -1;
  static unsigned char *loadbuf = NULL;
  static char *entry_point;
  void (*f)(void);
  extern int buffer_start; // バッファ領域を指すシンボル。リンカスクリプトで定義されている。

  INTR_DISABLE;
  
  init();
  puts("kzload (kozos boot loader) started.\n");

  while (1) {
    puts("kzload> ");
    gets(buf); // シリアルからのコマンド受信。

    if (!strcmp(buf, "load")) { // XMODEMでのダウンロード
      loadbuf = (char *)(&buffer_start);
      size = xmodem_recv(loadbuf);
      wait();
      if (size < 0) {
        puts("\nXMODEM receive error!\n");
      } else {
        puts("\nXMODEM receive succeeded.\n");
      }
    } else if (!strcmp(buf, "dump")) { // メモリの16進ダンプ
      puts("size: ");
      putxval(size, 0);
      puts("\n");
      dump(loadbuf, size);
    } else if (!strcmp(buf, "run")) { // ELF形式ファイルの実行
      entry_point = elf_load(loadbuf); // メモリ上に展開
      if (!entry_point) {
        puts("run error!\n");
      } else {
        puts("starting from entry point: ");
        putxval((unsigned long)entry_point, 0);
        puts("\n");
        f = (void (*)(void))entry_point;
        f(); // ロードしたプログラムに処理を渡す
        // ここには基本的に到達しない
      }
    } else {
      puts("unknown.\n");
    }
  }
  
  printval();
  puts("overwrite variables.\n");
  global_data = 0x20;
  global_bss = 0x30;
  static_data = 0x40;
  static_bss = 0x50;
  printval();
  
  while(1)
    ;
  
  return 0;
}
示例#13
0
void * adminchild(struct clientparam* param) {
 int i, res;
 char * buf;
 char username[256];
 char *sb;
 char *req = NULL;
 struct printparam pp;
 int contentlen = 0;
 int isform = 0;

 pp.inbuf = 0;
 pp.cp = param;

 buf = myalloc(LINESIZE);
 if(!buf) {RETURN(555);}
 i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '\n', conf.timeouts[STRING_S]);
 if(i<5 || ((buf[0]!='G' || buf[1]!='E' || buf[2]!='T' || buf[3]!=' ' || buf[4]!='/') && 
	   (buf[0]!='P' || buf[1]!='O' || buf[2]!='S' || buf[3]!='T' || buf[4]!=' ' || buf[5]!='/')))
 {
	RETURN(701);
 }
 buf[i] = 0;
 sb = strchr(buf+5, ' ');
 if(!sb){
	RETURN(702);
 }
 *sb = 0;
 req = mystrdup(buf + ((*buf == 'P')? 6 : 5));
 while((i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
	buf[i] = 0;
	if(i > 19 && (!strncasecmp(buf, "authorization", 13))){
		sb = strchr(buf, ':');
		if(!sb)continue;
		++sb;
		while(isspace(*sb))sb++;
		if(!*sb || strncasecmp(sb, "basic", 5)){
			continue;
		}
		sb+=5;
		while(isspace(*sb))sb++;
		i = de64((unsigned char *)sb, (unsigned char *)username, 255);
		if(i<=0)continue;
		username[i] = 0;
		sb = strchr((char *)username, ':');
		if(sb){
			*sb = 0;
			if(param->password)myfree(param->password);
			param->password = (unsigned char *)mystrdup(sb+1);
		}
		if(param->username) myfree(param->username);
		param->username = (unsigned char *)mystrdup(username);
		continue;
	}
	else if(i > 15 && (!strncasecmp(buf, "content-length:", 15))){
		sb = buf + 15;
		while(isspace(*sb))sb++;
		contentlen = atoi(sb);
	}
	else if(i > 13 && (!strncasecmp(buf, "content-type:", 13))){
		sb = buf + 13;
		while(isspace(*sb))sb++;
		if(!strncasecmp(sb, "x-www-form-urlencoded", 21)) isform = 1;
	}
 }
 param->operation = ADMIN;
 if(isform && contentlen) {
	printstr(&pp, "HTTP/1.0 100 Continue\r\n\r\n");
	stdpr(&pp, NULL, 0);
 }
 res = (*param->srv->authfunc)(param);
 if(res && res != 10) {
	printstr(&pp, authreq);
	RETURN(res);
 }
 if(param->srv->singlepacket || param->redirected){
	if(*req == 'C') req[1] = 0;
	else *req = 0;
 }
 sprintf(buf, ok, conf.stringtable?(char *)conf.stringtable[2]:"3proxy", conf.stringtable?(char *)conf.stringtable[2]:"3[APA3A] tiny proxy", conf.stringtable?(char *)conf.stringtable[3]:"");
 if(*req != 'S') printstr(&pp, buf);
 switch(*req){
	case 'C':
		printstr(&pp, counters);
		{
			struct trafcount *cp; 
			int num = 0;
			for(cp = conf.trafcounter; cp; cp = cp->next, num++){
			 int inbuf = 0;

			 if(cp->ace && (param->srv->singlepacket || param->redirected)){
				if(!ACLmatches(cp->ace, param))continue;
			 }
			 if(req[1] == 'S' && atoi(req+2) == num) cp->disabled=0;
			 if(req[1] == 'D' && atoi(req+2) == num) cp->disabled=1;
			 inbuf += sprintf(buf,	"<tr>"
						"<td>%s</td><td><A HREF=\'/C%c%d\'>%s</A></td><td>",
						(cp->comment)?cp->comment:"&nbsp;",
						(cp->disabled)?'S':'D',
						num,
						(cp->disabled)?"NO":"YES"
					);
			 if(!cp->ace || !cp->ace->users){
				inbuf += sprintf(buf+inbuf, "<center>ANY</center>");
			 }
			 else {
				inbuf += printuserlist(buf+inbuf, LINESIZE-800, cp->ace->users, ",<br />\r\n");
			 }
			 inbuf += sprintf(buf+inbuf, "</td><td>");
			 if(!cp->ace || !cp->ace->src){
				inbuf += sprintf(buf+inbuf, "<center>ANY</center>");
			 }
			 else {
				inbuf += printiplist(buf+inbuf, LINESIZE-512, cp->ace->src, ",<br />\r\n");
			 }
			 inbuf += sprintf(buf+inbuf, "</td><td>");
			 if(!cp->ace || !cp->ace->dst){
				inbuf += sprintf(buf+inbuf, "<center>ANY</center>");
			 }
			 else {
				inbuf += printiplist(buf+inbuf, LINESIZE-512, cp->ace->dst, ",<br />\r\n");
			 }
			 inbuf += sprintf(buf+inbuf, "</td><td>");
			 if(!cp->ace || !cp->ace->ports){
				inbuf += sprintf(buf+inbuf, "<center>ANY</center>");
			 }
			 else {
				inbuf += printportlist(buf+inbuf, LINESIZE-128, cp->ace->ports, ",<br />\r\n");
			 }
			 if(cp->type == NONE) {
			  inbuf += sprintf(buf+inbuf,	
					"</td><td colspan=\'6\' align=\'center\'>exclude from limitation</td></tr>\r\n"
				 );
			 }
			 else {
			  inbuf += sprintf(buf+inbuf,	
					"</td><td>%.3f</td>"
					"<td>MB%s</td>"
					"<td>%.3f MB</td>"
					"<td>%s</td>",
				 (1024.0 * (float)cp->traflimgb) + (float)cp->traflim/1048576.0,
				 rotations[cp->type],
				 (1024.0 * (float)cp->trafgb) + (float)cp->traf/1048576.0,
				 cp->cleared?ctime(&cp->cleared):"never"
				);
			 inbuf += sprintf(buf + inbuf,
					"<td>%s</td>"
					"<td>%i</td>"
					"</tr>\r\n",

				 cp->updated?ctime(&cp->updated):"never",
				 cp->number
				);
			 }
			 printstr(&pp, buf);
			}

		}
		printstr(&pp, counterstail);
		break;
		
	case 'R':
		conf.needreload = 1;
		printstr(&pp, "<h3>Reload scheduled</h3>");
		break;
	case 'S':
		{
			if(req[1] == 'X'){
				printstr(&pp, style);
				break;
			}
			printstr(&pp, xml);
			printval(conf.services, TYPE_SERVER, 0, &pp);
			printstr(&pp, postxml);
		}
			break;
	case 'F':
		{
			FILE *fp;
			char buf[256];

			fp = confopen();
			if(!fp){
				printstr(&pp, "<h3><font color=\"red\">Failed to open config file</font></h3>");
				break;
			}
				printstr(&pp, "<h3>Please be careful editing config file remotely</h3>");
				printstr(&pp, "<form method=\"POST\" action=\"/U\"><textarea cols=\"80\" rows=\"30\" name=\"conffile\">");
				while(fgets(buf, 256, fp)){
					printstr(&pp, buf);
				}
				if(!writable) fclose(fp);
				printstr(&pp, "</textarea><br><input type=\"Submit\"></form>");
			break;
		}
	case 'U':
		{
			int l=0;
			int error = 0;

			if(!writable || fseek(writable, 0, 0)){
				error = 1;
			}
			while((i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '+', conf.timeouts[STRING_S])) > 0){
				if(i > (contentlen - l)) i = (contentlen - l);
				buf[i] = 0;
				if(!l){
					if(strncasecmp(buf, "conffile=", 9)) error = 1;
				}
				if(!error){
					decodeurl((unsigned char *)buf, 1);
					fprintf(writable, "%s", l? buf : buf + 9);
				}
				l += i;
				if(l >= contentlen) break;
			}
			if(writable && !error){
				fflush(writable);
#ifndef _WINCE
				ftruncate(fileno(writable), ftell(writable));
#endif
			}
			printstr(&pp, error?    "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":
						"<h3>Configuration updated</h3>");

		}
		break;
	default:
		printstr(&pp, (char *)conf.stringtable[WEBBANNERS]);
		break;
 }
 if(*req != 'S') printstr(&pp, tail);

CLEANRET:


 printstr(&pp, NULL);
 if(buf) myfree(buf);
 (*param->srv->logfunc)(param, (unsigned char *)req);
 if(req)myfree(req);
 freeparam(param);
 return (NULL);
}
示例#14
0
文件: sur243.c 项目: mildred/Varkon
   DBstatus  varkon_poi_nurbs   (

/*-------------- Argument declarations -----------------------------*/
/*                                                                  */
/* In:                                                              */
   GMPATNU *p_patnu,     /* NURBS patch                       (ptr) */
   DBint    rwcase,      /* Read/write case:                        */
                         /* Eq. 0: Read  node                       */
                         /* Eq. 1: Write node                       */
                         /* Eq. 2: Initialize values                */
                         /* Eq. 3: Printout of polygon points       */
                         /* Eq. 4: Check NURBS data                 */
   DBint    i_up,        /* Point address in U direction            */
   DBint    i_vp,        /* Point address in V direction            */
   DBHvector  *p_pp )    /* Polygon point                     (ptr) */
/* Out:                                                             */
/*       Data to or from p_pp                                       */
/*-----------------------------------------------------------------!*/

{ /* Start of function */

/*!--------------- Internal variables ------------------------------*/
/*                                                                  */
   DBint  order_u;       /* Order  for surface in U direction       */
   DBint  order_v;       /* Order  for surface in V direction       */
   DBint  deg_u;         /* Degree for surface in U direction       */
   DBint  deg_v;         /* Degree for surface in V direction       */
   DBint  nk_u;          /* Number of nodes    in U direction       */
   DBint  nk_v;          /* Number of nodes    in V direction       */
   DBint  m_u;           /* Maximum node index value in U direction */
   DBint  m_v;           /* Maximum node index value in V direction */
   DBint  c_iuv;         /* Index to node in memory area            */
/*                                                                  */
/*-----------------------------------------------------------------!*/

   DBHvector *p_pp_l;    /* Polygon point                     (ptr) */
   char   errbuf[80];    /* String for error message fctn erpush    */
   short  status;        /* Error code from a called function       */

/*--------------end-of-declarations---------------------------------*/

/*!                                                                 */
/* Algorithm                                                        */
/* =========                                                        */
/*                                                                 !*/

#ifdef DEBUG
if ( dbglev(SURPAC) == 2 )
{
fprintf(dbgfil(SURPAC),
"sur243 Enter**varkon_poi_nurbs p_patnu %d rwcase %d\n",
                (int)p_patnu,(int)rwcase);
  fflush(dbgfil(SURPAC)); /* To file from buffer      */
}
#endif

/*!                                                                 */
/* 1. Check of input data and initializations for Debug On          */
/* ________________________________________________________         */
/*                                                                  */
/*  Initialize output coordinates and derivatives and internal      */
/*  variables for DEBUG on.                                         */
/*  Call of initial.                                                */
/*                                                                 !*/

#ifdef DEBUG
   status=initial(p_patnu, rwcase, i_up, i_vp, p_pp ); 
   if (status<0) 
   {
   sprintf(errbuf,"initial%%sur243");
   return(varkon_erpush("SU2973",errbuf));
   }
#endif

/*!                                                                 */
/* 2. Initialize values in memory area for rwcase= 2                */
/* _________________________________________________                */
/*                                                                  */
/*  Initialization of values is made in internal function setvalue. */
/*                                                                 !*/

   if ( rwcase == 2 ) 
     {
     status= setvalue (p_patnu); 
     if (status<0) 
       {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "sur243 setvalue failed\n" );
fflush(dbgfil(SURPAC));
}
#endif
      sprintf(errbuf,"setvalue%%sur243");
      return(varkon_erpush("SU2973",errbuf));
      }
     return(SUCCED);
     }

/*!                                                                 */
/* 3. Printout of nodes for rwcase = 3                              */
/* ____________________________________                             */
/*                                                                  */
/*  Printout of values is made in internal function printval.       */
/*                                                                 !*/

   if ( rwcase == 3 ) 
     {
     status= printval (p_patnu); 
     if (status<0) 
       {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "sur243 printval failed\n" );
fflush(dbgfil(SURPAC));
}
#endif
      sprintf(errbuf,"printval%%sur243");
      return(varkon_erpush("SU2973",errbuf));
      }
     return(SUCCED);
     }


/*!                                                                 */
/* 4. Calculate address to node point in memory area.               */
/* __________________________________________________               */
/*                                                                  */
/*                                                                 !*/

/*!                                                                 */
/* Get number of knot values                                        */
/*                                                                 !*/

    nk_u    = p_patnu->nk_u;
    nk_v    = p_patnu->nk_v;

/*!                                                                 */
/* Get the order (degree) of the basis functions.                   */
/*                                                                 !*/

    order_u = p_patnu->order_u;
    order_v = p_patnu->order_v;
    deg_u   = order_u - 1;
    deg_v   = order_v - 1;

/*!                                                                 */
/* Calculate the number of nodes                                    */
/*                                                                 !*/

    m_u     = nk_u - 1 - deg_u - 1;
    m_v     = nk_v - 1 - deg_v - 1;


/*!                                                                 */
/* Calculate the index c_iuv to the node in memory area             */
/*                                                                 !*/

   c_iuv = i_up*(m_v+1) + i_vp;

/*!                                                                 */
/* Read or write node                                               */
/*                                                                 !*/

    p_pp_l = p_patnu->cpts + c_iuv;

    if  ( rwcase == 0 )
      {
      p_pp->x_gm   = p_pp_l->x_gm;
      p_pp->y_gm   = p_pp_l->y_gm;
      p_pp->z_gm   = p_pp_l->z_gm;
      p_pp->w_gm   = p_pp_l->w_gm;
      }
    else if  ( rwcase == 1 )
      {
      p_pp_l->x_gm = p_pp->x_gm;
      p_pp_l->y_gm = p_pp->y_gm;
      p_pp_l->z_gm = p_pp->z_gm;
      p_pp_l->w_gm = p_pp->w_gm;
      }

#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC),
"sur243 Exit rwcase %d i_up %d i_vp %d c_iuv %d\n",
         (int)rwcase , (int)i_up  , (int)i_vp  , (int)c_iuv );
  fflush(dbgfil(SURPAC));
}
#endif

  return(SUCCED);

} /* End of function                                                */