$tag = new Swagger\Client\Model\Tag();
        $tag->setId($new_pet_id);
        // use the same id as pet
        $tag->setName("profile tag 1");
        // new category
        $category = new Swagger\Client\Model\Category();
        $category->setId($new_pet_id);
        // use the same id as pet
        $category->setName("profile category 1");
        $new_pet->setTags(array($tag));
        $new_pet->setCategory($category);
        // add a new pet (model)
        $add_response = $pet_api->addPet($new_pet);
        // ~~~ GET PET ~~~
        prof_flag("{$x}: GET PET");
        $response = $pet_api->getPetById($new_pet_id);
        // ~~~ UPDATE PET WITH FORM ~~~
        prof_flag("{$x}: UPDATE PET");
        $response = $pet_api->updatePetWithForm($new_pet_id, "new profiler", "sold");
        // ~~~ DELETE PET ~~~
        prof_flag("{$x}: DELETE PET");
        $response = $pet_api->deletePet($new_pet_id);
    } catch (Swagger\Client\ApiException $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
        echo 'HTTP response headers: ', print_r($e->getResponseHeaders(), true), "\n";
        echo 'HTTP response body: ', print_r($e->getResponseBody(), true), "\n";
        echo 'HTTP status code: ', $e->getCode(), "\n";
    }
}
prof_flag("{$x}: FINISH");
prof_print();
Esempio n. 2
0
 private static function decode_woba($p, &$woba, $bmap_offset, $woba_length, &$bounds)
 {
     prof_flag("WOBA block decode");
     /* WOBA initalization */
     $woba_offset = 0;
     /* offset into the WOBA-encoded data for either picture or mask;
     	  allows us to halt at the end (woba_length) */
     /* left & top: */
     $bx8 = $bounds['left'] & ~0x1f;
     /* round bounding left down to x32 */
     /* width & height: */
     /* round bounding right up to x32;
     		 subtract bounding left -> width */
     $rowwidth8 = ($bounds['right'] & 0x1f ? ($bounds['right'] | 0x1f) + 1 : $bounds['right']) - ($bounds['left'] & ~0x1f);
     $rowwidth = $rowwidth8 / 8;
     /* row-width (bytes) -> row-width (bits) */
     /* woba state initalization: */
     $repeat = 1;
     /* part of the WOBA format allows for the repetition of previous operations;
     		 this is the number of times the next operation should repeat */
     $dx = 0;
     /* dx & dy are part of the WOBA codec */
     $dy = 0;
     $patternbuffer = array(0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa);
     $buffer1 = array_fill(0, $rowwidth, 0);
     /* buffer rows sufficient to hold one row of pixel bitmap data */
     $buffer2 = array_fill(0, $rowwidth, 0);
     $x = 0;
     /* horizontal offset into temporary row decoding buffer, ie. buffer1 */
     $y = $bounds['top'];
     /* vertical offset into output picture buffer */
     /* WOBA decode */
     /* working data:  */
     $operandata = array_fill(0, 256, 0);
     /* continue until end of this WOBA image data */
     $step = 0;
     while ($woba_offset < $woba_length) {
         //if ($step ==11) return;
         /* get next 'opcode' */
         //print '<strong>STEP '.$step.'</strong><br>';
         //$step++;
         $opcode = $woba[$bmap_offset];
         $bmap_offset++;
         $woba_offset++;
         //print 'Y offset = '.($y * $rowwidth).'<br>';
         //print 'OP: '.strtoupper(str_pad(dechex($opcode), 2, ' ', STR_PAD_LEFT)).
         //	'  @ '.$bmap_offset. ' ';
         /* partial row decode - horizontal accumulation in temporary buffer: */
         if (($opcode & 0x80) == 0) {
             /* zeros followed by data */
             prof_flag('WOBA: Zeros + Data');
             //print 'Zeros + Data<br>';
             $nd = $opcode >> 4;
             $nz = $opcode & 15;
             //print ' nd = '.$nd.'  nz = '.$nz.'<br>';
             if ($nd) {
                 array_splice($operandata, 0, $nd, array_slice($woba, $bmap_offset, $nd));
                 //WOBA::_memcpy($operandata, 0, $woba, $bmap_offset, $nd); /* @bmap_offset:nd;
                 //										   				ie. inline data with instruction */
                 $bmap_offset += $nd;
                 $woba_offset += $nd;
             }
             while ($repeat) {
                 for ($k = $nz; $k > 0; $k--) {
                     $buffer1[$x] = 0;
                     $x++;
                 }
                 array_splice($buffer1, $x, $nd, array_slice($operandata, 0, $nd));
                 //WOBA::_memcpy($buffer1, $x, $operandata, 0, $nd); /* @x:nd,
                 //									             ie. zeros followed by data */
                 $x += $nd;
                 $repeat--;
             }
             $repeat = 1;
             prof_flag('End');
         } else {
             if (($opcode & 0xe0) == 0xc0) {
                 /* opcode & 1F * 8 bytes of data */
                 prof_flag('WOBA: x8 Data');
                 $nd = ($opcode & 0x1f) * 8;
                 //print $nd.' (x8) of Data<br>';
                 if ($nd) {
                     array_splice($operandata, 0, $nd, array_slice($woba, $bmap_offset, $nd));
                     //WOBA::_memcpy($operandata, 0, $woba, $bmap_offset, $nd); /* inline data */
                     $bmap_offset += $nd;
                     $woba_offset += $nd;
                 }
                 while ($repeat) {
                     array_splice($buffer1, $x, $nd, array_slice($operandata, 0, $nd));
                     //WOBA::_memcpy($buffer1, $x, $operandata, 0, $nd);
                     $x += $nd;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
             } else {
                 if (($opcode & 0xe0) == 0xe0) {
                     /* opcode & 1F * 16 bytes of zero */
                     prof_flag('WOBA: x16 Zeros');
                     $nz = ($opcode & 0x1f) * 16;
                     //print $nz.' (x16) of Zero<br>';
                     while ($repeat) {
                         for ($k = $nz; $k > 0; $k--) {
                             $buffer1[$x] = 0;
                             $x++;
                         }
                         $repeat--;
                     }
                     $repeat = 1;
                     prof_flag('End');
                 }
             }
         }
         if (($opcode & 0xe0) == 0xa0) {
             /* repeat opcode */
             prof_flag('WOBA: Repeat');
             $repeat = $opcode & 0x1f;
             //print 'Repeat '.$repeat.'<br>';
             prof_flag('End');
             continue;
         }
         switch ($opcode) {
             case 0x80:
                 /* uncompressed data */
                 prof_flag('WOBA: Uncompressed');
                 //print 'Uncompressed<br>';
                 $x = 0;
                 while ($repeat) {
                     $p->memcopyin($woba, $bmap_offset, $bx8, $y, $rowwidth);
                     $y++;
                     $flag = false;
                     $repeat--;
                 }
                 $repeat = 1;
                 $bmap_offset += $rowwidth;
                 $woba_offset += $rowwidth;
                 prof_flag('End');
                 break;
             case 0x81:
                 /* white row */
                 prof_flag('WOBA: White');
                 //print 'White Row<br>';
                 $x = 0;
                 while ($repeat) {
                     $p->memfill(0, $bx8, $y, $rowwidth);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x82:
                 /* black row */
                 prof_flag('WOBA: Black');
                 //print 'Black Row<br>';
                 $x = 0;
                 while ($repeat) {
                     $p->memfill(0xff, $bx8, $y, $rowwidth);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x83:
                 /* pattern */
                 prof_flag('WOBA: Pattern');
                 //print 'Pattern<br>';
                 $operand = $woba[$bmap_offset];
                 $bmap_offset++;
                 $woba_offset++;
                 $x = 0;
                 while ($repeat) {
                     $patternbuffer[$y & 7] = $operand;
                     $p->memfill($operand, $bx8, $y, $rowwidth);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x84:
                 /* last pattern */
                 prof_flag('WOBA: Last Pattern');
                 //print 'Last Pattern<br>';
                 $x = 0;
                 while ($repeat) {
                     $operand = $patternbuffer[$y & 7];
                     $p->memfill($operand, $bx8, $y, $rowwidth);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x85:
                 /* previous row */
                 prof_flag('WOBA: Previous Row');
                 //print 'Previous Row<br>';
                 $x = 0;
                 while ($repeat) {
                     $p->copyrow($y, $y - 1);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x86:
                 /* two rows back */
                 prof_flag('WOBA: Previous -2 Row');
                 //print 'Two Rows Back<br>';
                 $x = 0;
                 while ($repeat) {
                     $p->copyrow($y, $y - 2);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x87:
                 /* three rows back */
                 prof_flag('WOBA: Previous -3 Row');
                 //print 'Three Rows Back<br>';
                 $x = 0;
                 while ($repeat) {
                     $p->copyrow($y, $y - 3);
                     $y++;
                     $repeat--;
                 }
                 $repeat = 1;
                 prof_flag('End');
                 break;
             case 0x88:
                 //print 'dx,dy = 16,0<br>';
                 $dx = 16;
                 $dy = 0;
                 break;
             case 0x89:
                 //print 'dx,dy = 0,0<br>';
                 $dx = 0;
                 $dy = 0;
                 break;
             case 0x8a:
                 //print 'dx,dy = 0,1<br>';
                 $dx = 0;
                 $dy = 1;
                 break;
             case 0x8b:
                 //print 'dx,dy = 0,2<br>';
                 $dx = 0;
                 $dy = 2;
                 break;
             case 0x8c:
                 //print 'dx,dy = 1,0<br>';
                 $dx = 1;
                 $dy = 0;
                 break;
             case 0x8d:
                 //print 'dx,dy = 1,1<br>';
                 $dx = 1;
                 $dy = 1;
                 break;
             case 0x8e:
                 //print 'dx,dy = 2,2<br>';
                 $dx = 2;
                 $dy = 2;
                 break;
             case 0x8f:
                 //print 'dx,dy = 8,0<br>';
                 $dx = 8;
                 $dy = 0;
                 break;
             default:
                 /* it's not a repeat or a whole row */
                 if ($x >= $rowwidth) {
                     prof_flag('WOBA: Finishing Partial');
                     /* ie. a row has been gradually constructed in buffer1,
                     		 now that row needs to be output to the picture buffer */
                     $x = 0;
                     //print 'Finish partial row<br>';
                     if ($dx) {
                         $buffer2 = array_slice($buffer1, 0, $rowwidth);
                         //array_splice($buffer2, 0, $rowwidth, array_slice($buffer1, 0, $rowwidth));
                         //WOBA::_memcpy($buffer2, 0, $buffer1, 0, $rowwidth); /* make a copy of the completed row */
                         for ($k = $rowwidth8 / $dx; $k > 0; $k--) {
                             WOBA::_shiftnstr($buffer2, $rowwidth, $dx);
                             /* shift copy right by dx bits??? */
                             WOBA::_xornstr($buffer1, $buffer2, $rowwidth);
                             /* temp row 1 XOR temp row 2;
                             	  buffer1 := buffer1 ^ buffer2 for rowwidth bytes */
                         }
                     }
                     if ($dy) {
                         $p->memcopyout($buffer2, $bx8, $y - $dy, $rowwidth);
                         WOBA::_xornstr($buffer1, $buffer2, $rowwidth);
                         /* temp row 1 XOR temp row 2;
                         	  buffer1 := buffer1 ^ buffer2 for rowwidth bytes */
                     }
                     $p->memcopyin($buffer1, 0, $bx8, $y, $rowwidth);
                     $y++;
                     prof_flag('End');
                 }
                 break;
         }
     }
     prof_flag("End");
 }