dav/davql.c

changeset 28
4e46c65711ef
parent 27
e584c351b402
child 30
9a5a7a513a96
equal deleted inserted replaced
27:e584c351b402 28:4e46c65711ef
266 operation->type = DAVQOP_RESPROP; 266 operation->type = DAVQOP_RESPROP;
267 } else if(!sstrcmp(token, S("name"))) { 267 } else if(!sstrcmp(token, S("name"))) {
268 operation->type = DAVQOP_RESPROP; 268 operation->type = DAVQOP_RESPROP;
269 } else if(!sstrcmp(token, S("path"))) { 269 } else if(!sstrcmp(token, S("path"))) {
270 operation->type = DAVQOP_RESPROP; 270 operation->type = DAVQOP_RESPROP;
271 } else if(!sstrcmp(token, S("iscollection"))) {
272 operation->type = DAVQOP_RESPROP;
271 } else { 273 } else {
272 operation->type = DAVQOP_PROPERTY; 274 operation->type = DAVQOP_PROPERTY;
273 } 275 }
274 operation->val = token.ptr; 276 operation->val = token.ptr;
275 operation->intval = token.length; 277 operation->intval = token.length;
446 if(op.intval == 0) { 448 if(op.intval == 0) {
447 // not operator 449 // not operator
448 if(stackpos < 1) { 450 if(stackpos < 1) {
449 // error 451 // error
450 printf("no data on stack\n"); 452 printf("no data on stack\n");
451 return NULL; 453 return 0;
452 } 454 }
453 int pos = stackpos-1; 455 int pos = stackpos-1;
454 if(stack[pos].type == DAVQOP_INTEGER) { 456 if(stack[pos].type == DAVQOP_INTEGER) {
455 printf("not %" PRId64 "\n", stack[pos].intval); 457 printf("not %" PRId64 "\n", stack[pos].intval);
456 stack[pos].intval = !stack[pos].intval; 458 stack[pos].intval = !stack[pos].intval;
457 } else { 459 } else {
458 // error 460 // error
459 printf("wrong value for 'not' operator\n"); 461 printf("wrong value for 'not' operator\n");
460 return NULL; 462 return 0;
461 } 463 }
462 } else { 464 } else {
463 DavQOp val1 = stack[stackpos-2]; 465 DavQOp val1 = stack[stackpos-2];
464 DavQOp val2 = stack[stackpos-1]; 466 DavQOp val2 = stack[stackpos-1];
465 DavQOp result; 467 DavQOp result;
533 value.intval = strlen(res->name); 535 value.intval = strlen(res->name);
534 } else if(!sstrcmp(name, S("path"))) { 536 } else if(!sstrcmp(name, S("path"))) {
535 value.type = DAVQOP_STRING; 537 value.type = DAVQOP_STRING;
536 value.val = res->path; 538 value.val = res->path;
537 value.intval = strlen(res->path); 539 value.intval = strlen(res->path);
540 } else if(!sstrcmp(name, S("iscollection"))) {
541 value.type = DAVQOP_INTEGER;
542 value.val = NULL;
543 value.intval = res->iscollection;
538 } 544 }
539 stack[stackpos++] = value; 545 stack[stackpos++] = value;
540 break; 546 break;
541 } 547 }
542 } 548 }
678 break; 684 break;
679 } 685 }
680 case 13: { 686 case 13: {
681 // xor 687 // xor
682 printf("str compare: %.*s xor %.*s\n", s1.length, s1.ptr, s2.length, s2.ptr); 688 printf("str compare: %.*s xor %.*s\n", s1.length, s1.ptr, s2.length, s2.ptr);
683 res.intval = (int)s1.ptr ^ (int)s2.ptr; 689 res.intval = (intptr_t)s1.ptr ^ (intptr_t)s2.ptr;
684 break; 690 break;
685 } 691 }
686 } 692 }
687 return res; 693 return res;
688 } 694 }

mercurial