Example #1
0
/*
count the number of nodal domains in grid
precondition: grid must be ny x nx

inputs:
        grid   - function values sampled at grid points
	counted  - array to store nodal domain numbers in. mask should be applied to this already
        sizefile - file to write size of nodal domains to
output: return value - count of nodal domains
*/
int countNodalDomains(bit_array_t *signs, bit_array_t *counted, FILE *sizefile) {
  int i, j;
  int rc;
  int nx, ny;
  nx = signs->nx;
  ny = signs->ny;

  #ifdef DEBUG
  bit_array2file(signs, "../data/signs.dat");
  domain_numbers = imatrix(ny, nx);
  #endif
  
  int nd = 0; // count of nodal domains
  int size; // area of last nodal domain (in pixels)

  i = 0;
  j = 0;
  while (findNextUnseen(counted, &i, &j, ny, nx)) {
    nd++;
    size = findDomain(signs, counted, i, j, nd, ny, nx);
    if (sizefile) {
      fprintf(sizefile, "%d ", size);
    }
  }

  #ifdef DEBUG
  intArray2file(domain_numbers, ny, nx, "../data/counted.dat");
  #endif

  return nd;
}
void CookiesContentsWidget::removeCookie(const QNetworkCookie &cookie)
{
	const QString domain = (cookie.domain().startsWith('.') ? cookie.domain().mid(1) : cookie.domain());
	QStandardItem *domainItem = findDomain(domain);

	if (domainItem)
	{
		QPoint point;

		for (int j = 0; j < domainItem->rowCount(); ++j)
		{
			if (domainItem->child(j, 0)->text() == cookie.name() && domainItem->child(j, 0)->data(Qt::UserRole).toString() == cookie.path())
			{
				point = m_ui->cookiesView->visualRect(domainItem->child(j, 0)->index()).center();

				domainItem->removeRow(j);

				break;
			}
		}

		if (domainItem->rowCount() == 0)
		{
			m_model->invisibleRootItem()->removeRow(domainItem->row());
		}
		else
		{
			domainItem->setText(QStringLiteral("%1 (%2)").arg(domain).arg(domainItem->rowCount()));
		}

		if (!point.isNull())
		{
			const QModelIndex index = m_ui->cookiesView->indexAt(point);

			m_ui->cookiesView->setCurrentIndex(index);
			m_ui->cookiesView->selectionModel()->select(index, QItemSelectionModel::Select);
		}
	}
}
int filterDocumentIndex(struct DocumentIndexFormat *DocumentIndex) {

	char domain[65]; //domane kan maks være på 64 bokstaver, + \0
	char *cpoint;
	int hyphenCount;

	printf("url: %s\n",(*DocumentIndex).Url);

	findDomain((*DocumentIndex).Url,domain);

	//teller antal forekomster av -
	hyphenCount = 0;
	cpoint = domain;
	while(cpoint = strchr(cpoint,'-')) {
		//går vidre
		++cpoint;
		++hyphenCount;
	}	

	printf("domain: %s\nhyphenCount %i\n",domain,hyphenCount);

}
Example #4
0
static void
signalHandler(
    int sig,
    siginfo_t *info,
    void *arg)
{
    os_time serviceTerminatePeriod;
    cf_element domain = NULL;

    if(domain_name)
    {
        if(platformConfig)
        {
            findDomain (platformConfig, &domain);
        }
        findServiceTerminatePeriod(domain, &serviceTerminatePeriod);
        findSpliceSystemAndRemove (domain_name, serviceTerminatePeriod);
    } else
    {
        printf ("Signal received before fully started.\n");
        exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
    }
}
void CookiesContentsWidget::addCookie(const QNetworkCookie &cookie)
{
	const QString domain = (cookie.domain().startsWith('.') ? cookie.domain().mid(1) : cookie.domain());
	QStandardItem *domainItem = findDomain(domain);

	if (domainItem)
	{
		for (int i = 0; i < domainItem->rowCount(); ++i)
		{
			if (domainItem->child(i, 0)->text() == cookie.name() && domainItem->child(i, 0)->data(Qt::UserRole).toString() == cookie.path())
			{
				return;
			}
		}
	}
	else
	{
		domainItem = new QStandardItem(HistoryManager::getIcon(QUrl(QStringLiteral("http://%1/").arg(domain))), domain);
		domainItem->setToolTip(domain);

		m_model->appendRow(domainItem);

		if (sender())
		{
			m_model->sort(0);
		}
	}

	QStandardItem *cookieItem = new QStandardItem(QString(cookie.name()));
	cookieItem->setData(cookie.path(), Qt::UserRole);
	cookieItem->setData(cookie.domain(), (Qt::UserRole + 1));
	cookieItem->setToolTip(cookie.name());
	cookieItem->setFlags(cookieItem->flags() | Qt::ItemNeverHasChildren);

	domainItem->appendRow(cookieItem);
	domainItem->setText(QStringLiteral("%1 (%2)").arg(domain).arg(domainItem->rowCount()));
}
void CookiesContentsWidget::removeDomainCookies()
{
	const QModelIndex index = m_ui->cookiesView->currentIndex();
	QStandardItem *domainItem = ((index.isValid() && index.parent() == m_model->invisibleRootItem()->index()) ? findDomain(index.sibling(index.row(), 0).data(Qt::ToolTipRole).toString()) : m_model->itemFromIndex(index.parent()));

	if (!domainItem)
	{
		return;
	}

	QNetworkCookieJar *cookieJar = NetworkManagerFactory::getCookieJar();
	QList<QNetworkCookie> cookies;

	for (int i = 0; i < domainItem->rowCount(); ++i)
	{
		QStandardItem *cookieItem = domainItem->child(i, 0);

		if (cookieItem)
		{
			cookies.append(getCookie(cookieItem->index()));
		}
	}

	if (cookies.isEmpty())
	{
		return;
	}

	QMessageBox messageBox;
	messageBox.setWindowTitle(tr("Question"));
	messageBox.setText(tr("You are about to delete %n cookies.", "", cookies.count()));
	messageBox.setInformativeText(tr("Do you want to continue?"));
	messageBox.setIcon(QMessageBox::Question);
	messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
	messageBox.setDefaultButton(QMessageBox::Yes);

	if (messageBox.exec() == QMessageBox::Yes)
	{
		for (int i = 0; i < cookies.count(); ++i)
		{
			cookieJar->deleteCookie(cookies.at(i));
		}
	}
}
Example #7
0
int
main(
    int argc,
    char *argv[])
{
    int opt;
    int retCode = OSPL_EXIT_CODE_OK;
    char *uri = NULL;
    char *command = NULL;
    char start_command[2048];
    cf_element domain = NULL;
    cfgprs_status r;
    os_boolean blocking = OS_FALSE;
    os_boolean blockingDefined = OS_FALSE;
    os_time serviceTerminatePeriod;
    char *vg_cmd = NULL;

    ospl_setsignals();
    os_osInit();
    os_procAtExit(os_osExit);

    uri = os_getenv ("OSPL_URI");
    vg_cmd = os_getenv("VG_SPLICED");
    if (!vg_cmd)
    {
       vg_cmd = "";
    }

    while ((opt = getopt (argc, argv, "hvafd:")) != -1)
    {
        switch (opt)
        {
        case 'h':
            print_usage (argv[0]);
            exit (OSPL_EXIT_CODE_OK);
            break;
        case 'v':
            printf ("OpenSplice version : %s\n", VERSION);
            exit (OSPL_EXIT_CODE_OK);
            break;
        case 'd':
            if (domain_name)
            {
                print_usage (argv[0]);
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
            domain_name = optarg;
            break;
        case 'a':
            if (domain_name)
            {
                print_usage (argv[0]);
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
            uri = NULL;
            domain_name = "*";
            break;
        case 'f':
            if(blockingDefined)
            {
                print_usage (argv[0]);
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
            blocking = OS_TRUE;
            blockingDefined = OS_TRUE;
            break;
        case '?':
            print_usage (argv[0]);
            exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            break;
        default:
            break;
        }
    }
    if ((argc-optind) > 3)
    {
        print_usage (argv[0]);
        exit(OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
    }
    command = argv[optind];
    if (command && argv[optind+1])
    {
        uri = argv[optind+1];
    }

    if (uri && (strlen(uri) > 0))
    {
        r = cfg_parse_ospl (uri, &platformConfig);
        if (r == CFGPRS_OK)
        {
            domain_name = findDomain (platformConfig, &domain);
            if (domain_name == NULL)
            {
                printf ("The domain name could not be determined from the configuration\n");
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
        } else
        {
            if (r == CFGPRS_NO_INPUT)
            {
                printf ("Error: Cannot open URI \"%s\". Exiting now...\n", uri);
            }
            else
            {
                printf ("Errors are detected in the configuration. Exiting now...\n");
            }
            exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
        }
    }
    if ((command == NULL) || (strcmp (command, "stop") == 0))
    {
        if (domain_name == NULL)
        {
            domain_name = "The default Domain";
        }
        findServiceTerminatePeriod(domain, &serviceTerminatePeriod);
        retCode = findSpliceSystemAndRemove (domain_name, serviceTerminatePeriod);
    } else if (strcmp (command, "start") == 0)
    {
#ifdef OS_LINUX_DEFS_H
        check_for_LD_ASSUME_KERNEL ();
#endif
        if (domain_name == NULL)
        {
            domain_name = "The default Domain";
        }
        if (!spliceSystemRunning (domain_name))
        {
            if(!blocking)
            {
                printf ("\nStarting up domain \"%s\" .", domain_name);
            } else
            {
                printf ("\nStarting up domain \"%s\" and blocking.", domain_name);
            }
            if (uri)
            {
                if(!blocking)
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced \"%s\" &", vg_cmd, uri);
                } else
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced \"%s\"", vg_cmd, uri);
                }
            } else
            {
                if(!blocking)
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced &", vg_cmd);
                } else
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced", vg_cmd);
                }
            }

            printf (" Ready\n");

            /* Display locations of info and error files */
            os_reportDisplayLogLocations();

            retCode = WEXITSTATUS(system (start_command));
            if(!blocking)
            {
                sleep (2); /* take time to first show the license message from spliced */
            }
        } else
        {
            printf ("Splice System with domain name \"%s\" is found running, ignoring command\n",
            domain_name);
        }
    } else if (strcmp (command, "list") == 0)
    {
        retCode = findSpliceSystemAndShow (domain_name);
    } else
    {
        print_usage (argv[0]);
        exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
    }
    return retCode;
}