コード例 #1
0
ファイル: A.cpp プロジェクト: ACM-Obsidian/Obsidian
void solve() {
	for (int i = 0; i < n; i++) scanf("%d", &d[i]), d[i]++;
	for (int i = 0; i < n; i++) scanf("%d", &p[i]);
	int flag1 = 1, flag2 = 0;
	for (int i = 0; i < n; i++) flag1 &= d[i] & 1;
	for (int i = 0; i < n; i++) flag2 = (flag2 + p[i]) & 1;
	if (flag1 && !flag2) {
		puts("Bob"); fflush(stdout);
		for (int i = 0; i < n; i++) x[i] = p[i];
		findmatch(n, x);
	} else {
		puts("Alice"); fflush(stdout);
		if (flag1) {
			for (int i = 0; i < n; i++) x[i] = 0;
			findmatch(n, x);
		} else {
			findmatch(n, x);
		}
		printmove();
	}
	while (1) {
		if (scanmove() == -1)
			break;
		printmove();
	}
}
コード例 #2
0
ファイル: hpifru.c プロジェクト: openhpi1/testrepo
static int 
IsTagBmc(char *dstr, int dlen)
{
   int ret = 0;
   if (findmatch(dstr,dlen,bmctag2,sizeof(bmctag2),1) >= 0)
        ret = 1;    /* BMC tag for OpenHPI with ipmi plugin */
   else if (strncmp(dstr, bmctag, dlen) == 0)  /* Sahalee */
	ret = 1;
   else if (findmatch(dstr,dlen,"BMC",3,1) >= 0) /* mBMC or other */
	ret = 1;
   return(ret);
}
コード例 #3
0
ファイル: A.cpp プロジェクト: ACM-Obsidian/Obsidian
void findmatch(int n, int *x) {
	int flag = 1, delta = 1;
	for (int i = 0; i < n; i++) flag &= d[i] & 1;
	for (int i = 0; i < n-1; i++) delta *= d[i];
	if (!flag) {
		if (n == 1) {
			for (int i = 0; i < d[0]; i += 2) addmatch(i, i+1);
		} else {
			flag = 1;
			for (int i = 0; i < n-1; i++) flag &= d[i] & 1;
			if (flag) {
				for (int i = 0; i < n-1; i++) x[i] = 0;
				findmatch(n-1, x);
				duplicate(n, delta);
				for (int i = 0; i < d[n-1]; i += 2) addmatch(delta*i, delta*(i+1));
			} else {
				findmatch(n-1, x);
				duplicate(n, delta);
			}
		}
	} else {
		if (n == 1) {
			for (int i = 0; i < x[0]; i += 2) addmatch(i, i+1);
			for (int i = x[0]+1; i < d[0]; i += 2) addmatch(i, i+1);
			match[x[0]] = -1;
		} else if (x[n-1] & 1) {
			int dir = -1;
			if (x[n-2] == 0) dir = 1;
			x[n-2] += dir;
			findmatch(n-1, x);
			duplicate(n, delta);
			int base1 = encode(x, n-1);
			x[n-2] -= dir;
			int base = encode(x, n-1), base2 = match[base];
			for (int i = 1; i < x[n-1]; i += 2) addmatch(delta*i+base, delta*(i+1)+base);
			for (int i = x[n-1]+1; i < d[n-1]-1; i += 2) addmatch(delta*i+base, delta*(i+1)+base);
			for (int i = 0; i < d[n-1]-1; i += 2) addmatch(delta*i+base1, delta*(i+1)+base1);
			addmatch(delta*(d[n-1]-1)+base1, delta*(d[n-1]-1)+base);
			for (int i = 1; i < d[n-1]; i += 2) addmatch(delta*i+base2, delta*(i+1)+base2);
			addmatch(base, base2);
			match[x[n-1]*delta+base] = -1;
		} else {
			findmatch(n-1, x);
			duplicate(n, delta);
			int base = encode(x, n-1);
			for (int i = 0; i < x[n-1]; i += 2) addmatch(delta*i+base, delta*(i+1)+base);
			for (int i = x[n-1]+1; i < d[n-1]; i += 2) addmatch(delta*i+base, delta*(i+1)+base);
			match[x[n-1]*delta+base] = -1;
		}
	}
}
コード例 #4
0
ファイル: bcmgpio.c プロジェクト: AllardJ/Tomato
/*
* Variable should be in format:
*
*	gpio<N>=pin_name,pin_name
*
* This format allows multiple features to share the gpio with
* mutual understanding.
*
* 'def_pin' is returned if a specific gpio is not defined for the requested functionality 
* and if def_pin is not used by others.
*/
int
bcmgpio_getpin(char *pin_name, uint def_pin)
{
	char name[] = "gpioXXXX";
	char *val;
	uint pin;

	/* Go thru all possibilities till a match in pin name */
	for (pin = 0; pin < BCMGPIO_MAXPINS; pin ++) {
		sprintf(name, "gpio%d", pin);
		val = nvram_get(name);
		if (val && findmatch(val, pin_name))
			return pin;
	}

	if (def_pin != BCMGPIO_UNDEFINED) {
		/* make sure the default pin is not used by someone else */
		sprintf(name, "gpio%d", def_pin);
		if (nvram_get(name))
		{
			def_pin =  BCMGPIO_UNDEFINED;
		}
	}

	return def_pin;
}
コード例 #5
0
ファイル: gage.c プロジェクト: Giswater/giswater_models
int readGageSeriesFormat(char* tok[], int ntoks, double x[])
{
    int m, ts;
    DateTime aTime;

    if ( ntoks < 6 ) return error_setInpError(ERR_ITEMS, "");

    // --- determine type of rain data
    m = findmatch(tok[1], RainTypeWords);
    if ( m < 0 ) return error_setInpError(ERR_KEYWORD, tok[1]);
    x[1] = (double)m;

    // --- get data time interval & convert to seconds
    if ( getDouble(tok[2], &x[2]) ) x[2] = floor(x[2]*3600 + 0.5);
    else if ( datetime_strToTime(tok[2], &aTime) )
    {
        x[2] = floor(aTime*SECperDAY + 0.5);
    }
    else return error_setInpError(ERR_DATETIME, tok[2]);
    if ( x[2] <= 0.0 ) return error_setInpError(ERR_DATETIME, tok[2]);

    // --- get snow catch deficiency factor
    if ( !getDouble(tok[3], &x[3]) )
        return error_setInpError(ERR_DATETIME, tok[3]);;

    // --- get time series index
    ts = project_findObject(TSERIES, tok[5]);
    if ( ts < 0 ) return error_setInpError(ERR_NAME, tok[5]);
    x[0] = (double)ts;
    strcpy(tok[2], "");
    return 0;
}
コード例 #6
0
ファイル: bcmutils.c プロジェクト: 12019/hg556a_source
/*
* Variable should be in format:
*
*	gpio<N>=pin_name,pin_name
*
* This format allows multiple features to share the gpio with mutual
* understanding.
*
* 'def_pin' is returned if a specific gpio is not defined for the requested functionality 
* and if def_pin is not used by others.
*/
uint
getgpiopin(char *vars, char *pin_name, uint def_pin)
{
	char name[] = "gpioXXXX";
	char *val;
	uint pin;

	/* Go thru all possibilities till a match in pin name */
	for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
		sprintf(name, "gpio%d", pin);
		val = getvar(vars, name);
		if (val && findmatch(val, pin_name))
			return pin;
	}

	if (def_pin != GPIO_PIN_NOTDEFINED) {
		/* make sure the default pin is not used by someone else */
		sprintf(name, "gpio%d", def_pin);
		if (getvar(vars, name)) {
			def_pin =  GPIO_PIN_NOTDEFINED;
		}
	}

	return def_pin;
}
コード例 #7
0
int readControl(char* tok[], int ntoks)
//
//  Input:   tok[] = array of string tokens
//           ntoks = number of tokens
//  Output:  returns error code
//  Purpose: reads a line of input for a control rule.
//
{
    int index;
    int keyword;

    // --- check for minimum number of tokens
    if ( ntoks < 2 ) return error_setInpError(ERR_ITEMS, "");

    // --- get index of control rule keyword
    keyword = findmatch(tok[0], RuleKeyWords);
    if ( keyword < 0 ) return error_setInpError(ERR_KEYWORD, tok[0]);

    // --- if line begins a new control rule, add rule ID to the database
    if ( keyword == 0 )
    {
        if ( !project_addObject(CONTROL, tok[1], Mobjects[CONTROL]) )
        {
            return error_setInpError(ERR_DUP_NAME, Tok[1]);
        }
        Mobjects[CONTROL]++;
    }

    // --- get index of last control rule processed
    index = Mobjects[CONTROL] - 1;
    if ( index < 0 ) return error_setInpError(ERR_RULE, "");

    // --- add current line as a new clause to the control rule
    return controls_addRuleClause(index, keyword, Tok, Ntokens);
}
コード例 #8
0
ファイル: rename.c プロジェクト: walrus7521/code
int main()
{
    string s;
    char c;
    int nlines;
    int i, j;
    int pos;

    read_changes();
    scanf("%d\n", &nlines);
    for (i = 1; i <= nlines; i++) {
        j = 0;
        while ((c = getchar()) != '\n') {
            s[j] = c;
            j++;
        }
        s[j] = '\0';

        for (j = 0; j < nmergers; j++)
            while ((pos = findmatch(mergers[j][0], s)) != -1) {
                replace_x_with_y(s, pos,
                        strlen(mergers[j][0]), mergers[j][1]);
            }
        printf("%s\n", s);
    }

    return 0;
}
コード例 #9
0
ファイル: treatmnt.c プロジェクト: mbusnina/DynaVIBe
int  getVariableIndex(char* s)
//
//  Input:   s = name of a process variable or pollutant
//  Output:  returns index of process variable or pollutant
//  Purpose: finds position of process variable/pollutant in list of names.
//
{
    // --- check for a process variable first
    int k;
    int m = PVMAX;                     // PVMAX is number of process variables

    k = findmatch(s, ProcessVarWords);
    if ( k >= 0 ) return k;

    // --- then check for a pollutant concentration
    k = project_findObject(POLLUT, s);
    if ( k >= 0 ) return (k + m);

    // --- finally check for a pollutant removal
    if ( UCHAR(s[0]) == 'R' && s[1] == '_')
    {
        k = project_findObject(POLLUT, s+2);
        if ( k >= 0 ) return (Nobjects[POLLUT] + k + m);
    }
    return -1;
}
コード例 #10
0
ファイル: 1641.cpp プロジェクト: draak-krijger/timus
int main()
{
    int n, k, m;
    scanf("%d %d %d", &n, &k, &m);
    for(int i = 0; i < n; i++)
        printf("%d\n", room[i+1] = 1 + i % k);

    while(m > 0)
    {
        if(findmatch(n))
            m--;
        else
        {
            bool done = false;
            for(int i = 1; i <= n && !done; i++)
            {
                for(int j = i+1; j <= n && !done; j++)
                {
                    if(!c[i][j] && room[i] != room[j] && i != j)
                    {
                        printf("%d %d\n", i, j);
                        if(!--m)
                            done = true;
                    }
                        
                }
            }
        }
    }
    return 0;
}
コード例 #11
0
ファイル: rdii.cpp プロジェクト: Geosyntec/SUSTAIN
int readRdiiFileHeader()
//
//  Input:   none
//  Output:  returns error code
//  Purpose: reads header information from RDII file.
//
{
    int   i;
    char  line[MAXLINE+1];             // line from RDII data file
    char  s1[MAXLINE+1];               // general string variable
    char  s2[MAXLINE+1];         

    // --- check for correct file type
    fgets(line, MAXLINE, Frdii.file);
    sscanf(line, "%s", s1);
    if ( strcmp(s1, "SWMM5") != 0 ) return ERR_RDII_FILE_FORMAT;

    // --- skip title line
    fgets(line, MAXLINE, Frdii.file);

    // --- read RDII UH time step interval (sec)
    RdiiStep = 0;
    fgets(line, MAXLINE, Frdii.file);
    sscanf(line, "%d", &RdiiStep);
    if ( RdiiStep <= 0 ) return ERR_RDII_FILE_FORMAT;

    // --- skip over line with number of constituents (= 1 for RDII)
    fgets(line, MAXLINE, Frdii.file);

    // --- read flow units
    fgets(line, MAXLINE, Frdii.file);
    sscanf(line, "%s %s", s1, s2);
    RdiiFlowUnits = findmatch(s2, FlowUnitWords);
    if ( RdiiFlowUnits < 0 ) return ERR_RDII_FILE_FORMAT;

    // --- read number of RDII nodes
    fgets(line, MAXLINE, Frdii.file);
    if ( sscanf(line, "%d", &NumRdiiNodes) < 1 ) return ERR_RDII_FILE_FORMAT;

    // --- allocate memory for RdiiNodeIndex & RdiiNodeFlow arrays
    RdiiNodeIndex = (int *) calloc(NumRdiiNodes, sizeof(int));
    if ( !RdiiNodeIndex ) return ERR_MEMORY;
    RdiiNodeFlow = (float *) calloc(NumRdiiNodes, sizeof(float));
    if ( !RdiiNodeFlow ) return ERR_MEMORY;

    // --- read names of RDII nodes from file & save their indexes
    for ( i=0; i<NumRdiiNodes; i++ )
    {
        if ( feof(Frdii.file) ) return ERR_RDII_FILE_FORMAT;
        fgets(line, MAXLINE, Frdii.file);
        sscanf(line, "%s", s1);
        RdiiNodeIndex[i] = project_findObject(NODE, s1);
    }

    // --- skip column heading line
    if ( feof(Frdii.file) ) return ERR_RDII_FILE_FORMAT;
    fgets(line, MAXLINE, Frdii.file);
    return 0;
}
コード例 #12
0
ファイル: strings.c プロジェクト: walrus7521/code
int main()
{
    int f;
    char data[] = "sledbobber\0";
    
    f = findmatch("bob", data);
    if (f != -1) printf("found match at %d -> %s\n", f, &data[f]);
}
コード例 #13
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static void remote_filereq(int idx, char *from, char *file)
{
  char *p, what[256], dir[256], s[256], s1[256], *reject;
  FILE *f;
  filedb fdb;
  long i = 0;

  strcpy(what, file);
  p = strrchr(what, '/');
  if (p == NULL)
    dir[0] = 0;
  else {
    *p = 0;
    strcpy(dir, what);
    strcpy(what, p + 1);
  }
  f = filedb_open(dir, 0);
  reject = NULL;
  if (f == NULL) {
    reject = FILES_DIRDNE;
  } else {
    if (!findmatch(f, what, &i, &fdb)) {
      reject = FILES_FILEDNE;
      filedb_close(f);
    } else {
      if ((!(fdb.stat & FILE_SHARE)) ||
	  (fdb.stat & (FILE_HIDDEN | FILE_DIR))) {
	reject = FILES_NOSHARE;
	filedb_close(f);
      } else {
	filedb_close(f);
	/* copy to /tmp if needed */
	sprintf(s1, "%s%s%s%s", dccdir, dir, dir[0] ? "/" : "", what);
	if (copy_to_tmp) {
	  sprintf(s, "%s%s", tempdir, what);
	  copyfile(s1, s);
	} else
	  strcpy(s, s1);
	i = raw_dcc_send(s, "*remote", FILES_REMOTE, s);
	if (i > 0) {
	  wipe_tmp_filename(s, -1);
	  reject = FILES_SENDERR;
	}
      }
    }
  }
  simple_sprintf(s1, "%s:%s/%s", botnetnick, dir, what);
  if (reject) {
    botnet_send_filereject(idx, s1, from, reject);
    return;
  }
  /* grab info from dcc struct and bounce real request across net */
  i = dcc_total - 1;
  simple_sprintf(s, "%d %u %d", iptolong(getmyip()), dcc[i].port,
		dcc[i].u.xfer->length);
  botnet_send_filesend(idx, s1, from, s);
  putlog(LOG_FILES, "*", FILES_REMOTEREQ, dir, dir[0] ? "/" : "", what);
}
コード例 #14
0
int  getIfaceFilePolluts()
//
//  Input:   none
//  Output:  returns an error code
//  Purpose: reads names of pollutants saved on the inflows interface file.
//
{
    int   i, j;
    char  line[MAXLINE+1];             // line from inflows interface file
    char  s1[MAXLINE+1];               // general string variable
    char  s2[MAXLINE+1];         

    // --- read number of pollutants (minus FLOW)
    fgets(line, MAXLINE, Finflows.file);
    sscanf(line, "%d", &NumIfacePolluts);
    NumIfacePolluts--;
    if ( NumIfacePolluts < 0 ) return ERR_ROUTING_FILE_FORMAT;

    // --- read flow units
    fgets(line, MAXLINE, Finflows.file);
    sscanf(line, "%s %s", s1, s2);
    if ( !strcomp(s1, "FLOW") )  return ERR_ROUTING_FILE_FORMAT;
    IfaceFlowUnits = findmatch(s2, FlowUnitWords);
    if ( IfaceFlowUnits < 0 ) return ERR_ROUTING_FILE_FORMAT;


////  This section was moved out of the if (...) statement below it   ////     //(5.0.017 - LR)
////  so that not all pollutants have to be in the interface file.    ////     //(5.0.017 - LR)

    // --- allocate memory for pollutant index array
    if ( Nobjects[POLLUT] > 0 )
    {
        IfacePolluts = (int *) calloc(Nobjects[POLLUT], sizeof(int));
        if ( !IfacePolluts ) return ERR_MEMORY;
        for (i=0; i<Nobjects[POLLUT]; i++) IfacePolluts[i] = -1;
    }

    // --- read pollutant names & units
    if ( NumIfacePolluts > 0 )
    {
        // --- check each pollutant name on file with project's pollutants
        for (i=0; i<NumIfacePolluts; i++)
        {
            if ( feof(Finflows.file) ) return ERR_ROUTING_FILE_FORMAT;
            fgets(line, MAXLINE, Finflows.file);
            sscanf(line, "%s %s", s1, s2);
            if ( Nobjects[POLLUT] > 0 )
            {
                j = project_findObject(POLLUT, s1);
                if ( j < 0 ) continue;
                if ( !strcomp(s2, QualUnitsWords[Pollut[j].units]) )
                    return ERR_ROUTING_FILE_NOMATCH;
                IfacePolluts[j] = i;
            }
        }
    }
    return 0;
}
コード例 #15
0
ファイル: dirplex.c プロジェクト: dolda2000/ashd
static void handlefile(struct hthead *req, int fd, char *path)
{
    struct pattern *pat;

    if((pat = findmatch(path, 0, PT_FILE)) == NULL) {
	handle404(req, fd, path);
	return;
    }
    handle(req, fd, path, pat);
}
コード例 #16
0
ファイル: hpifru.c プロジェクト: openhpi1/testrepo
static int 
IsTagBmc(char *dstr, int dlen)
{
   int ret = 0;
   if (strncmp(dstr, bmctag, dlen) == 0)  /* Sahalee */
	ret = 1;
   else if (findmatch(dstr,dlen,"BMC",3,1) >= 0) /* mBMC or other */
	ret = 1;
   return(ret);
}
コード例 #17
0
ファイル: snow.c プロジェクト: HydroCouple/FVHMComponent
int snow_readMeltParams(Project* project, char* tok[], int ntoks)
//
//  Input:   tok[] = array of string tokens
//           ntoks = number of tokens
//  Output:  returns error code
//  Purpose: reads snow melt parameters from a tokenized line of input data.
//
//  Format of data are:
//   Name  SubArea   Cmin  Cmax  Tbase  FWF  SD0  FW0  SNN0/SD100
//	 Name  REMOVAL   SDplow Fout Fimperv Fperv Fimelt Fsubcatch (Subcatch)
//
{
    int i, j, k, m, n;
    double x[7];
    if ( ntoks < 8 ) return error_setInpError(ERR_ITEMS, "");

    // --- save snow melt parameter set name if not already done so
	j = project_findObject(project, SNOWMELT, tok[0]);
    if ( j < 0 ) return error_setInpError(ERR_NAME, tok[0]);
    if ( project->Snowmelt[j].ID == NULL )
		project->Snowmelt[j].ID = project_findID(project, SNOWMELT, tok[0]);

    // --- identify data keyword
    k = findmatch(tok[1], SnowmeltWords);
    if ( k < 0 ) return error_setInpError(ERR_KEYWORD, tok[1]);

    // --- number of parameters to read
    n = 7;                             // 7 for subareas
    if ( k == SNOW_REMOVAL ) n = 6;    // 6 for Removal
    if ( ntoks < n + 2 ) return error_setInpError(ERR_ITEMS, "");
    for (i=0; i<7; i++) x[i] = 0.0;

    // --- parse each parameter
    for (i=0; i<n; i++)
    {
        if ( ! getDouble(tok[i+2], &x[i]) )
            return error_setInpError(ERR_NUMBER, tok[i+2]);
    }

    // --- parse name of subcatch receiving snow plowed from current subcatch
    if ( k == SNOW_REMOVAL )
    {
        x[6] = -1.0;
        if ( ntoks >= 9 )
        {
			m = project_findObject(project, SUBCATCH, tok[8]);
            if ( m < 0 ) return error_setInpError(ERR_NAME, tok[8]);
            x[6] = m;
        }
    }

    // --- save snow melt parameters
	setMeltParams(project, j, k, x);
    return 0;
}
コード例 #18
0
ファイル: controls.c プロジェクト: iut-ibk/DynaVIBe
int  setActionSetting(char* tok[], int nToks, int* curve, int* tseries,        //(5.0.012 - LR)
                      int* attrib, double values[])                            //(5.0.012 - LR)
//
//  Input:   tok = array of string tokens containing action statement
//           nToks = number of string tokens
//  Output:  curve = index of controller curve
//           tseries = index of controller time series
//           attrib = r_PID if PID controller used                             //(5.0.012 - LR)
//           values = values of control settings                               //(5.0.012 - LR)
//           returns an error code
//  Purpose: identifies how control actions settings are determined.
//
{
    int k, m;

    // --- see if control action is determined by a Curve or Time Series
    if (nToks < 6) return error_setInpError(ERR_ITEMS, "");
    k = findmatch(tok[5], SettingTypeWords);
    if ( k >= 0 && nToks < 7 ) return error_setInpError(ERR_ITEMS, "");
    switch (k)
    {

    // --- control determined by a curve - find curve index
    case r_CURVE:
        m = project_findObject(CURVE, tok[6]);
        if ( m < 0 ) return error_setInpError(ERR_NAME, tok[6]);
        *curve = m;
        break;

    // --- control determined by a time series - find time series index
    case r_TIMESERIES:
        m = project_findObject(TSERIES, tok[6]);
        if ( m < 0 ) return error_setInpError(ERR_NAME, tok[6]);
        *tseries = m;
        Tseries[m].refersTo = CONTROL;                                         //(5.0.019 - LR)
        break;

    // --- control determined by PID controller                                //(5.0.012 - LR)
    case r_PID:                                                                //(5.0.012 - LR)
        if (nToks < 9) return error_setInpError(ERR_ITEMS, "");                //(5.0.012 - LR)
        for (m=6; m<=8; m++)                                                   //(5.0.012 - LR)
        {                                                                      //(5.0.012 - LR)
            if ( !getDouble(tok[m], &values[m-6]) )                            //(5.0.012 - LR)
                return error_setInpError(ERR_NUMBER, tok[m]);                  //(5.0.012 - LR)
        }                                                                      //(5.0.012 - LR)
        *attrib = r_PID;                                                       //(5.0.012 - LR)
        break;                                                                 //(5.0.012 - LR)

    // --- direct numerical control is used
    default:
        if ( !getDouble(tok[5], &values[0]) )                                  //(5.0.012 - LR)
            return error_setInpError(ERR_NUMBER, tok[5]);
    }
    return 0;
}
コード例 #19
0
ファイル: inpfile.c プロジェクト: asselapathirana/epanettools
void  saveauxdata(FILE *f)                                                     //(2.00.12 - LR)
/*
------------------------------------------------------------
  Writes auxilary data from original input file to new file.
------------------------------------------------------------
*/
{
   int   sect,newsect;
   char  *tok; 
   char  line[MAXLINE+1];
   char  s[MAXLINE+1];

   sect = -1;
   rewind(InFile);
   while (fgets(line,MAXLINE,InFile) != NULL)
   {
   /* Check if line begins with a new section heading */
      strcpy(s,line);
      tok = strtok(s,SEPSTR);
      if (tok != NULL && *tok == '[')
      {
         newsect = findmatch(tok,SectTxt);
         if (newsect >= 0)
         {
            sect = newsect;
            if (sect == _END) break;
            switch(sect)
            {
               case _RULES:
               case _COORDS:
               case _VERTICES:
               case _LABELS:
               case _BACKDROP:
               case _TAGS: fprintf(f, "%s", line);                             //(2.00.12 - LR)
            }
            continue;
         }
         else continue;
      }

   /* Write lines appearing in the section to file */
      switch(sect)
      {
          case _RULES:
          case _COORDS:
          case _VERTICES:
          case _LABELS:
          case _BACKDROP:
          case _TAGS: fprintf(f, "%s", line);                                  //(2.00.12 - LR)
      }
   }
}
コード例 #20
0
ファイル: gwater.c プロジェクト: HydroCouple/FVHMComponent
int  getVariableIndex(Project* project, char* s)
//
//  Input:   s = name of a groundwater variable
//  Output:  returns index of groundwater variable
//  Purpose: finds position of project->GW variable in list of project->GW variable names.
//
{
    int k;

    k = findmatch(s, GWVarWords);
    if ( k >= 0 ) return k;
    return -1;
}
コード例 #21
0
ファイル: gage.c プロジェクト: Giswater/giswater_models
int readGageFileFormat(char* tok[], int ntoks, double x[])
{
    int   m, u;
    DateTime aDate;
    DateTime aTime;

    // --- determine type of rain data
    m = findmatch(tok[1], RainTypeWords);
    if ( m < 0 ) return error_setInpError(ERR_KEYWORD, tok[1]);
    x[1] = (double)m;

    // --- get data time interval & convert to seconds
    if ( getDouble(tok[2], &x[2]) ) x[2] *= 3600;
    else if ( datetime_strToTime(tok[2], &aTime) )
    {
        x[2] = floor(aTime*SECperDAY + 0.5);
    }
    else return error_setInpError(ERR_DATETIME, tok[2]);
    if ( x[2] <= 0.0 ) return error_setInpError(ERR_DATETIME, tok[2]);

    // --- get snow catch deficiency factor
    if ( !getDouble(tok[3], &x[3]) )
        return error_setInpError(ERR_NUMBER, tok[3]);
 
    // --- get rain depth units
    u = findmatch(tok[7], RainUnitsWords);
    if ( u < 0 ) return error_setInpError(ERR_KEYWORD, tok[7]);
    x[6] = (double)u;

    // --- get start date (if present)
    if ( ntoks > 8 && *tok[8] != '*')
    {
        if ( !datetime_strToDate(tok[8], &aDate) )
            return error_setInpError(ERR_DATETIME, tok[8]);
        x[4] = (float) aDate;
    }
    return 0;
}
コード例 #22
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static int filedb_getgots(char *dir, char *fn)
{
  FILE *f;
  filedb fdb;
  long i = 0;

  f = filedb_open(dir, 0);
  if (!f)
    return 0;
  if (!findmatch(f, fn, &i, &fdb))
    fdb.gots = 0;
  filedb_close(f);
  return fdb.gots;
}
コード例 #23
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static void filedb_add(FILE * f, char *filename, char *nick)
{
  long where;
  filedb fdb;

  /* when the filedb was opened, a record was already created */
  where = 0;
  if (!findmatch(f, filename, &where, &fdb))
    return;
  strncpy(fdb.uploader, nick, HANDLEN);
  fdb.uploader[HANDLEN] = 0;
  fdb.uploaded = now;
  fseek(f, where, SEEK_SET);
  fwrite(&fdb, sizeof(filedb), 1, f);
}
コード例 #24
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static void filedb_getlink(char *dir, char *fn, char *link)
{
  FILE *f;
  filedb fdb;
  long i = 0;

  f = filedb_open(dir, 0);
  link[0] = 0;
  if (!f)
    return;
  if (findmatch(f, fn, &i, &fdb) && !(fdb.stat & FILE_DIR))
    strcpy(link, fdb.sharelink);
  filedb_close(f);
  return;
}
コード例 #25
0
ファイル: dirplex.c プロジェクト: dolda2000/ashd
static void handle404(struct hthead *req, int fd, char *path)
{
    struct child *ch;
    struct config *ccf;
    struct pattern *pat;
    
    char tmp[strlen(path) + 1];
    strcpy(tmp, path);
    if((pat = findmatch(tmp, 0, PT_NOTFOUND)) != NULL) {
	handle(req, fd, tmp, pat);
    } else {
	ch = findchild(tmp, ".notfound", &ccf);
	if(childhandle(ch, req, fd, chinit, ccf?ccf->path:NULL))
	    childerror(req, fd);
    }
}
コード例 #26
0
ファイル: pattern.cpp プロジェクト: ThatOtherPerson/dhc
std::shared_ptr<dhc::graft::match::match> dhc::graft::pattern::pattern::find(scanner::scanner &s)
{
    auto match = findmatch(s);

    if (match)
    {
        if (type != -1)
            match->type = type;

        if (process)
        {
            return process(match);
        }
    }

    return match;
}
コード例 #27
0
ファイル: nvram_rw.c プロジェクト: Antares84/asuswrt-merlin
int
bcmgpio_getpin(char *pin_name)
{
        char name[] = "gpioXXXX";
        char *val;
        uint pin;

        /* Go thru all possibilities till a match in pin name */
        for (pin = 0; pin < BCMGPIO_MAXPINS; pin ++) {
                sprintf(name, "gpio%d", pin);
                val = nvram_get(name);
                if (val && findmatch(val, pin_name))
                        return pin;
        }

        return -1;
}
コード例 #28
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static void filedb_setdesc(char *dir, char *fn, char *desc)
{
  FILE *f;
  filedb fdb;
  long where = 0;

  f = filedb_open(dir, 0);
  if (!f)
    return;
  if (findmatch(f, fn, &where, &fdb)) {
    strncpy(fdb.desc, desc, 185);
    fdb.desc[185] = 0;
    fseek(f, where, SEEK_SET);
    fwrite(&fdb, sizeof(filedb), 1, f);
  }
  filedb_close(f);
  return;
}
コード例 #29
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static void filedb_getdesc(char *dir, char *fn, char *desc)
{
  FILE *f;
  filedb fdb;
  long i = 0;

  f = filedb_open(dir, 0);
  if (!f) {
    desc[0] = 0;
    return;
  }
  if (!findmatch(f, fn, &i, &fdb))
    desc[0] = 0;
  else
    strcpy(desc, fdb.desc);
  filedb_close(f);
  return;
}
コード例 #30
0
ファイル: filedb.c プロジェクト: Estella/eggdrop-1.4
static void filedb_setowner(char *dir, char *fn, char *owner)
{
  FILE *f;
  filedb fdb;
  long where = 0;

  f = filedb_open(dir, 0);
  if (!f)
    return;
  if (findmatch(f, fn, &where, &fdb)) {
    strncpy(fdb.uploader, owner, HANDLEN);
    fdb.uploader[HANDLEN] = 0;
    fseek(f, where, SEEK_SET);
    fwrite(&fdb, sizeof(filedb), 1, f);
  }
  filedb_close(f);
  return;
}