コード例 #1
0
void readFile(char* filename){
    FILE* stream = fopen(filename, "r");

    // First extract the number of datapoints and their dimension
    char firstLine[1024];
    fgets(firstLine, 1024, stream);
    numDatapoints = atoi(getfield(strdup(firstLine), 1)); // num datapoints
    numDims = atoi(getfield(strdup(firstLine), 2)); // 

    // Allocate array to store matrix
    datapoints = allocMatrix(numDatapoints, numDims, 0);

    // Read the datapoints, one line at a time
    char line[1024];
    int row = 0;
    while (fgets(line, 1024, stream))
    {
		int column;
        for(column = 0; column < numDims; column++){
            char* tmp = strdup(line);
            double value;
            sscanf(getfield(tmp, column+1), "%lf", &value);
            datapoints[row][column] = value;
            free(tmp);
        }
        row++;
    }
}
コード例 #2
0
ファイル: zips.c プロジェクト: varunmved/CS46-Programs
int main()
{
  FILE* stream = fopen("homes200.csv", "r");
  //FILE* smallStream = fopen("smallWrong.txt","w");

    //creating a "fake hashtable" with an array
    //allows me to map each zip code to an index on the array
  char line[1024];
  char zipStr[10] ="";
  char addStr[50] ="";
  char col[] = " : ";
  int sqft;
  int i =0;

  while (fgets(line, 1024, stream))
  {
    char* tmp = strdup(line);
    char* tmp2 = strdup(line);
    char* tmp3 = strdup(line);

    strcpy(zipStr,getfield(tmp, 1));
    strcpy(addStr,getfield(tmp3, 3));
    strcat(addStr,"\n");
    
    int zip = atoi(zipStr);
    char* zipStr2 = strcat(zipStr,".txt");
    FILE* smallStream = fopen(zipStr2,"a");
    fprintf(smallStream,"%s",addStr);

  }

}
コード例 #3
0
ファイル: kdparse.c プロジェクト: Cloudxtreme/ircd-ratbox
void parse_d_file(FBFILE *file)
{
  struct ConfItem *aconf;
  char* reason_field=(char *)NULL;
  char* host_field=(char *)NULL;
  char  line[BUFSIZE];
  char* p;

  while (fbgets(line, sizeof(line), file))
    {
      if ((p = strchr(line, '\n')))
        *p = '\0';

      if ((*line == '\0') || (line[0] == '#'))
        continue;

      if ((host_field = getfield(line)) == NULL)
	continue;

      if ((reason_field = getfield(NULL)) == NULL)
	continue;
	  
      aconf = make_conf();
      aconf->status = CONF_DLINE;
      conf_add_fields(aconf,host_field,reason_field,"",0,NULL);
      conf_add_d_conf(aconf);
    }
}
コード例 #4
0
ファイル: kdparse.c プロジェクト: Cloudxtreme/ircd-ratbox
void
parse_k_file(FBFILE *file)
{
  struct ConfItem *aconf;
  char* user_field=(char *)NULL;
  char* reason_field=(char *)NULL;
  char* host_field=(char *)NULL;
  char  line[BUFSIZE];
  char* p;

  while (fbgets(line, sizeof(line), file))
    {
      if ((p = strchr(line, '\n')) != NULL)
        *p = '\0';

      if ((*line == '\0') || (*line == '#'))
        continue;

      if ((user_field = getfield(line)) == NULL)
	continue;

      if ((host_field = getfield(NULL)) == NULL)
	continue;

      if ((reason_field = getfield(NULL)) == NULL)
	continue;
	  
      aconf = make_conf();
      aconf->status = CONF_KILL;
      conf_add_fields(aconf,host_field,reason_field,user_field,0,NULL);

      if (aconf->host != NULL)
	add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
    }
}
コード例 #5
0
ファイル: kdparse.c プロジェクト: Cloudxtreme/ircd-ratbox
void
parse_resv_file(FBFILE *file)
{
  char *reason_field;
  char *host_field;
  char line[BUFSIZE];
  char *p;

  while(fbgets(line, sizeof(line), file))
  {
    if((p = strchr(line, '\n')))
      *p = '\0';

    if((*line == '\0') || (line[0] == '#'))
      continue;

    if((host_field = getfield(line)) == NULL)
      continue;

    if((reason_field = getfield(NULL)) == NULL)
      continue;

    if(IsChannelName(host_field))
      create_resv(host_field, reason_field, RESV_CHANNEL);
    else if(clean_resv_nick(host_field))
      create_resv(host_field, reason_field, RESV_NICK);
  }
}
コード例 #6
0
ファイル: join.c プロジェクト: vocho/openqnx
int compare (char *buf1, int field1, char *buf2, int field2)
{
	char *p1, *p2;
	int l1, l2, rc;

	DBG(fprintf(stderr, "compare: buf1='%s', field1=%d, buf2='%s', field2=%d\n",
                          buf1, field1, buf2, field2));

	p1 = getfield(buf1, field1, &l1);
	p2 = getfield(buf2, field2, &l2);


	DBG(fprintf(stderr, "compare: \"%-*s\" (%2d)  \"%-*s\" (%2d)  ", 
		l1, p1, l1, l2, p2, l2));

	for ( ; l1 && l2 && *p1 == *p2; ++p1, ++p2, --l1, --l2)
		;

	if (l1 == 0 && l2 == 0)
		rc = 0;
	else if (l1 == 0)
		rc = -1;
	else if (l2 == 0)
		rc = 1;
	else 
		rc = (*p1 - *p2) < 0 ? -1 : 1;

	DBG(fprintf(stderr, "match=%d\n", rc));

	return rc;
}
コード例 #7
0
ファイル: regtwoblb.c プロジェクト: mokiss/sxshao
void regtwosamp(char **file1, char **file2, int *yindex, int *xindex ,double *sum, 
  double *square, double *interx, double *interxy, 
 int *samp, int *weight, int *stop, int *n){
 FILE *stream1 = fopen(*file1, "r");
 FILE *stream2 = fopen(*file2,  "r");
 char line1[1024], line2[1024];
 int i=0,j=0;
while( fgets(line1, 1024, stream1) && fgets(line2, 1024, stream2))
 { 
    if(i>0 && i == samp[j] ){
     char *tmp1 = strdup(line1), *tmp2 = strdup(line2);
     double x1,x2,y;
     y = getdif(tmp2, yindex[0],yindex[1]);
     x1 = getfield(tmp1, xindex[0]);
     x2 = getfield(tmp2, xindex[1]);
     sum[0] = sum[0] + x1*weight[j];
     sum[1] = sum[1] + x2*weight[j];
     sum[2] = sum[2] + y*weight[j];
     square[0] = square[0] + x1*x1*weight[j];
     square[1] = square[1] + x2*x2*weight[j];
     interx[0] = interx[0] + x1*x2*weight[j];
     interxy[0] = interxy[0] + x1*y*weight[j];
     interxy[1] = interxy[1] + x2*y*weight[j];
     free(tmp1);free(tmp2);
     j++;
    };

    i++;
 }
 *stop = j;
 *n = i;
}
コード例 #8
0
void
parse_d_file(FILE * file)
{
	struct ConfItem *aconf;
	char *reason_field = NULL;
	char *host_field = NULL;
	char *operreason_field = NULL;
	char line[BUFSIZE];
	char *p;

	while (fgets(line, sizeof(line), file))
	{
		if((p = strpbrk(line, "\r\n")))
			*p = '\0';

		if((*line == '\0') || (line[0] == '#'))
			continue;

		host_field = getfield(line);
		if(EmptyString(host_field))
			continue;

		reason_field = getfield(NULL);
		if(EmptyString(reason_field))
			continue;

		operreason_field = getfield(NULL);

		aconf = make_conf();
		aconf->status = CONF_DLINE;
		conf_add_fields(aconf, host_field, reason_field, "", operreason_field);
		conf_add_d_conf(aconf);
	}
}
コード例 #9
0
ファイル: main_1.c プロジェクト: openETCS/srcAndBinary
int main(int argc, char **argv)
{
	if (access("train_input.csv" , F_OK ) != -1 ) { 
		//FILE* stream = fopen("train_input.csv", "r");
	} else {
		printf("Input file does not exist. This program expects train_input.csv in the same folder\n");
		return 0;
	}
	//SCADE reset function call
	Amsterdam_Utrecht_reset_US_Integration_June();
	
	FILE* stream = fopen("train_input.csv", "r");
	char line[1024];
	int cycle = 0;
	while (fgets(line, 1024, stream))
	{
		cycle++;
		printf("Cycle %d : ", cycle);
        	char* tmp = strdup(line); //strok trashes line, hence repeated tmp use for each call to getfield 
		TrainPos = atof( getfield(tmp, 1) );
		printf("Train_pos %f : ", TrainPos);
        	tmp = strdup(line); //strok trashes line, hence repeated tmp use  for each call to getfield
		Trigger_in = atoi( getfield(tmp, 2) );
		printf("Trigger_in %d\n", Trigger_in);
		Amsterdam_Utrecht_US_Integration_June();
        	free(tmp);
	}
	printf("Execution of %d cycles complete\n" , cycle);
	return 0;
}
コード例 #10
0
struct Info parse_line(char* line){
	struct Info inv;
	
	char* id = strdup(line);
	char* surname = strdup(line);
	char* firstname = strdup(line);		
	char* department = strdup(line);
	char* age = strdup(line);
	
	//ID
	inv.ID = atoi(getfield(id, 1));
	//firstname
	sscanf(getfield(firstname, 2), "%s", inv.Firstname);
	//surname
	sscanf(getfield(surname, 3), "%s", inv.Surname);
	//department
	sscanf(getfield(department, 4), "%s", inv.Department);
	//age
	inv.Age = atoi(getfield(age, 5));
	
	free(id);
	free(surname);
	free(firstname);
	free(department);
	free(age);
	return inv;
}
コード例 #11
0
ファイル: convertklines.c プロジェクト: Codyle/elemental-ircd
static void parse(FILE *outkline, FILE *outdline, char* line)
{
	char conf_letter;
	char *tmp;
	const char *user_field = NULL;
	const char *passwd_field = NULL;
	const char *host_field = NULL;
	const char *operpasswd_field = NULL;
	tmp = getfield(line);
	conf_letter = *tmp;
	for (;;) { /* Fake loop, that I can use break here --msa */
		/* host field */
		if ((host_field = getfield(NULL)) == NULL)
			return;
		/* pass field */
		if ((passwd_field = getfield(NULL)) == NULL)
			break;
		else {
			/* if theres a password, try splitting the operreason out */
			char *p;
			if ((p = strchr(passwd_field, '|'))) {
				*p++ = '\0';
				operpasswd_field = p;
			} else
				operpasswd_field = "";
		}
		/* user field */
		if ((user_field = getfield(NULL)) == NULL)
			break;
		/* what could possibly be after a userfield? */
		break;
	}
	if (!passwd_field) {
		passwd_field = "";
		operpasswd_field = "";
	}
	if (!user_field)
		user_field = "";
	switch (conf_letter) {
		case 'd':
			fprintf(stderr, "exempt in old file, ignoring.\n");
			break;
		case 'D': /* Deny lines (immediate refusal) */
			if (host_field && passwd_field)
				fprintf(outdline, "\"%s\",\"%s\",\"%s\",\"\",\"Unknown\",0\n",
				        host_field, passwd_field, operpasswd_field);
			break;
		case 'K': /* Kill user line on irc.conf           */
		case 'k':
			if (host_field && passwd_field && user_field)
				fprintf(outkline, "\"%s\",\"%s\",\"%s\",\"%s\",\"\",\"Unknown\",0\n",
				        user_field, host_field, passwd_field, operpasswd_field);
			break;
		default:
			fprintf(stderr, "Error in config file: %s", line);
			break;
	}
}
コード例 #12
0
ファイル: process_xml.c プロジェクト: gc3-uzh-ch/ganglia
/* Write a metric summary value to the RRD database. */
static int
finish_processing_source(datum_t *key, datum_t *val, void *arg)
{
   xmldata_t *xmldata = (xmldata_t *) arg;
   char *name, *type;
   char sum[512];
   char num[256];
   Metric_t *metric;
   struct type_tag *tt;
   llist_entry *le;

   name = (char*) key->data;
   metric = (Metric_t*) val->data;
   type = getfield(metric->strings, metric->type);

   /* Don't save to RRD if the datasource is dead or write_rrds is off */
   if( xmldata->ds->dead || gmetad_config.write_rrds != 1)
      return 1;

   tt = in_type_list(type, strlen(type));
   if (!tt) return 0;

   /* Don't save to RRD if this is a metric not to be summarized */
   if (llist_search(&(gmetad_config.unsummarized_metrics), (void *)name, llist_strncmp, &le) == 0)
      return 0;

   switch (tt->type)
      {
         case INT:
         case UINT:
            sprintf(sum, "%.f", metric->val.d);
            break;
         case FLOAT:
            sprintf(sum, "%.*f", (int) metric->precision, metric->val.d);
            break;
         default:
            break;
      }
   sprintf(num, "%u", metric->num);

   /* Save the data to a round robin database if this data source is 
    * alive. */
   if (!xmldata->ds->dead && !xmldata->rval)
     {

       debug_msg("Writing Summary data for source %s, metric %s",
                 xmldata->sourcename, name);

       xmldata->rval = write_data_to_rrd(xmldata->sourcename, NULL, name,
                                         sum, num, xmldata->ds->step,
                                         xmldata->source.localtime,
                                         cstr_to_slope(getfield(metric->strings, metric->slope)));
     }

   return xmldata->rval;
}
コード例 #13
0
ファイル: str_util.cpp プロジェクト: ericchu30/Colossal
int main()
{
	const char *str =
		" hello  world string ___GARBAGE___";
	char field[6];
	char large[100];
	assert(getfield(str, str, 0, field, 0, ' ') == str);
	assert(getfield(str, str + strlen(str), 0, NULL, 0, ' ') == str);
	assert(getfield(str, str + strlen(str), 1, NULL, sizeof(field), ' ') == str + 1);
	assert(getfield(str, str + strlen(str), 1, field, sizeof(field), ' ') == str + 1);
	assert(strcmp(field, "hello") == 0);
	assert(getfield(str, str + strlen(str), 2, field, sizeof(field), ' ') == str + 7);
	assert(field[0] == 0);
	assert(getfield(str, str + strlen(str), 4, field, sizeof(field), ' ') == str + 14);
	assert(strcmp(field, "strin") == 0);  // yes, "strin" without 'g'
	assert(getfield(str, str + strlen(str), 5, field, sizeof(field), ' ') == str + 21);
	assert(getfield(str, str + strlen(str), 5, large, sizeof(large), ' ') == str + 21);
	assert(strcmp(large, "___GARBAGE___") == 0);
	assert(getfield(str, str + strlen(str), 6, field, sizeof(field), ' ') == str + strlen(str));
	assert(regex_match("hello .", "^hello") == 1);
	assert(regex_match("0hello .", "^hello") == 0);
	assert(regex_match("seal man zeroxsssskd.", "o.*x.*kd") == 1);
	assert(regex_match("", ".*.*.*") == 1);
	printf("passed\n");

	return 0;
}
コード例 #14
0
void
parse_resv_file(FILE * file)
{
	struct ConfItem *aconf;
	char *reason_field;
	char *host_field;
	char line[BUFSIZE];
	char *p;

	while (fgets(line, sizeof(line), file))
	{
		if((p = strpbrk(line, "\r\n")))
			*p = '\0';

		if((*line == '\0') || (line[0] == '#'))
			continue;

		host_field = getfield(line);
		if(EmptyString(host_field))
			continue;

		reason_field = getfield(NULL);
		if(EmptyString(reason_field))
			continue;

		if(IsChannelName(host_field))
		{
			if(hash_find_resv(host_field))
				continue;

			aconf = make_conf();
			aconf->status = CONF_RESV_CHANNEL;
			aconf->port = 0;

			DupString(aconf->name, host_field);
			DupString(aconf->passwd, reason_field);
			add_to_resv_hash(aconf->name, aconf);
		}
		else if(clean_resv_nick(host_field))
		{
			if(find_nick_resv(host_field))
				continue;

			aconf = make_conf();
			aconf->status = CONF_RESV_NICK;
			aconf->port = 0;

			DupString(aconf->name, host_field);
			DupString(aconf->passwd, reason_field);
			dlinkAddAlloc(aconf, &resv_conf_list);
		}
	}
}
コード例 #15
0
static int
write_root_summary(datum_t *key, datum_t *val, void *arg)
{
   char *name, *type;
   char sum[256];
   char num[256];
   Metric_t *metric;
   int rc;
   struct type_tag *tt;
   llist_entry *le;
   char *p;

   name = (char*) key->data;
   metric = (Metric_t*) val->data;
   type = getfield(metric->strings, metric->type);

   /* Summarize all numeric metrics */
   tt = in_type_list(type, strlen(type));
   /* Don't write a summary for an unknown or STRING type */
   if (!tt || (tt->type == STRING))
       return 0;

   /* Don't write a summary for metrics not to be summarized */
   if (llist_search(&(gmetad_config.unsummarized_metrics), (void *)key->data, llist_strncmp, &le) == 0)
       return 0;

   /* Don't write a summary for metris that appears to be sFlow VM metrics */
   if (gmetad_config.unsummarized_sflow_vm_metrics && (p = strchr(name, '.')) != NULL && *(p+1) == 'v')
     return 0;

   ganglia_scoreboard_inc(METS_SUMRZ_ROOT);
   /* We log all our sums in double which does not suffer from
      wraparound errors: for example memory KB exceeding 4TB. -twitham */
   sprintf(sum, "%.5f", metric->val.d);

   sprintf(num, "%u", metric->num);

   /* err_msg("Writing Overall Summary for metric %s (%s)", name, sum); */

   /* Save the data to a rrd file unless write_rrds == off */
	 if (gmetad_config.write_rrds == 0)
	     return 0;

   debug_msg("Writing Root Summary data for metric %s", name);

   rc = write_data_to_rrd( NULL, NULL, name, sum, num, 15, 0,
      cstr_to_slope(getfield(metric->strings, metric->slope)));
   if (rc)
      {
         err_msg("Unable to write meta data for metric %s to RRD", name);
      }
   return 0;
}
コード例 #16
0
ファイル: test-uninames.c プロジェクト: AdeebNqo/poedit
/* Stores in unicode_names[] the relevant contents of the UnicodeData.txt
   file.  */
static void
fill_names (const char *unicodedata_filename)
{
  unsigned int i;
  FILE *stream;
  char field0[FIELDLEN];
  char field1[FIELDLEN];
  int lineno = 0;

  for (i = 0; i < 0x110000; i++)
    unicode_names[i] = NULL;

  stream = fopen (unicodedata_filename, "r");
  if (stream == NULL)
    {
      fprintf (stderr, "error during fopen of '%s'\n", unicodedata_filename);
      exit (EXIT_FAILURE);
    }

  for (;;)
    {
      int n;
      int c;

      lineno++;
      n = getfield (stream, field0, ';');
      n += getfield (stream, field1, ';');
      if (n == 0)
        break;
      if (n != 2)
        {
          fprintf (stderr, "short line in '%s':%d\n",
                   unicodedata_filename, lineno);
          exit (EXIT_FAILURE);
        }
      for (; (c = getc (stream)), (c != EOF && c != '\n'); )
        ;
      i = strtoul (field0, NULL, 16);
      if (i >= 0x110000)
        {
          fprintf (stderr, "index too large\n");
          exit (EXIT_FAILURE);
        }
      unicode_names[i] = xstrdup (field1);
    }
  if (ferror (stream) || fclose (stream))
    {
      fprintf (stderr, "error reading from '%s'\n", unicodedata_filename);
      exit (1);
    }
}
コード例 #17
0
const char* translator(const char* word)
//int main(int argc, char* argv[])
{
	/*if (argc == 3)			Encryption (not needed?)
	{
		if(strcmp(argv[1], "encrypt") == 0)
		{
			char* tmp = malloc(sizeof(char)*2000);
			sprintf(tmp, "openssl aes-256-cbc -in %s -out %s.enc -pass pass:§acf578?#*+-463-{{}av@wer637,,..", argv[2], argv[2]);
			popen(tmp, "w");
			return 0;		
		}
		else if(strcmp(argv[1], "decrypt")==0)
		{*/

		
	char* randName = randstring(15);
	FILE* f = NULL;
	char* tmp = malloc(sizeof(char)*2000);
	char* remove = malloc(sizeof(char)*200);
	sprintf(tmp, "openssl aes-256-cbc -d -in Bayrisch.csv.enc -out %s -pass pass:§acf578?#*+-463-{{}av@wer637,,..", randName);
	f = popen(tmp, "w");
	pclose(f);
	FILE* output=fopen(randName, "r");
	char* encryptedData[1500];
	int i = 0;
	int p = 1;
	char* result = malloc(128);
	memset(result, 0, strlen(result));
	encryptedData[0] = malloc(sizeof(char)*500);
	char line[1024];
	while(fgets(line, 1024, output)!=NULL)
	{
		char* tmp = strdup(line);
		if(strcmp(getfield(tmp, 1), word) == 0)
		{
			strcpy(tmp, line);
			sprintf(result,"The word %s means %s\n", word, getfield(tmp,2));
		}
		sprintf(encryptedData[i], "%s", line); 
		i++;
		encryptedData[i] = malloc(sizeof(char)*500);
		free(tmp);
	}
	if(strlen(result) == 0)
		sprintf(result, "Sorry we couldn't find that word\n");
	/* give result to the next function */
	sprintf(remove, "rm %s", randName);
	popen(remove, "w");
	return result;
}
コード例 #18
0
int main(int argc, const char* argv[])
{
	FILE* fstream = fopen(argv[1], "r");
	FILE* ostream = fopen(argv[2], "wb");
	char line[1024];
	char buf[1024];
	int lines = countlines(argv[1]);
	printf("the file contains %d lines!\n", lines);
	struct Info *ptr;
	ptr = malloc(sizeof(struct Info) * lines);
	memset(ptr, 0, sizeof(struct Info) * lines);
	size_t i = 0;
	
	while(fgets(line, 1024, fstream)){
		char* id = strdup(line);
		char* surname = strdup(line);
		char* firstname = strdup(line);
		char* department = strdup(line);
		char* age = strdup(line);

		ptr[i].ID = atoi(getfield(id, 1));
		sscanf(getfield(firstname, 2), "%s", ptr[i].Firstname);
		sscanf(getfield(surname, 3), "%s", ptr[i].Surname);
		sscanf(getfield(department, 4), "%s", ptr[i].Department);
		ptr[i].Age = atoi(getfield(age, 5));
		
		printf("the ID is %d\n", ptr[i].ID);
		printf("the name is %s\n", ptr[i].Firstname);
		printf("the surname is %s\n", ptr[i].Surname);
		printf("the age is %d\n", ptr[i].Age);
		printf("the ID is %u\n", htonl(ptr[i].ID));
		
		fprintf(ostream, "%u\n", htonl(ptr[i].ID));
		printchar2bin(ptr[i].Firstname, sizeof(ptr[i].Firstname), ostream);
		printchar2bin(ptr[i].Surname, sizeof(ptr[i].Surname), ostream);
		printchar2bin(ptr[i].Department, sizeof(ptr[i].Department), ostream);
		fprintf(ostream, "%u\n", htonl(ptr[i].Age));

		++i;
		free(id);
		free(surname);
		free(firstname);
		free(department);
		free(age);
	}
	fclose(fstream);
	fclose(ostream);
	return 0;
}
コード例 #19
0
ファイル: Login.c プロジェクト: rishabt/COMP206_FinalProject
int main(void)
{
	    char *lenstr;
	    char input[MAXINPUT], data[MAXINPUT];
	    long len;
	    const char* uname;

	    printf("%s%c%c\n",
			    "Content-Type:text/html;charset=iso-8859-1",13,10);
	    printf("<TITLE>Response</TITLE>\n");

	    lenstr = getenv("CONTENT_LENGTH");
	    if(lenstr == NULL || sscanf(lenstr,"%ld",&len)!=1 || len > MAXLEN)
		      printf("<P>Error in invocation - wrong FORM probably.");
	    else {
		fgets(input, len+1, stdin);
		unencode(input+EXTRA, input+len, data);
		const char* in_pass = getfield(&data[0], 3);
		const char* in_user = getfield(&data[0], 1);
		uname = in_user;
		int found = 0;

		FILE* file = fopen(DATAFILE, "r");
		char line[256];
            	while (fgets(line, sizeof(line), file)) {

			char* tmp1 = strdup(line);
			const char* pass = getfield(line, 3);

			const char* user = getfield(tmp1, 2);

			if(strcmp(user, in_user) == 0){
				if(strcmp(pass, in_pass) == 0){
					found = 1;
					break;
				}
			}
	    	}

		fclose(file);

		if(found == 1){
			printf("<p>Logged in!");
			printf("<form action=\"http://cgi.cs.mcgill.ca/~rtando1/cgi-bin/MyFacebookPage.py\" METHOD=\"POST\"><input type=\"hidden\" name=\"username\" value=\"%s\"><INPUT TYPE=\"SUBMIT\" VALUE=\"Go to your profile\" NAME=\"pass\"></form>", uname);	
		}
	    }

            return 0;
}
コード例 #20
0
ファイル: rcalc.c プロジェクト: Pizookies/Radiance
static int
getrec(void)				/* get next record from file */
{
	int  eatline;
	register struct field  *f;

	while (ipb.chr != EOF) {
		if (blnkeq) {		/* beware of nbsynch() */
			while (isblnk(ipb.chr))
				resetinp();
			if (ipb.chr == EOF)
				return(0);
		}
		eatline = (!igneol && ipb.chr != '\n');
		clearrec();		/* start with fresh record */
		for (f = inpfmt; f != NULL; f = f->next)
			if (getfield(f) == -1)
				break;
		if (f == NULL) {
			advinp();       /* got one! */
			return(1);
		}
		resetinp();		/* eat false start */
		if (eatline) {          /* eat rest of line */
			while (ipb.chr != '\n') {
				if (ipb.chr == EOF)
					return(0);
				resetinp();
			}
			resetinp();
		}
	}
	return(0);
}
コード例 #21
0
ファイル: bags.cpp プロジェクト: Soltero/reenigne
void updatebag(Sint4 bag)
{
  Sint4 x,h,xr,y,v,yr,wbl;
  x=bagdat[bag].x;
  h=bagdat[bag].h;
  xr=bagdat[bag].xr;
  y=bagdat[bag].y;
  v=bagdat[bag].v;
  yr=bagdat[bag].yr;
  switch (bagdat[bag].dir) {
    case DIR_NONE:
      if (y<180 && xr==0) {
        if (bagdat[bag].wobbling) {
          if (bagdat[bag].wt==0) {
            bagdat[bag].dir=DIR_DOWN;
            soundfall();
            break;
          }
          bagdat[bag].wt--;
          wbl=bagdat[bag].wt%8;
          if (!(wbl&1)) {
            drawgold(bag,wblanim[wbl>>1],x,y);
            incpenalty();
            soundwobble();
          }
        }
        else
          if ((getfield(h,v+1)&0xfdf)!=0xfdf)
            if (!checkdiggerunderbag(h,v+1))
              bagdat[bag].wobbling=TRUE;
      }
コード例 #22
0
ファイル: list.c プロジェクト: ksandeep/decaf_labs
entry sum_35() {
new_env(1, 0);
ildc(0);
load();
null();
oequal();
jz(label2);
ildc(0);
ret();
jmp(label3);
label2:
ildc(0);
load();
call(get_element_29);
ildc(0);
load();
ildc(1);
getfield();
call(sum_35);
iadd();
ret();
label3:
null();
ret();
}
コード例 #23
0
ファイル: server.c プロジェクト: tstarling/monitor-core
/* These are a bit different since they always need to go out. */
int
root_report_start(client_t *client)
{
    int rc;

    if (client->http)
    {
        rc = xml_print(client, "HTTP/1.0 200 OK\r\n"
                       "Server: gmetad/" GANGLIA_VERSION_FULL "\r\n"
                       "Content-Type: application/xml\r\n"
                       "Connection: close\r\n"
                       "\r\n");
        if (rc)
            return rc;
    }

    rc = xml_print(client, DTD);
    if (rc) return 1;

    rc = xml_print(client, "<GANGLIA_XML VERSION=\"%s\" SOURCE=\"gmetad\">\n",
                   VERSION);

    rc = xml_print(client, "<GRID NAME=\"%s\" AUTHORITY=\"%s\" LOCALTIME=\"%u\">\n",
                   gmetad_config.gridname, getfield(root.strings, root.authority_ptr),
                   (unsigned int) time(0));

    return rc;
}
コード例 #24
0
ファイル: feed.c プロジェクト: pmyadlowsky/mash
static int stop_feed(lua_State *lstate) {
	FEED *feed;
	getfield(lstate, "intern");
	feed = (FEED *)lua_touserdata(lstate, -1);
	feed->running = 0;
	lua_pop(lstate, 2);
	return 0;
	}
コード例 #25
0
ファイル: gen.c プロジェクト: pmyadlowsky/mash
static int gen_stop(lua_State *lstate) {
	GEN *gen;
	getfield(lstate, "intern");
	gen = (GEN *)lua_touserdata(lstate, -1);
	gen->running = 0;
	lua_pop(lstate, 2);
	return 0;
	}
コード例 #26
0
ファイル: address.c プロジェクト: daniw/mc
/**
 * Function to sort the Linked List
 * This function sorts according to the field given as enum
 * @param n Pointer to the first element
 * @param field field to sort for
 */
void sortaddress(nodePtr_t n, fields_t field)
{
    int s = getsize();
    int i = 0;
    int j = 0;
    nodePtr_t t = getfirst();
    nodePtr_t* a = (nodePtr_t) malloc(s * sizeof(nodePtr_t));
    
    // Preparing array to sort
    for(i = 0; i < s; i++)
    {
        a[i] = t;
        t = getnext(t);
    }
    
    // Sorting the prepared array
    for(i = 0; i < (s); i++)
    {
        for(j = 0; j < (s - i - 1); j++)
        {
            if(strcmp(getfield(a[j], field), getfield(a[j+1], field)))
            {
                t = a[j];
                a[j] = a[j + 1];
                a[j + 1] = t;
            }
        }
    }
    
    // Order data according to sorted array
    head = a[0];
    tail = a[s-1];
    a[0]->prev = NULL;
    a[0]->next = a[1];
    a[s-1]->next = NULL;
    a[s-1]->prev = a[s-2];
    for(i = 1; i < (s - 1); i++)
    {
        a[i]->next = a[i+1];
        a[i]->prev = a[i-1];
    }

    return;
}
コード例 #27
0
ファイル: compat-5.1.c プロジェクト: BOBYou/ntopng
LUALIB_API void luaL_module(lua_State *L, const char *libname,
                              const luaL_reg *l, int nup) {
  if (libname) {
    getfield(L, LUA_GLOBALSINDEX, libname);  /* check whether lib already exists */
    if (lua_isnil(L, -1)) { 
      int env, ns;
      lua_pop(L, 1); /* get rid of nil */
      lua_pushliteral(L, "require");
      lua_gettable(L, LUA_GLOBALSINDEX); /* look for require */
      lua_getfenv(L, -1); /* getfenv(require) */
      lua_remove(L, -2); /* remove function require */
      env = lua_gettop(L);

      lua_newtable(L); /* create namespace for lib */
      ns = lua_gettop(L);
      getfield(L, env, "package.loaded"); /* get package.loaded table */
      if (lua_isnil(L, -1)) { /* create package.loaded table */
          lua_pop(L, 1); /* remove previous result */
          lua_newtable(L);
          lua_pushvalue(L, -1);
          setfield(L, env, "package.loaded");
      }
      else if (!lua_istable(L, -1))
        luaL_error(L, "name conflict for library `%s'", libname);
      lua_pushstring(L, libname);
      lua_pushvalue(L, ns); 
      lua_settable(L, -3); /* package.loaded[libname] = ns */
      lua_pop(L, 1); /* get rid of package.loaded table */
      lua_pushvalue(L, ns); /* copy namespace */
      setfield(L, LUA_GLOBALSINDEX, libname);
      lua_remove (L, env); /* remove env */
    }
    lua_insert(L, -(nup+1));  /* move library table to below upvalues */
  }
  for (; l->name; l++) {
    int i;
    lua_pushstring(L, l->name);
    for (i=0; i<nup; i++)  /* copy upvalues to the top */
      lua_pushvalue(L, -(nup+1));
    lua_pushcclosure(L, l->func, nup);
    lua_settable(L, -(nup+3));
  }
  lua_pop(L, nup);  /* remove upvalues */
}
コード例 #28
0
ファイル: list.c プロジェクト: ksandeep/decaf_labs
entry pop_front_33() {
new_env(1, 0);
ildc(0);
load();
ildc(1);
getfield();
ret();
null();
ret();
}
コード例 #29
0
ファイル: list.c プロジェクト: ksandeep/decaf_labs
entry get_element_29() {
new_env(1, 0);
ildc(0);
load();
ildc(0);
getfield();
ret();
null();
ret();
}
コード例 #30
0
void
parse_k_file(FILE * file)
{
	struct ConfItem *aconf;
	char *user_field = NULL;
	char *reason_field = NULL;
	char *operreason_field = NULL;
	char *host_field = NULL;
	char line[BUFSIZE];
	char *p;

	while (fgets(line, sizeof(line), file))
	{
		if((p = strpbrk(line, "\r\n")) != NULL)
			*p = '\0';

		if((*line == '\0') || (*line == '#'))
			continue;

		user_field = getfield(line);
		if(EmptyString(user_field))
			continue;

		host_field = getfield(NULL);
		if(EmptyString(host_field))
			continue;

		reason_field = getfield(NULL);
		if(EmptyString(reason_field))
			continue;

		operreason_field = getfield(NULL);

		aconf = make_conf();
		aconf->status = CONF_KILL;
		conf_add_fields(aconf, host_field, reason_field,
				user_field, operreason_field);

		if(aconf->host != NULL)
			add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
	}
}