Exemplo n.º 1
0
int parserLine(struct shell_state *state, const char *line)
{
	char **argv = NULL;
	int argc = 0;
	struct function *fct = NULL;

	argc = getTokens(line, &argv);
	argc = replaceTokens(argc, &argv, state);

	if((fct = searchFunction(state->cmds, argv[0])) != NULL)
	{
		state->last_ret_value = fct->f(argc, argv);

		for(; argc > 0; argc--)
			free(argv[argc-1]);

		return 0;
	}
	else
	{
		printf("%s : unknown filename or command.\n", argv[0]);
		return -1;	
	}

	return 0;
}
void* searchLinkedList(LinkedList list, int (*searchFunction)(void *, void *), void *params) {
    LinkedElem aux = list->elems;

    while (aux != NULL) {
        if (searchFunction(aux->data, params))
            return aux->data;
        aux = aux->next;
    }

    return NULL;
}
Exemplo n.º 3
0
Object *findByNameInScope(Object * scope, char *name, int bUseFullName)
{

    if (scope == 0 || name == 0) {

        warningMsg("Object or name was null in findByNameInScope. (ObjectTree.c)\n");

        return 0;

    }
    //printf("in findByName, searching %s for %s\n", scope->fullname, name);
    Object *result;

    switch (scope->category) {

    case CodeBlock:
        result = searchCodeBlock(scope, name, bUseFullName);
        break;

    case Function:
        //compilerDebugPrintf("Searching %s in function %s\n",name,scope->name);
        result = searchFunction(scope, name, bUseFullName);
        break;

    case Constructor:
        result = searchConstructor(scope, name, bUseFullName);
        break;

    case Type:
        result = searchType(scope, name, bUseFullName);
        break;

    default:
        warningMsg("cannot search within category %d\n", scope->category);
        break;

    }

    //printf("exiting findByName (%s), found %s\n", scope->fullname, result? result->fullname : "nothing.");
    return result;

}
Exemplo n.º 4
0
Arquivo: doc.cpp Projeto: speakman/qlc
void Doc::createFunctionContents(QList<QString> &list)
{
  Function* function = NULL;
  DMXDevice* device = NULL;

  unsigned long deviceId = 0;
  unsigned long functionId = ULONG_MAX;

  QString name;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Name"))
	{
	  name = *(list.next());
	}		      
      else if (*s == QString("Type"))
	{
	  list.next();
	}
      else if (*s == QString("ID"))
	{
	  functionId = list.next()->toULong();
	}
      else if (*s == QString("Device"))
	{
	  deviceId = list.next()->toInt();
	  if (deviceId == 0)
	    {
	      device = NULL;
	    }
	  else
	    {
	      device = searchDevice(deviceId);
	    }
	  break;
	}
      else
	{
	  // Unknown keyword (at this time)
	  list.next();
	}
    }

  if (functionId == ULONG_MAX)
    {
      qDebug("Couldn't find an ID for function <" + name + ">");
    }
  else
    {
      function = searchFunction(functionId);

      if (function != NULL)
	{
	  function->setDevice(device);
	  function->createContents(list);
	}
      else
	{
	  qDebug("Couldn't find function <" + name + ">");
	}
    }
}
Exemplo n.º 5
0
Arquivo: doc.cpp Projeto: speakman/qlc
void Doc::createFunctionContents(QList<QString> &list)
{
  Function* f = NULL;
  DMXDevice* d = NULL;

  QString name;
  QString type;
  QString device;

  for (QString* s = list.next(); s != NULL; s = list.next())
    {
      if (*s == QString("Entry"))
	{
	  s = list.prev();
	  break;
	}
      else if (*s == QString("Name"))
	{
	  name = *(list.next());
	}		      
      else if (*s == QString("Type"))
	{
	  type = *(list.next());
	}
      else if (*s == QString("Device"))
	{
	  device = *(list.next());
	  if (device == QString("Global"))
	    {
	      d = NULL;
	    }
	  else
	    {
	      d = searchDevice(device);
	    }
	  break;
	}
      else
	{
	  // Unknown keyword (at this time)
	  list.next();
	}
    }

  if (name != QString::null && type != QString::null)
    {
      if (d != NULL)
	{
	  f = d->searchFunction(name);
	}
      else
	{
	  f = searchFunction(name);
	}

      if (f != NULL)
	{
	  f->setDevice(d);
	  f->createContents(list);
	}
      else
	{
	  qDebug("Invalid or missing information for function <%s>", (const char*) name);
	}
    }
  else
    {
      qDebug("Invalid or missing information for function <%s>", (const char*) name);
    }
}