Exemplo n.º 1
0
	void LNSSqrt::outputVHDL(std::ostream& o, std::string name)
	{
		licence(o,"Jérémie Detrey, Florent de Dinechin (2003-2004), Sylvain Collange (2008)");
		Operator::stdLibs(o);
		outputVHDLEntity(o);
		newArchitecture(o,name);

		o
			<< tab << "constant wE : positive := " << wE <<";\n"
			<< tab << "constant wF : positive := " << wF <<";\n"
			<< tab << "\n"
			<< tab << "signal sRn : std_logic;\n"
			<< tab << "signal eRn : std_logic_vector(wE+wF-1 downto 0);\n"
			<< tab << "signal xRn : std_logic_vector(1 downto 0);\n"
			<< tab << "signal nRn : std_logic_vector(wE+wF+2 downto 0);\n"
			<< tab << "signal nRx : std_logic_vector(wE+wF+2 downto 0);\n"
			<< tab << "\n"
			<< tab << "signal xsA  : std_logic_vector(2 downto 0);\n";
	
		beginArchitecture(o);

		o
			<< tab << "eRn <= nA(wE+wF-1) & nA(wE+wF-1 downto 1);\n"
			<< tab << "\n"
			<< tab << "sRn <= nA(wE+wF);\n"
			<< tab << "xRn <= \"01\";\n"
			<< tab << "nRn <= xRn & sRn & eRn;\n"
			<< tab << "\n"
			<< tab << "xsA <= nA(wE+wF+2 downto wE+wF);\n"
			<< tab << "\n"
			<< tab << "with xsA select\n"
			<< tab << "nR(wE+wF+2 downto wE+wF+1) <= xsA(2 downto 1) when \"001\" | \"000\" | \"010\" | \"100\",\n"
			<< tab << "	                                    \"11\"            when others;\n"
			<< tab << "\n"
			<< tab << "nR(wE+wF downto 0) <= nRn(wE+wF downto 0);\n"
			<< "end architecture;\n";

	}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    enum { UNSPEC, READ, WRITE } mode = UNSPEC;
    int doing_opts = 1;

    ctldir = NULL;
    command = NULL;

    while (--argc > 0) {
        char *p = *++argv;
        if (doing_opts && *p == '-') {
            if (!strcmp(p, "-w")) {
                mode = WRITE;
            } else if (!strcmp(p, "-r")) {
                mode = READ;
            } else if (!strcmp(p, "--")) {
                doing_opts = 0;
            } else if (!strcmp(p, "--version")) {
                version();
                return 0;
            } else if (!strcmp(p, "--help")) {
                usage();
                return 0;
            } else if (!strcmp(p, "--licence") || !strcmp(p, "--license")) {
                licence();
                return 0;
            } else {
                fprintf(stderr, "buildrun: unrecognised option '%s'\n", p);
                return 1;
            }
        } else {
            if (!ctldir) {
                ctldir = p;
            } else {
                command = argv;
                break;
            }
        }
    }

    if (mode == UNSPEC) {
        fprintf(stderr, "buildrun: expected -w or -r\n");
        return 1;
    }

    if (!ctldir) {
        fprintf(stderr, "buildrun: expected a control directory name\n");
        return 1;
    }

    pipepath = malloc(strlen(ctldir) + strlen(PIPEFILE) + 2);
    if (!pipepath) {
        fprintf(stderr, "buildrun: out of memory\n");
        return 1;
    }
    sprintf(pipepath, "%s/%s", ctldir, PIPEFILE);

    if (mode == WRITE) {
        return writemode();
    } else if (mode == READ) {
        return readmode();
    }
}
Exemplo n.º 3
0
Arquivo: unix.c Projeto: rdebath/sgt
int main(int argc, char **argv)
{
    char **singleusercmd = NULL;
    char *testurl = NULL;
    char *dropprivuser = NULL;
#ifndef NO_X11
    char *display = NULL; 
#endif
    int doing_opts = 1;
    int port = 880;
    int multiuser = 0;

    /*
     * Parse the arguments.
     */
    while (--argc > 0) {
        char *p = *++argv;
        if (*p == '-' && doing_opts) {
            if (!strcmp(p, "--multiuser")) {
		multiuser = 1;
#ifndef NO_X11
	    } else if (!strcmp(p, "--display") || !strcmp(p, "-display")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: %s expected a parameter\n", p);
                    return 1;
                }
                display = *++argv;
#endif
            } else if (!strcmp(p, "-p")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: -p expected a parameter\n");
                    return 1;
                }
                port = atoi(*++argv);
            } else if (!strcmp(p, "-s")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: -s expected a parameter\n");
                    return 1;
                }
		override_script = *++argv;
            } else if (!strcmp(p, "-i")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: -i expected a parameter\n");
                    return 1;
                }
		override_inpac = *++argv;
            } else if (!strcmp(p, "-o")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: -o expected a parameter\n");
                    return 1;
                }
		override_outpac = *++argv;
            } else if (!strcmp(p, "-t")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: -t expected a parameter\n");
                    return 1;
                }
		testurl = *++argv;
            } else if (!strcmp(p, "-u")) {
                if (--argc <= 0) {
                    fprintf(stderr, "ick-proxy: -u expected a parameter\n");
                    return 1;
                }
		dropprivuser = *++argv;
            } else if (!strcmp(p, "--help") || !strcmp(p, "-help") ||
                       !strcmp(p, "-?") || !strcmp(p, "-h")) {
                /* Valid help request. */
                usage();
                return 0;
            } else if (!strcmp(p, "--licence") || !strcmp(p, "--license")) {
                licence();
                return 0;
            } else if (!strcmp(p, "--version")) {
                version();
                return 0;
            } else if (!strcmp(p, "--")) {
                doing_opts = 0;
            } else {
                /* Invalid option; give help as well as whining. */
                fprintf(stderr, "ick-proxy: unrecognised option '%s'\n", p);
                usage();
                return 1;
            }
        } else {
            singleusercmd = argv;
            break;
        }
    }

    /*
     * Handle command-line URL-test mode.
     */
    if (testurl) {
	char *err, *ret;

	ick_proxy_setup();

	ret = rewrite_url(&err, "", testurl);
	if (!ret) {
	    fprintf(stderr, "ick-proxy: rewrite error: %s\n", err);
	    sfree(err);
	    return 1;
	} else {
	    puts(ret);
	    sfree(ret);
	    return 0;
	}
    }

    /*
     * Otherwise, hand off to uxmain.
     */
    if (!multiuser && !singleusercmd) {
#ifdef NO_X11
	fprintf(stderr, "ick-proxy: expected a command in single-user"
		" mode\n");
	return 1;
#else
	/*
	 * Open the X display.
	 */
	disp = XOpenDisplay(display);
	if (!disp) {
	    fprintf(stderr, "ick-proxy: unable to open X display\n");
	    return 1;
	}

	/*
	 * When working with an X display, we daemonise, if only
	 * to avoid zombie processes if we're started from a
	 * .xsession that isn't wait()ing for us.
	 */
	return uxmain(0, -1, NULL, NULL, ConnectionNumber(disp), xreadfd, 1);
#endif
    }

    /*
     * The `daemon' flag is set iff we are multi-user.
     */
    return uxmain(multiuser, port, dropprivuser, singleusercmd,
		  -1, NULL, multiuser);
}
Exemplo n.º 4
0
Arquivo: pid.c Projeto: rdebath/sgt
int main(int argc, char **argv)
{
    const char **searchwords;
    int nsearchwords;
    int all = 0, all_uids = 0;
    int doing_opts = 1;

    /*
     * Allocate enough space in 'searchwords' that we could shovel the
     * whole of our argv into it if we had to. Then we won't have to
     * worry about it later.
     */
    searchwords = (const char **)malloc((argc+1) * sizeof(const char *));
    nsearchwords = 0;

    /*
     * Parse the command line.
     */
    while (--argc > 0) {
        char *p = *++argv;
        if (doing_opts && *p == '-') {
            if (!strcmp(p, "-a") || !strcmp(p, "--all")) {
                all = 1;
            } else if (!strcmp(p, "-U") || !strcmp(p, "--all-uids")) {
                all_uids = 1;
            } else if (!strcmp(p, "--version")) {
                version();
                return 0;
            } else if (!strcmp(p, "--help")) {
                usage();
                return 0;
            } else if (!strcmp(p, "--licence") || !strcmp(p, "--license")) {
                licence();
                return 0;
            } else if (!strcmp(p, "--")) {
                doing_opts = 0;
            } else {
                fprintf(stderr, "pid: unrecognised option '%s'\n", p);
                return 1;
            }
        } else {
            searchwords[nsearchwords++] = p;
            doing_opts = 0; /* further optionlike args become search terms */
        }
    }

    if (!nsearchwords) {
        fprintf(stderr, "pid: expected a command to search for; "
                "type 'pid --help' for help\n");
        return 1;
    }
    searchwords[nsearchwords] = NULL;  /* terminate list */

    {
        struct pidset procs;
        int uid, pid, npids;
        /*
         * Construct our list of processes.
         */
        procs = get_processes();
        uid = getuid();
        if (uid > 0 && !all_uids)
            procs = filter_by_uid(procs, uid);
        procs = filter_out_self(procs);
        procs = filter_by_command(procs, searchwords);
        if (!all)
            procs = filter_out_forks(procs);

        /*
         * Output.
         */
        npids = pidset_size(&procs);
        if (npids == 0) {
            printf("NONE\n");
        } else if (all) {
            const char *sep = "";
            for (pid = pidset_first(&procs); pid >= 0;
                 pid = pidset_next(&procs)) {
                printf("%s%d", sep, pid);
                sep = " ";
            }
            putchar('\n');
        } else {
            if (npids == 1) {
                printf("%d\n", pidset_first(&procs));
            } else {
                printf("MULTIPLE\n");
            }
        }
    }

    return 0;
}
Exemplo n.º 5
0
void Operator::licence(std::ostream& o){
	licence(o, copyrightString_);
}
Exemplo n.º 6
0
ReporterMV::ReporterMV(uint64_t computerName , QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ReporterMV)
{

    qDebug() <<"Name :" <<  computerName << ":)";
    QFile licence("Licence.l");
    if(!licence.open(QIODevice::ReadOnly|QIODevice::Text)){
        licence.open((QIODevice::WriteOnly|QIODevice::Text));
        licence.write("0");
        licence.close();
        licence.open(QIODevice::ReadOnly|QIODevice::Text);
    }
    uint64_t l1 = licence.readLine().toInt();
    uint64_t l2 = l1;
    uint64_t key = computerName%125418539+54919373;
    licence.close();
    bool ok = false;

    while(key != l2){
        l2 = QInputDialog::getInt(0,"Licence" , "Entrée le numero de license associée à l'ordinateur : " + QString::number(computerName)
                                  ,0 ,-2147483647 , 2147483647 , 1 , &ok);
        if(!ok){
            showed = false;
            reportDialog = NULL;
            snapDialog = NULL;
            return;
        }
    }
    showed = true;

    if(l1!=l2){
        licence.open(QIODevice::WriteOnly|QIODevice::Text|QIODevice::Truncate);
        licence.write(QString::number(l2).toStdString().c_str());
    }




    ui->setupUi(this);
    reportDialog = new ReportDialog();
    snapDialog = new SnapshotDialog(this);
    paramDialog = new ParamDialog(this);
    connect(snapDialog , SIGNAL(snapshotZoneChoosen(QRect)) , this , SLOT(changeSnapZoneParam(QRect)));
    connect(paramDialog , SIGNAL(logoButtonS()) , this , SLOT(logoButton()));
    connect(paramDialog , SIGNAL(exportButtonS()) , this , SLOT(exportButton()));
    connect(paramDialog , SIGNAL(snapZoneButtonS()) , this , SLOT(paramSnapButton()));

    //Load initial param
    QFile paramConfig("paramConfig.ini");
	if(!paramConfig.open(QIODevice::ReadOnly|QIODevice::Text)){
		exportDir = "";
        this->paramSnapshot = QRect(10,10,200,100);
        QMessageBox::information(this,"Configuration Initiale" , "Configuration du dossier d'exportation (dossier où vous exportez vos fichiers *.txt");
        this->exportButton();
        QMessageBox::information(this,"Configuration Initiale" , "Configuration du logo que vous voulez pour les rapports");
        this->logoButton();
        QMessageBox::information(this,"Configuration Initiale" , "Configuration de la fenetre de capture d'ecran.\nRedimensionnez la fenetre transparente pour qu'elle epouse les bords de la zone de schema de Inspec");
        this->paramSnapButton();
	}
    else{
        QTextStream in(&paramConfig);
        int x,y,width,height;
        char waste;
        in >> x >>waste >> y >> waste >> width >> waste >> height >> waste >> exportDir >> waste >> logo;
        paramConfig.close();
        this->paramSnapshot = QRect(x , y, width , height);
    }

}
Exemplo n.º 7
0
int main(int argc, char **argv)
{
  char **infiles;
  char *outfile;
  int nfiles;
  int nogo;
  int errs;
  int reportcols;
  int debug;

  /*
   * Set up initial (default) parameters.
   */
  infiles = mknewa(char *, argc);
  outfile = NULL;
  nfiles = 0;
  nogo = errs = FALSE;
  reportcols = 0;
  debug = 0;

  if (argc == 1)
  {
    usage();
    exit(EXIT_SUCCESS);
  }

  /*
   * Parse command line arguments.
   */
  while (--argc)
  {
    char *p = *++argv;
    if (*p == '-')
    {
      /*
       * An option.
       */
      while (p && *++p)
      {
        char c = *p;
        switch (c)
        {
        case '-':
          /*
           * Long option.
           */
          {
            char *opt, *val;
            opt = p++;          /* opt will have _one_ leading - */
            while (*p && *p != '=')
              p++;              /* find end of option */
            if (*p == '=')
            {
              *p++ = '\0';
              val = p;
            } else
              val = NULL;
            if (!strcmp(opt, "-version"))
            {
              showversion();
              nogo = TRUE;
            } else if (!strcmp(opt, "-licence") ||
                       !strcmp(opt, "-license"))
            {
              licence();
              nogo = TRUE;
            } else if (!strcmp(opt, "-output"))
            {
              if (!val)
                errs = TRUE, error(err_optnoarg, opt);
              else
                outfile = val;
            } else if (!strcmp(opt, "-precise"))
            {
              reportcols = 1;
            } else
            {
              errs = TRUE, error(err_nosuchopt, opt);
            }
          }
          p = NULL;
          break;
        case 'V':
        case 'L':
        case 'P':
        case 'd':
          /*
           * Option requiring no parameter.
           */
          switch (c)
          {
          case 'V':
            showversion();
            nogo = TRUE;
            break;
          case 'L':
            licence();
            nogo = TRUE;
            break;
          case 'P':
            reportcols = 1;
            break;
          case 'd':
            debug = TRUE;
            break;
          }
          break;
        case 'o':
          /*
           * Option requiring parameter.
           */
          p++;
          if (!*p && argc > 1)
            --argc, p = *++argv;
          else if (!*p)
          {
            char opt[2];
            opt[0] = c;
            opt[1] = '\0';
            errs = TRUE, error(err_optnoarg, opt);
          }
          /*
           * Now c is the option and p is the parameter.
           */
          switch (c)
          {
          case 'o':
            outfile = p;
            break;
          }
          p = NULL;             /* prevent continued processing */
          break;
        default:
          /*
           * Unrecognised option.
           */
          {
            char opt[2];
            opt[0] = c;
            opt[1] = '\0';
            errs = TRUE, error(err_nosuchopt, opt);
          }
        }
      }
    } else
    {
      /*
       * A non-option argument.
       */
      infiles[nfiles++] = p;
    }
  }

  if (errs)
    exit(EXIT_FAILURE);
  if (nogo)
    exit(EXIT_SUCCESS);

  /*
   * Do the work.
   */
  if (nfiles == 0)
  {
    error(err_noinput);
    usage();
    exit(EXIT_FAILURE);
  }

  {
    input in;
    paragraph *sourceform, *p;
    indexdata *idx;
    keywordlist *keywords;

    in.filenames = infiles;
    in.nfiles = nfiles;
    in.currfp = NULL;
    in.currindex = 0;
    in.npushback = in.pushbacksize = 0;
    in.pushback = NULL;
    in.reportcols = reportcols;
    in.stack = NULL;

    idx = make_index();

    sourceform = read_input(&in, idx);
    if (!sourceform)
      exit(EXIT_FAILURE);

    sfree(in.pushback);

    mark_attr_ends(sourceform);

    sfree(infiles);

    keywords = get_keywords(sourceform);
    if (!keywords)
      exit(EXIT_FAILURE);
    gen_citations(sourceform, keywords);
    subst_keywords(sourceform, keywords);

    for (p = sourceform; p; p = p->next)
      if (p->type == para_IM)
        index_merge(idx, TRUE, p->keyword, p->words);

    build_index(idx);


    if (debug)
    {
      index_debug(idx);
      dbg_prtkws(keywords);
      dbg_prtsource(sourceform);
    }

    xhtml_backend(sourceform, keywords, idx);

    free_para_list(sourceform);
    free_keywords(keywords);
    cleanup_index(idx);
  }

  return 0;
}