Beispiel #1
0
unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
{
    if (!IsPayToScriptHash())
        return GetSigOpCount(true);

    // This is a pay-to-script-hash scriptPubKey;
    // get the last item that the scriptSig
    // pushes onto the stack:
    const_iterator pc = scriptSig.begin();
    std::vector<unsigned char> vData;
    while (pc < scriptSig.end())
    {
        opcodetype opcode;
        if (!scriptSig.GetOp(pc, opcode, vData))
            return 0;
        if (opcode > OP_16)
            return 0;
    }

    /// ... and return its opcount:
    CScript subscript(vData.begin(), vData.end());
    return subscript.GetSigOpCount(true);
}
// consoleCallback handles the processing of locally-defined commands
const char *SimDynamicDataPlugin::consoleCallback(CMDConsole *, 
                                          int         iCmd,
                                          int         argc,
                                          const char *argv[])
{
   char szDup[BUFSIZ];

   switch (iCmd)
   {
      // RegisterDataBlock is used to create a new instance of a 
      // known data block type
      case RegisterDataBlock:
         if (argc == 3)
         {
            if (strlen(argv[1]) >= DATANAME_MAX_LENGTH)
            {
               console->printf("registerDataBlock: name too long");
            }
            else
            {
               int ret = registerDataBlock(argv[1], argv[2]);

               switch (ret)
               {
                  case DATAERROR_NOTIMPL:
                     console->printf("registerDataBlock: not implemented");
                     break;

                  case DATAERROR_NOTFOUND:
                     console->printf("registerDataBlock: data type not found");
                     break;

                  case DATAERROR_UNKNOWN:
                     console->printf("registerDataBlock: unknown error");
                     break;

                  case DATAERROR_EXISTS:
                     console->printf("registerDataBlock: named data block exists");
                     break;
               }
            }
         }
         else
         {
            console->printf("registerDataBlock <name> <type>");
         }
         break;

      // RegisterDataBlock is used to create a new instance of a 
      // known data block type
      case RegisterStaticDataBlock:
         if (argc == 3)
         {
            if (strlen(argv[1]) >= DATANAME_MAX_LENGTH)
            {
               console->printf("registerDataBlock: name too long");
            }
            else
            {
               int ret = registerStaticDataBlock(argv[1], argv[2]);

               switch (ret)
               {
                  case DATAERROR_NOTIMPL:
                     console->printf("registerStaticDataBlock: not implemented");
                     break;

                  case DATAERROR_NOTFOUND:
                     console->printf("registerStaticDataBlock: data type not found");
                     break;

                  case DATAERROR_UNKNOWN:
                     console->printf("registerStaticDataBlock: unknown error");
                     break;

                  case DATAERROR_EXISTS:
                     console->printf("registerStaticDataBlock: named data block exists");
                     break;
               }
            }
         }
         else
         {
            console->printf("registerStaticDataBlock <name> <type>");
         }
         break;

      // EditDataBlock will either bring the requested data block into
      // scope, or create the requested data block if it was not found
      case EditDataBlock :
         if (argc == 3)
         {
            if (strlen(argv[1]) >= DATANAME_MAX_LENGTH)
            {
               console->printf("editDataBlock: name too long");
            }
            else
            {
               vec_data::iterator iter;
               strcpy(szDup, argv[1]);

               if ((iter = findData(strupr(szDup))) != data.end())
               {
                  pDataCurrent = (Data *)(*iter);
               }

               else
               {
                  int ret;

                  ret = registerDataBlock(argv[1], argv[2]);

                  switch (ret)
                  {
                     case DATAERROR_NOTIMPL:
                        console->printf("editDataBlock: not implemented");
                        break;

                     case DATAERROR_NOTFOUND:
                        console->printf("editDataBlock: data type not found");
                        break;

                     case DATAERROR_UNKNOWN:
                        console->printf("editDataBlock: unknown error");
                        break;
                  }
               }
            }
         }
         else
         {
            console->printf("editDataBlock <name> <type>");
         }
         break;

      // SetData is used to set the values of elements within an in-scope
      // data block
      case SetData:
      {
         Element            *element;
         vec_elem::iterator  iter;
         int                 iRow = 0, iCol = 0, ret;

         if (argc > 2)
         {
            if (pDataCurrent == NULL)
            {
               ret = DATAERROR_NOCURRENT;
            }

            else
            {
               // See if this is a subscripted element
               ret = subscript(argv[1], iRow, iCol);

               if (ret == DATAERROR_NOERROR)
               {
                  strcpy(szDup, argv[1]);
                  if ((iter  = pDataCurrent->findElem(strupr(szDup))) 
                            != pDataCurrent->elements.end())
                  {
                     element = (Element *)(*iter);

                     ret = verifySubscripts(element, argc - 2, iRow, iCol);

                     if (ret == DATAERROR_NOERROR)
                     {
                        ret = setData(element, &argv[2], argc - 2, iRow, iCol);
                     }
                  }
                  else
                  {
                     ret = DATAERROR_NOTFOUND;
                  }
               }
            }

            switch (ret)
            {
               case DATAERROR_NOCURRENT:
                  console->printf("setData: no current record");
                  break;

               case DATAERROR_NOTFOUND:
                  console->printf("setData: data field: %s not found", argv[1]);
                  break;

               case DATAERROR_INDEXOOB:
                  console->printf("setData: index out of bounds");
                  break;

               case DATAERROR_NOSUBSCRIPT:
                  console->printf("setData: cannot access multidimensional array without subscript");
                  break;

               case DATAERROR_SYNTAX:
                  console->printf("setData: syntax error (badly formed)");
                  break;
            }
         }
         else
         {
            console->printf("setData <name> <value>");
         }
      }
      break;
   }

   return 0;
}
Beispiel #3
0
   #define HTML_ICON(a) QIcon(a)
 #endif
#endif

struct html_editor::action_type
html_editor::m_action_definitions[] = {
#define QN QT_TR_NOOP
#define NA QWebPage::NoWebAction

  // {name, shortcut, icon, WebAction
  {QN("Bold"), QN("Ctrl+B"), "icon-bold.png", SLOT(bold()), NA }
  ,{QN("Italic"), QN("Ctrl+I"), "icon-italic.png", SLOT(italic()), NA }
  ,{QN("Underline"), QN("Ctrl+U"), "icon-underline.png", SLOT(underline()), NA }
  ,{QN("Strike through"), QN("Ctrl+S"), "icon-strikethrough.png", SLOT(strikethrough()) , NA}
  ,{QN("Superscript"), NULL, "icon-superscript.png", SLOT(superscript()), NA }
  ,{QN("Subscript"), NULL, "icon-subscript.png", SLOT(subscript()), NA }

  // separator before 6
  ,{QN("Set foreground color"), NULL, "icon-foreground-color.png", SLOT(foreground_color()), NA }
  ,{QN("Set background color"), NULL, "icon-background-color.png", SLOT(background_color()), NA }
  ,{QN("Insert image"), NULL, "icon-image.png", SLOT(insert_image()), NA }
  ,{QN("Insert link"), NULL, "icon-link.png", SLOT(insert_link()), NA }
  ,{QN("Insert horizontal rule"), NULL, "icon-hr.png", SLOT(insert_hr()), NA }
  ,{QN("Insert unordered list"), NULL, "icon-bullet-list.png", SLOT(insert_unordered_list()), NA }
  ,{QN("Insert ordered list"), NULL, "icon-ordered-list.png", SLOT(insert_ordered_list()), NA }
  ,{QN("Remove format"), NULL, "icon-eraser.png", SLOT(remove_format()), NA }
  ,{QN("Cut"), NULL, "icon-cut.png", NULL, QWebPage::Cut }
  ,{QN("Copy"), NULL, "icon-copy.png", NULL, QWebPage::Copy }
  ,{QN("Paste"), NULL, "icon-paste.png", NULL, QWebPage::Paste }
  ,{QN("Undo"), QN("Ctrl+Z"), "icon-undo.png", NULL, QWebPage::Undo }
  ,{QN("Redo"), NULL, "icon-redo.png", NULL, QWebPage::Redo }