Пример #1
0
// virtual
void LLFloaterIMPanel::changed(U32 mask)
{
	if (mask & (REMOVE|ADD|POWERS|ONLINE)) // Fix remove/add and map friend choices
	{
		U8 did(0);
		LLComboBox& flyout = *getChild<LLComboBox>("instant_message_flyout");
		if (mask & POWERS)
		{
			// Powers changed, unfortunately, we never know which.
			add_map_option(flyout, getString("find on map"), mOtherParticipantUUID, did);
		}
		if (mask & ONLINE)
		{
			if (~did & 0x01)
				add_map_option(flyout, getString("find on map"), mOtherParticipantUUID, did);
			/* Singu TODO: Chat UI - Online icons?
			if (LLAvatarTracker::instance().isBuddyOnline(mOtherParticipantUUID))
				// Show online icon here?
			else
				// Show offline icon here?
			*/
		}
		if (mask & (REMOVE|ADD) || did & 0x02) // Only rebuild if necessary
			rebuildDynamics(&flyout);
	}
}
Пример #2
0
int main()
{
   void did();
   int t;
   scanf("%d",&t);
   while (t--)
      did();
   system("pause");
   return(0);
}
Пример #3
0
void check(int x,int y)
{
    char c;
    scanf(" %c",&c);
    switch (c)
    {
    case 'a' :
        add(x,y);
        break;
    case 'b' :
        sub(x,y);
        break;
    case 'c' :
        mul(x,y);
        break;
    case 'd' :
        did(x,y);
        break;
    default:
        printf("You have entered wrong input !!\n");
        break;
    }
    return;
}
Пример #4
0
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        ok=ans=0;
        scanf("%d%d%d%d%d%d",&p1,&q1,&p2,&q2,&p3,&q3);
        if(aabs(p1,p2)<aabs(q1,q2))
        {
            change(&p1,&q1);
            change(&p2,&q2);
            change(&p3,&q3);
        }
        did();
        if(ok==0)
        {
            printf("NO\n%d\n",dist-1);
        }
        else
        {
            printf("YES\n%d\n",ans);
        }
    }
    return 0;
}
Пример #5
0
int main( int argc, char** argv )
{
        if (argc == 1) usage(argv[0]);
        int c;
        int verbose_flag, quiet_flag;
        char input[MAX_FILENAME], output[MAX_FILENAME], geom[MAX_FILENAME], status[MAX_FILENAME];
        sprintf(input, "input.dat");
        sprintf(output, "output.root");
        sprintf(geom, "detid_geom.dat");
        sprintf(status, " ");

        int tmin = -1, tmax = -1, niov = -1, br = 0, prescale = 1;

        while (1) {

                static struct option long_options[] =
                {
                        {"verbose",  no_argument, &verbose_flag, 1},
                        {"quiet",    no_argument, &quiet_flag, 0},
                        {"input",    required_argument, 0, 'i'},
                        {"output",   required_argument, 0, 'o'},
                        {"geom",     required_argument, 0, 'g'},
                        {"status",   required_argument, 0, 'S'},
                        {"tmin",     required_argument, 0, 't'},
                        {"tmax",     required_argument, 0, 'T'},
                        {"niov",     required_argument, 0, 'n'},
                        {"break",    required_argument, 0, 'b'},
                        {"prescale", required_argument, 0, 's'},
                };

                int option_index = 0;
                c = getopt_long(argc, argv, "vqi:o:g:S:s:t:T:n:b", long_options, &option_index);
                if (c == -1) break;

                switch (c) {
                        case 0:
                                if (long_options[option_index].flag != 0) break;
                                printf("option %s", long_options[option_index].name);
                                if (optarg) printf(" with arg %s", optarg);
                                printf("\n");
                        case 'b':
                                br = atoi(optarg);
                                printf("break: %d\n", br);
                                break;
                        case 'g':
                                sprintf(geom, "%s", optarg);
                                printf("geometry file: %s\n", geom);
                                break;
                        case 'i':
                                sprintf(input, "%s", optarg);
                                printf("input file: %s\n", input);
                                break;
                        case 'n':
                                niov = atoi(optarg);
                                printf("number of IOV: %d\n", niov);
                                break;
                        case 'o':
                                sprintf(output, "%s", optarg);
                                printf("output file: %s\n", output);
                                break;
                        case 'S':
                                sprintf(status, "%s", optarg);
                                printf("status file: %s\n", status);
                                break;
                        case 't':
                                tmin = atoi(optarg);
                                printf("tmin: %d\n", tmin);
                                break;
                        case 'T':
                                tmax = atoi(optarg);
                                printf("tmax: %d\n", tmax);
                                break;
                        case 's':
                                prescale = atoi(optarg);
                                printf("prescale: %d\n", tmax);
                                break;
                        default:
                                usage(argv[0]);
                }
        }

        FILE * fd = fopen(input, "r");
        if (fd == NULL) {
                fprintf(stderr, "error opening file `%s': %s.\n", input, strerror(errno));
                exit(2);
        }

        FILE * ftmp = fopen(geom, "r");
        if (ftmp == NULL) {
                fprintf(stderr, "error opening file `%s': %s.\n", geom, strerror(errno));
                exit(3);
        } else {
                fclose(ftmp);
        }

        EcalChannelStatus ch_status_;
        if (strcmp(status, " ") != 0) {
                FILE * fstatus = fopen(status, "r");
                if (fstatus == NULL) {
                        fprintf(stderr, "error opening file `%s': %s.\n", status, strerror(errno));
                        exit(4);
                } else {
                        uint32_t id;
                        uint16_t st;
                        int cnt = 0;
                        while (fscanf(fstatus, "%u %hu", &id, &st) != EOF) {
                                EcalChannelStatusCode code(st);
                                ch_status_[id] = code;
                                ++cnt;
                        }
                        assert(cnt == 75848);
                        fclose(fstatus);
                }
        }

        char * line = NULL;
        size_t len = 0;
        ssize_t read;
        int first = 1;
        EcalLaserPlotter lp(geom);
        if (strcmp(status, " ") != 0) lp.setEcalChannelStatus(ch_status_, 1);
        EcalLaserAPDPNRatios apdpn;
        time_t t[92], t1, t3; //, ot3 = 0;
        int cnt = 0, cnt_iov = 0, skip = 0;
        int id;
        char * beg, * end;
        EcalLaserAPDPNRatios::EcalLaserAPDPNpair p;
        EcalLaserAPDPNRatios::EcalLaserTimeStamp ts;
        size_t cnt_line = 0;
        while( (read = getline(&line, &len, fd)) != EOF ) {
                ++cnt_line;
                if (line[0] == 'T') {
                        if (!first && !skip) lp.fill(apdpn, t1);
                        skip = 0;
                        ++cnt_iov;
                        // new sequence
                        sscanf(line, "T %ld %ld", &t1, &t3);
                        char bufb[128], bufe[128];
                        strftime(bufb, sizeof(bufb), "%F %R:%S", gmtime(&t1));
                        strftime(bufe, sizeof(bufe), "%F %R:%S", gmtime(&t3));
                        if (tmin > 0 && t1 < tmin)      skip = 1;
                        if (tmax > 0 && t1 > tmax)      skip = 1;
                        if (niov > 0 && cnt_iov > niov) skip = 1;
                        if (cnt_iov % prescale != 0)    skip = 1;
                        if (skip) {
                                if (br) break;
                                printf("skipping IOV %5d     begin: %s (%ld)    end: %s (%ld)\n", cnt_iov, bufb, t1, bufe, t3);
                                continue;
                        } else  printf("IOV %5d     begin: %s (%ld)    end: %s (%ld)\n", cnt_iov, bufb, t1, bufe, t3);
                        beg = &line[1];
                        for (int i = -2, j = -2; i < 92; ++i, ++j) {
                                if(i < 0) j = 0;
                                t[j] = strtol(beg, &end, 0);
                                beg = end;
                        }
                        if (!(t1 < t3)) {
                                lp.save(output);
                                fprintf(stderr, "ERROR in line %lu: t1 < t3 failed\n", cnt_line);
                                assert(0);
                        }
                        for (int i = 0; i < 92; ++i) {
                                if(!(t1 <= t[i] && t[i] <= t3)) {
                                        lp.save(output);
                                        fprintf(stderr, "ERROR in line %lu: t1 <= t[i] && t[i] <= t3 failed\n", cnt_line);
                                        assert(0);
                                }
                        }
                        //printf("%d %d %d\n", cnt, EBDetId::MAX_HASH, EEDetId::kSizeForDenseIndexing);
                        if (!first) {
                                //assert(ot3 == t1); // not always true if sequences are taken from DB
                                if (!(cnt == EBDetId::MAX_HASH + 1 + EEDetId::kSizeForDenseIndexing)) {
                                        fprintf(stderr, "found only %d DetId(s) at line %lu\n", cnt, cnt_line);
                                }
                                assert(cnt == EBDetId::MAX_HASH + 1 + EEDetId::kSizeForDenseIndexing);
                        }
                        //ot3 = t3;
                        cnt = 0;
                        first = 0;
                        free(line);
                        line = NULL;
                } else {
                        sscanf(line, "P %d %f %f %f", &id, &p.p1, &p.p2, &p.p3);
                        if (skip) continue;
                        ts.t1 = (edm::Timestamp)t1;
                        DetId did(id);
                        int iLM;
                        if (did.subdetId() == EcalBarrel) {
                                EBDetId ebid(id);
                                iLM = MEEBGeom::lmr(ebid.ieta(), ebid.iphi());
                        } else if (did.subdetId() == EcalEndcap) {
                                EEDetId eeid(id);
                                // SuperCrystal coordinates
                                MEEEGeom::SuperCrysCoord iX = (eeid.ix()-1)/5 + 1;
                                MEEEGeom::SuperCrysCoord iY = (eeid.iy()-1)/5 + 1;    
                                iLM = MEEEGeom::lmr(iX, iY, eeid.zside());    
                        } else {
                                fprintf(stderr, "ERROR on line %lu: DetId %d not belonging to EB nor to EE\n", cnt_line, id);
                                assert(0);
                        }
                        ts.t2 = (edm::Timestamp)t[iLM - 1];
                        ts.t3 = (edm::Timestamp)t3;
                        apdpn.setValue(id, p);
                        apdpn.setTime(iLM - 1, ts);
                        ++cnt;
                        free(line);
                        line = NULL;
                }
        }
        if (!skip) lp.fill(apdpn, t1);
        lp.save(output);
        return 0;
}
Пример #6
0
// get network interface info from file (should include all available interfaces)
std::vector<std::map<std::string,std::string> >
Responder::read_eth_info()
{
    const std::string eth_file(_eth_file);

    std::vector<std::map<std::string,std::string> > eths;
    try
    {
        ifstream eth_info(eth_file.c_str());
        if(!eth_info.is_open()){
            return eths;
        }
        const int len = 256;
        char cline[len];
        for(; !eth_info.eof() ;)
        {
            eth_info.getline(cline, len);
            std::string line(cline);
            if(line.find("## ETH Interface") != std::string::npos)
            {
                eth_info.getline(cline, len);
                std::string eth(cline);
//                cout << "interface=" << eth << endl;
                std::map<std::string,std::string> iface;
                iface["interface"] = eth;
                eths.push_back(iface);
            }
            const std::string ipstr("\tip ");
            if(line.find(ipstr) != std::string::npos)
            {
                std::string ip( line.replace(line.begin(), line.begin()+ipstr.length(), "") );
//                cout << "ip=" << ip << endl;
                eths.back()["addr"] = ip;
            }
            const std::string macstr("\tmac ");
            if(line.find(macstr) != std::string::npos)
            {
                std::string mac( line.replace(line.begin(), line.begin()+macstr.length(), "") );
//                cout << "mac=" << mac << endl;
                eths.back()["mac"] = mac;
            }
            const std::string vstr("\t\tvendor ");
            if(line.find(vstr) != std::string::npos)
            {
                std::string vendor( line.replace(line.begin(), line.begin()+vstr.length(), "") );
                std::string vid( vendor.substr(0,6) );
                vendor.replace(0, 7, "");
//                cout << "id=" << vid << endl;
//                cout << "vendor=" << vendor << endl;
                eths.back()["vendor"] = vendor;
                eths.back()["vendor_id"] = vid;
            }
            const std::string dstr("\t\tdevice ");
            if(line.find(dstr) != std::string::npos)
            {
                std::string device( line.replace(line.begin(), line.begin()+dstr.length(), "") );
                std::string did( device.substr(0,6) );
                device.replace(0, 7, "");
//                cout << "id=" << did << endl;
//                cout << "device=" << device << endl;
                eths.back()["device"] = device;
                eths.back()["device_id"] = did;
            }
        }

    }
    catch(...)
    {
        // nothing in yet
    }
    return eths;
}