Beispiel #1
0
void
analyse_function(Function *f, sym_table *prog, char *scope_id, int line_no) {
    //Find the scope of the function
    scope *called = find_scope(f->id, prog);

    //Find the scope
    if (!called) {
        //Ooops this is an error. Report it.
        print_undefined_proc_call_error(f, line_no);
        isValid = FALSE;
        return;
    }

    Params *fcallee = (Params *) called->params;
    Exprs *fcaller = f->args;
    //Check number of variables
    int call_no = count_list((void *)fcaller);
    int expect_no = count_list((void *)fcallee);

    if (call_no != expect_no) {
        print_func_pmismatch_error(f, fcallee, line_no, expect_no, call_no);
        isValid = FALSE;
    } else {
        //Go through each variable and try match. We know these are the same
        //lenght now.
        int par_num = 1;
        while (fcallee != NULL) {
            Expr *e = fcaller->first;
            Param *p = fcallee->first;
            Type caller = get_expr_type(e, NULL, prog, scope_id, line_no);
            if (caller != p->type && p->ind == VAL_IND) {
                if ((caller == INT_TYPE) && (p->type == FLOAT_TYPE)) {
                    // This is valid, we can cast an int val into a float val
                } else {
                    //Then the parameter calls are incorrect
                    print_func_ptype_error(par_num, caller,
                                           p->type, f, line_no);
                    isValid = FALSE;
                }
            } else if (caller != p->type && p->ind == REF_IND) {
                if ((caller == FLOAT_TYPE) && (p->type == INT_TYPE)) {
                    // This is valid, we can cast an int into a float to store
                    // in the ref.
                } else {
                    //Then the parameter calls are incorrect
                    print_func_ptype_error(par_num, caller,
                                           p->type, f, line_no);
                    isValid = FALSE;
                }
            } else if (caller != p->type && caller != INVALID_TYPE) {
                //Then the parameter calls are incorrect
                print_func_ptype_error(par_num, caller, p->type, f, line_no);
                isValid = FALSE;
            }
            fcallee = fcallee->rest;
            fcaller = fcaller->rest;
            par_num ++;
        }
    }
}
Beispiel #2
0
write_hooks (FILE *inf, FILE *outf)
{
  char *p, buf[1024];
  struct id *newid;

  struct id *constructors = 0;
  struct id *destructors = 0;

  while (! feof (inf)) {

    /* Read a line of nm output and strip the trailing newline. */

    fgets (buf, sizeof buf, inf);
    p = buf + strlen (buf) - 1;
    if (*p == '\n')
      *p = '\0';

    /* If it contains a constructor or destructor name, add the name
       to the appropriate list. */

    for (p = buf; *p; p++)
      {
	while (*p && *p != '_')
	  p++;
	if (! strncmp (p, "_GLOBAL_$I$", 11))
	  {
	    newid = alloca (sizeof *newid);
	    newid->name = alloca (strlen (p) + 1);
	    strcpy (newid->name, p);
	    newid->next = constructors;
	    constructors = newid;
	    break;
	  }
	else if (! strncmp (p, "_GLOBAL_$D$", 11))
	  {
	    newid = alloca (sizeof *newid);
	    newid->name = alloca (strlen (p) + 1);
	    strcpy (newid->name, p);
	    newid->next = destructors;
	    destructors = newid;
	    break;
	  }
      }
  }

  /* Write the tables. */

  fprintf (outf, "%s\n", TEXT_SECTION_ASM_OP);
  ASM_GLOBALIZE_LABEL (outf, "__CTOR_LIST__");
  ASM_OUTPUT_LABEL (outf, "__CTOR_LIST__");
  ASM_OUTPUT_INT (outf, count_list (constructors));
  write_list (outf, constructors);
  
  fprintf (outf, "%s\n", DATA_SECTION_ASM_OP);
  ASM_GLOBALIZE_LABEL (outf, "__DTOR_LIST__");
  ASM_OUTPUT_LABEL (outf, "__DTOR_LIST__");
  ASM_OUTPUT_INT (outf, count_list (destructors));
  write_list (outf, destructors);
  ASM_OUTPUT_INT (outf, 0);
}
Beispiel #3
0
static long procinfo_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
#endif
{
    procinfo_t info;
    procinfo_arg_t *info_arg;
    struct task_struct *task;
    pid_t pid;

    switch (cmd) {
        case GET_PROCINFO:
            info_arg = (procinfo_arg_t *) arg;
            pid = info_arg->pid;
            if (pid > 0) {
                task = pid_task(find_vpid(pid), PIDTYPE_PID);
            } else if (pid == 0) {
                task = current;
            } else if (pid < 0) {
                task = current->parent;
            }
            if (task == NULL) {
                return -EINVAL;
            }
            info.pid = task->pid;
            info.ppid = task->parent->pid;
            info.start_time = task->start_time;
            info.num_sib = count_list(&task->sibling);
            if (copy_to_user(info_arg->info, &info, sizeof(procinfo_t))) {
                return -EACCES;
            }
            break;
        default:
            return -EINVAL;
    }
    return 0;
}
Beispiel #4
0
static void jffs2_rotate_lists(struct jffs2_sb_info *c)
{
	uint32_t x;

	x = count_list(&c->clean_list);
	if (x)
		rotate_list((&c->clean_list), pseudo_random % x);

	x = count_list(&c->dirty_list);
	if (x)
		rotate_list((&c->dirty_list), pseudo_random % x);

	if (c->nr_erasing_blocks)
		rotate_list((&c->erase_pending_list), pseudo_random % c->nr_erasing_blocks);

	if (c->nr_free_blocks) /* Not that it should ever be zero */
		rotate_list((&c->free_list), pseudo_random % c->nr_free_blocks);
}
Beispiel #5
0
BOOL
validate_array_dims(Expr *e, char *scope_id, sym_table *table) {
    symbol *asym = retrieve_symbol(e->id, scope_id, table);
    if (asym == NULL) {
        //Array has not been defined
        return FALSE;
    } else {
        Decl *d = (Decl *) asym->sym_value;
        return count_array(d->array) == count_list(e->indices);
    }
}
Beispiel #6
0
void jffs2_rotate_lists(struct jffs2_sb_info *c)
{
	uint32_t x;
	uint32_t rotateby;

	x = count_list(&c->clean_list);
	if (x) {
		rotateby = pseudo_random % x;
		rotate_list((&c->clean_list), rotateby);
	}

	x = count_list(&c->very_dirty_list);
	if (x) {
		rotateby = pseudo_random % x;
		rotate_list((&c->very_dirty_list), rotateby);
	}

	x = count_list(&c->dirty_list);
	if (x) {
		rotateby = pseudo_random % x;
		rotate_list((&c->dirty_list), rotateby);
	}

	x = count_list(&c->erasable_list);
	if (x) {
		rotateby = pseudo_random % x;
		rotate_list((&c->erasable_list), rotateby);
	}

	if (c->nr_erasing_blocks) {
		rotateby = pseudo_random % c->nr_erasing_blocks;
		rotate_list((&c->erase_pending_list), rotateby);
	}

	if (c->nr_free_blocks) {
		rotateby = pseudo_random % c->nr_free_blocks;
		rotate_list((&c->free_list), rotateby);
	}
}
Beispiel #7
0
void jffs2_rotate_lists(struct jffs2_sb_info *c)
{
	uint32_t x;
	uint32_t rotateby;

	x = count_list(&c->clean_list);
	if (x) {
		rotateby = pseudo_random % x;
		D1(printk(KERN_DEBUG "Rotating clean_list by %d\n", rotateby));

		rotate_list((&c->clean_list), rotateby);

		D1(printk(KERN_DEBUG "Erase block at front of clean_list is at %08x\n",
			  list_entry(c->clean_list.next, struct jffs2_eraseblock, list)->offset));
	} else {
Beispiel #8
0
void
rd_particle_specs(FILE *ifp, char *input)
{
  PBC_t *PBC;
  char err_msg[MAX_CHAR_ERR_MSG], s_tmp[SLEN], s_tmp_save[SLEN_2], *s_ptr1, *s_ptr2;
  int i, j, iread;

  iread = look_for_optional(ifp, "Particle Specifications", input, '=');
  if(iread != 1)
    {
      Particle_Dynamics = 0;
      Particle_Number_Sample_Types = 0;
      Particle_Number_Samples_Existing = NULL;
      Particle_Number_Samples = NULL;
      Particle_Number_Output_Variables = NULL;
      Particle_Output_Variables = NULL;
      Particle_Filename_Template = NULL;
      Particle_Number_PBCs = 0;
      PBCs = NULL;
      return;
    }

  printf("\n--- Particle specifications ---\n");
  Particle_Dynamics = 1;	/* turn on particle dynamics */

  /* What kind of particle model do you want?  This determines all
   * kinds of things, such as FEM<->particle coupling, particle
   * trajectory calculation, etc. */
  look_for(ifp, "Particle model", input, '=');
  if(!fgets(s_tmp, SLEN-1, ifp))
    EH(-1, "Error reading Particle model card.");
  strip(s_tmp);			/* s_tmp still has '\n' at end */
  if(s_tmp[strlen(s_tmp)-1] == '\n')
    s_tmp[strlen(s_tmp)-1] = 0;
  strcpy(s_tmp_save, s_tmp);
  s_ptr1 = strpbrk(s_tmp_save, " \t\n");
  if(s_ptr1 != NULL)
    s_ptr1[0] = 0;
  if(!strncmp("INERTIAL_TRACER_EXPLICIT", s_tmp, 24))
    Particle_Model = INERTIAL_TRACER_EXPLICIT;
  else if(!strncmp("INERTIAL_TRACER_IMPLICIT", s_tmp, 24))
    Particle_Model = INERTIAL_TRACER_IMPLICIT;
  else if(!strncmp("TRACER_EXPLICIT", s_tmp, 15))
    Particle_Model = TRACER_EXPLICIT;
  else if(!strncmp("TRACER_IMPLICIT", s_tmp, 15))
    Particle_Model = TRACER_IMPLICIT;
  else if(!strncmp("SWIMMER_EXPLICIT", s_tmp, 16))
    Particle_Model = SWIMMER_EXPLICIT;
  else if(!strncmp("SWIMMER_IMPLICIT", s_tmp, 16))
    Particle_Model = SWIMMER_IMPLICIT;
  else if(!strncmp("CHARGED_TRACER_EXPLICIT", s_tmp, 23))
    Particle_Model = CHARGED_TRACER_EXPLICIT;
  else if(!strncmp("CHARGED_TRACER_IMPLICIT", s_tmp, 23))
    Particle_Model = CHARGED_TRACER_IMPLICIT;
  else if(!strncmp("DIELECTROPHORETIC_TRACER_IMPLICIT", s_tmp, 33))
    Particle_Model = DIELECTROPHORETIC_TRACER_IMPLICIT;
  else
    {
      sprintf(s_tmp_save, "Unknown Particle model: %s\n", s_tmp);
      EH(-1, s_tmp_save);
    }
  printf("Setting Particle_Model = %s\n", s_tmp_save);

  switch(Particle_Model)
    {
    case INERTIAL_TRACER_IMPLICIT:
    case INERTIAL_TRACER_EXPLICIT:
      s_ptr1 = s_tmp + 24;
      if(!(s_ptr2 = strtok(s_ptr1, " \t\n")))
	{
	  sprintf(err_msg, "Error reading random walk coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[0] = atof(s_ptr2);
      printf("Setting random walk coefficient = %g\n", Particle_Model_Data[0]);
      
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading gravity coefficient for %s particle_model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[1] = atof(s_ptr2);
      printf("Setting gravity coefficient = %g\n", Particle_Model_Data[1]);
      break;
    case TRACER_EXPLICIT:
    case TRACER_IMPLICIT:
      s_ptr1 = s_tmp + 15;
      if(!(s_ptr2 = strtok(s_ptr1, " \t\n")))
	{
	  sprintf(err_msg, "Error reading random walk coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[0] = atof(s_ptr2);
      printf("Setting random walk coefficient = %g\n", Particle_Model_Data[0]);
      break;
    case SWIMMER_EXPLICIT:
    case SWIMMER_IMPLICIT:
      s_ptr1 = s_tmp + 16;
      if(!(s_ptr2 = strtok(s_ptr1, " \t\n")))
	{
	  sprintf(err_msg, "Error reading random swimming speed coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[0] = atof(s_ptr2);
      printf("Setting random swimming speed coefficient = %g\n", Particle_Model_Data[0]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading random cell orientation coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[1] = atof(s_ptr2);
      printf("Setting random cell orientation coefficient = %g\n", Particle_Model_Data[1]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading upswimming speed for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[2] = atof(s_ptr2);
      printf("Setting particle upswimming speed = %g\n", Particle_Model_Data[2]);
      break;
    case CHARGED_TRACER_EXPLICIT:
    case CHARGED_TRACER_IMPLICIT:
      s_ptr1 = s_tmp + 23;
      if(!(s_ptr2 = strtok(s_ptr1, " \t\n")))
	{
	  sprintf(err_msg, "Error reading random walk coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[0] = atof(s_ptr2);
      printf("Setting random walk coefficient = %g\n", Particle_Model_Data[0]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading charge coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[1] = atof(s_ptr2);
      printf("Setting charge coefficient = %g\n", Particle_Model_Data[1]);
      break;
    case DIELECTROPHORETIC_TRACER_IMPLICIT:
      s_ptr1 = s_tmp + 33;
      if(!(s_ptr2 = strtok(s_ptr1, " \t\n")))
	{
	  sprintf(err_msg, "Error reading random walk coefficient for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[0] = atof(s_ptr2);
      printf("Setting random walk coefficient = %g\n", Particle_Model_Data[0]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading particle permittivity for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[1] = atof(s_ptr2);
      printf("Setting particle permittivity = %g\n", Particle_Model_Data[1]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading medium (fluid) permittivity for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[2] = atof(s_ptr2);
      printf("Setting medium (fluid) permittivity = %g\n", Particle_Model_Data[2]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading particle conductivity for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[3] = atof(s_ptr2);
      printf("Setting particle conductivity = %g\n", Particle_Model_Data[3]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading medium (fluid) conductivity for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[4] = atof(s_ptr2);
      printf("Setting medium (fluid) conductivity = %g\n", Particle_Model_Data[4]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading AC angular frequency for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[5] = atof(s_ptr2);
      printf("Setting AC angular frequency = %g\n", Particle_Model_Data[5]);
      if(!(s_ptr2 = strtok(NULL, " \t\n")))
	{
	  sprintf(err_msg, "Error reading Volt conversion factor for %s particle model.", s_tmp);
	  EH(-1, err_msg);
	}
      Particle_Model_Data[6] = atof(s_ptr2);
      printf("Setting Volt conversion factor = %g\n", Particle_Model_Data[6]);
      break;
    default:
      EH(-1, "How'd you get here?");
    }

  /* Get maximum number of particle time steps if we're running after
   * a steady-state solution... */
  if(TimeIntegration == STEADY)
    {
      if(look_for_optional(ifp, "Time steps", input, '=') == 1)
	{
	  if(fscanf(ifp, "%d", &Particle_Max_Time_Steps) != 1)
	    EH(-1, "Error reading Time steps card for post-steady problem.");
	  printf("Setting Particle_Max_Time_Steps = %d\n", Particle_Max_Time_Steps);
	}
      else
	Particle_Max_Time_Steps = 0;
    }
  else
    if(look_for_optional(ifp, "Time steps", input, '=') == 1)
      printf("CAUTION: ignoring Time steps card for transient problem.");

  /* How many particles would you like?  For now, they are always
   * introduced unformly throughout the domain. */
  look_for(ifp, "Number of particles", input, '=');
  if(fscanf(ifp, "%d", &Particle_Number) != 1)
    EH(-1, "Error reading Number of particles card.");
  printf("Setting Particle_Number = %d\n", Particle_Number);

  if(look_for_optional(ifp, "Restart file", input, '=') == 1)
    {
      char file_name_temp[MAX_PARTICLE_FILENAME_LENGTH];
      if(!fgets(file_name_temp, MAX_PARTICLE_FILENAME_LENGTH, ifp))
	EH(-1, "Error reading Restart file card.");
      strip(file_name_temp);
      strncpy(Particle_Restart_Filename, file_name_temp, MAX_PARTICLE_FILENAME_LENGTH);
      printf("Restart file = %s\n", Particle_Restart_Filename);
    }
  else
    sprintf(Particle_Restart_Filename, "<not active>");

  /* When to output particle information.  There are two ways to
   * specify this, and they are incompatible (i.e., only one can be
   * specified).  Either you can output particles every so many Goma
   * time steps, or you can have particles output every so often
   * time-wise (e.g., every 0.1 seconds), whether within a Goma time
   * step or containing many Goma time steps.*/ 
  if(look_for_optional(ifp, "Output stride", input, '=') == 1)
    {
      if(fscanf(ifp, "%d", &Particle_Output_Stride) != 1)
	EH(-1, "Error reading Output stride card.");
      printf("Setting Particle_Output_Stride = %d\n", Particle_Output_Stride);
    }
  else
    Particle_Output_Stride = -1;

  if(look_for_optional(ifp, "Output time step", input, '=') == 1)
    {
      if(fscanf(ifp, "%lf", &Particle_Output_Time_Step) != 1)
	EH(-1, "Error reading Output time step card.");
      printf("Setting Particle_Output_Time_Step = %g\n", Particle_Output_Time_Step);
      if(Particle_Output_Stride != -1)
	EH(-1, "You cannot specify both Output stride and Output time step.");
    }
  else
    Particle_Output_Time_Step = 0.0;

  if(Particle_Output_Stride == -1 &&
     Particle_Output_Time_Step == 0.0)
    EH(-1, "One of the Output stride or Output time step cards must be present.");

  if(look_for_optional(ifp, "Output format", input, '=') == 1)
    {
      if(!fgets(s_tmp, SLEN-1, ifp))
	EH(-1, "Error reading Output format card.");
      strip(s_tmp);			/* s_tmp still has '\n' at end -- don't care. */
      if(!strncmp("TECPLOT", s_tmp, 7))
	Particle_Output_Format = TECPLOT;
      else if(!strncmp("FLAT_TEXT", s_tmp, 9))
	Particle_Output_Format = FLAT_TEXT;
      else
	{
	  sprintf(s_tmp_save, "Unknown Output format: %s\n", s_tmp);
	  EH(-1, s_tmp_save);
	}
    }
  else
    Particle_Output_Format = FLAT_TEXT;

  if(look_for_optional(ifp, "Particle density", input, '=') == 1)
    {
      if(fscanf(ifp, "%lf", &Particle_Density) != 1)
	EH(-1, "Error reading Particle density card.");
    }
  else
    Particle_Density = 1.0;
  printf("Setting Particle_Density = %g\n", Particle_Density);

  if(look_for_optional(ifp, "Particle radius", input, '=') == 1)
    {
      if(fscanf(ifp, "%lf", &Particle_Radius) != 1)
	EH(-1, "Error reading Particle radius card.");
    }
  else
    Particle_Radius = 1.0;
  printf("Setting Particle_Radius = %g\n", Particle_Radius);
  if(Particle_Radius <= 0.0)
    EH(-1, "Particle radius must be > 0.0.  Non-inertial tracer particles will ignore this setting.");

  if(look_for_optional(ifp, "Particle ratio", input, '=') == 1)
    {
      if(fscanf(ifp, "%lf", &Particle_Ratio) != 1)
	EH(-1, "Error reading Particle ratio card.");
    }
  else
    Particle_Ratio = 1.0;
  printf("Setting Particle_Ratio = %g\n", Particle_Ratio);

  Particle_Show_Debug_Info = 0;
  if(look_for_optional(ifp, "Show particle debug info", input, '=') == 1)
    {
      if(fscanf(ifp, "%s", s_tmp) != 1)
	EH(-1, "Need yes or no for Show particle debug info card.");
      if(!strncmp(s_tmp, "YES", 3))
	{
	  Particle_Show_Debug_Info = 1;
	  printf("Showing particle debug info\n");
	}
    }
  if(!Particle_Show_Debug_Info)
    printf("Not showing particle debug info\n");

  /* Initialization for particle creation and move domains. */
  for(i = 0; i < MAX_DOMAIN_REAL_VALUES; i++)
    {
      Particle_Creation_Domain_Reals[i] = 1.0e+10;
      Particle_Move_Domain_Reals[i] = 1.0e+10;
    }
  Particle_Creation_Domain = UNRESTRICTED;
  Particle_Move_Domain = UNRESTRICTED;
  sprintf(Particle_Creation_Domain_Filename, "<not active>");
  sprintf(Particle_Creation_Domain_Name, "<not active>");
  sprintf(Particle_Move_Domain_Filename, "<not active>");
  sprintf(Particle_Move_Domain_Name, "<not active>");

  /* Set optional creation domain. */
  if(look_for_optional(ifp, "Particle creation domain", input, '=') == 1)
    {
      if(fscanf(ifp, "%s", s_tmp) != 1)
	EH(-1, "Error reading Particle creation domain card.");
      if(!strncmp(s_tmp, "BRICK", 5))
	{
	  Particle_Creation_Domain = BRICK;
	  if(fscanf(ifp, "%lf %lf %lf %lf %lf %lf\n", &Particle_Creation_Domain_Reals[0],
		     &Particle_Creation_Domain_Reals[1], &Particle_Creation_Domain_Reals[2],
		     &Particle_Creation_Domain_Reals[3], &Particle_Creation_Domain_Reals[4],
		     &Particle_Creation_Domain_Reals[5]) != 6)
	    EH(-1, "Error reading min/max values on Particle creation domain card.");
	  printf("Using BRICK creation domain with x in [%g,%g], y in [%g,%g], z in [%g,%g]\n",
		 Particle_Creation_Domain_Reals[0], Particle_Creation_Domain_Reals[1],
		 Particle_Creation_Domain_Reals[2], Particle_Creation_Domain_Reals[3],
		 Particle_Creation_Domain_Reals[4], Particle_Creation_Domain_Reals[5]);
	}
      else if(!strncmp(s_tmp, "ACIS", 4))
	{
	  EH(-1, "CGM not supported, ACIS");
	}
      else
	{
	  sprintf(err_msg, "Error reading Particle creation domain card, unknown domain type: %s.", s_tmp);
	  EH(-1, err_msg);
	}
    }
  else
    printf("Using unrestricted Particle_Creation_Domain\n");

  /* Set optional move domain. */
  if(look_for_optional(ifp, "Particle move domain", input, '=') == 1)
    {
      if(fscanf(ifp, "%s", s_tmp) != 1)
	EH(-1, "Error reading Particle move domain card.");
      if(!strncmp(s_tmp, "BRICK", 5))
	{
	  Particle_Move_Domain = BRICK;
	  if(fscanf(ifp, "%lf %lf %lf %lf %lf %lf\n", &Particle_Move_Domain_Reals[0],
		    &Particle_Move_Domain_Reals[1], &Particle_Move_Domain_Reals[2],
		    &Particle_Move_Domain_Reals[3], &Particle_Move_Domain_Reals[4],
		    &Particle_Move_Domain_Reals[5]) != 6)
	    EH(-1, "Error reading min/max values on Particle move domain card.");
	  printf("Using BRICK move domain with x in [%g,%g], y in [%g,%g], z in [%g,%g]\n",
		 Particle_Move_Domain_Reals[0], Particle_Move_Domain_Reals[1],
		 Particle_Move_Domain_Reals[2], Particle_Move_Domain_Reals[3],
		 Particle_Move_Domain_Reals[4], Particle_Move_Domain_Reals[5]);
	}
      else if(!strncmp(s_tmp, "ACIS", 4))
	{
	  EH(-1, "Need the CGM library to use ACIS for Particle creation domain card.");
	}
      else
	{
	  sprintf(err_msg, "Error reading Particle move domain card, unknown domain type: %s.", s_tmp);
	  EH(-1, err_msg);
	}
    }
  else
    printf("Using unrestricted Particle_Move_Domain\n");

  /* This is used for restarts, too, and ignores output file type.  If
   * we're a steady-state Goma calculation, then this applies to the
   * particle timesteps taken afterwards.  If this is a transient Goma
   * calculation, then this is a multiple of Goma steps.  In
   * particular, if particles are output on a time strided basis, that
   * will be ignored here. */
  if(look_for_optional(ifp, "Full output stride", input, '=') == 1)
    {
      char file_name_temp[MAX_PARTICLE_FILENAME_LENGTH];
      if(fscanf(ifp, "%d", &Particle_Full_Output_Stride) != 1)
	EH(-1, "Problem reading Full output stride card.");
      if(!fgets(file_name_temp, MAX_PARTICLE_FILENAME_LENGTH, ifp))
	EH(-1, "Problem reading Full output stride card.");
      strip(file_name_temp);
      strncpy(Particle_Full_Output_Filename, file_name_temp, MAX_PARTICLE_FILENAME_LENGTH);
      printf("Setting full output every %d steps to file %s\n", Particle_Full_Output_Stride, Particle_Full_Output_Filename);
    }
  else
    {
      Particle_Full_Output_Stride = 0;
      sprintf(Particle_Full_Output_Filename, "<not active>");
    }

  /* General description for number of particles to track, and how
   * many of them.  Can specify multiple selections, and the particles
   * will be separate samples.  Subject to total number of particles,
   * of course... */
  look_for(ifp, "Number of sample types", input, '=');
  if(fscanf(ifp, "%d", &Particle_Number_Sample_Types) != 1)
    EH(-1, "Problem reading Number of sample types card.");
  printf("Setting Particle_Number_Sample_Types = %d\n", Particle_Number_Sample_Types);

  if(Particle_Number_Sample_Types)
    {
      Particle_Number_Samples_Existing = (int *)array_alloc(1, Particle_Number_Sample_Types, sizeof(int));
      Particle_Number_Samples = (int *)array_alloc(1, Particle_Number_Sample_Types, sizeof(int));
      Particle_Number_Output_Variables = (int *)array_alloc(1, Particle_Number_Sample_Types, sizeof(int));
      Particle_Output_Variables = (particle_variable_s **)
	array_alloc(1, Particle_Number_Sample_Types, sizeof(particle_variable_s *));
      Particle_Filename_Template = (particle_filename_s *)array_alloc(1, Particle_Number_Sample_Types, sizeof(particle_filename_s));
    }
  else
    {
      Particle_Number_Samples_Existing = NULL;
      Particle_Number_Samples = NULL;
      Particle_Number_Output_Variables = NULL;
      Particle_Output_Variables = NULL;
      Particle_Filename_Template = NULL;
    }

  for(i = 0; i < Particle_Number_Sample_Types; i++)
    {
      look_for(ifp, "Sample", input, '=');
      if(fscanf(ifp, "%d", &Particle_Number_Samples[i]) != 1)
	EH(-1, "Error reading number of particle samples.");
      if(Particle_Number_Samples[i] > 0)
	printf("Sample %d contains %d particles", i, Particle_Number_Samples[i]);
      else
	EH(-1, "Number of particle samples must be > 0.");
      
      if(!fgets(s_tmp, SLEN-1, ifp))
	EH(-1, "Error reading sample variables and filename.");
      strncpy(s_tmp_save, s_tmp, SLEN);
      Particle_Number_Output_Variables[i] = 0;

      s_ptr1 = strtok(s_tmp, " \t\n");
      while((s_ptr1 = strtok(NULL, " \t\n")))
	Particle_Number_Output_Variables[i]++;

      s_ptr1 = strtok(s_tmp_save, " \t\n");
      if(Particle_Number_Output_Variables[i] > 0)
	{
	  printf(" tracking variable(s)");
	  Particle_Output_Variables[i] = (particle_variable_s *)calloc(Particle_Number_Output_Variables[i], sizeof(particle_variable_s));
	  /*
	    Particle_Output_Variables[i] = (char **)array_alloc(1, Particle_Number_Output_Variables[i], sizeof(char *));
	  */
	  for(j = 0; j < Particle_Number_Output_Variables[i]; j++)
	    {
	      if(strlen(s_ptr1) + 1 > MAX_PARTICLE_OUTPUT_VARIABLE_LENGTH)
		EH(-1, "Increase MAX_PARTICLE_OUTPUT_VARIABLE_LENGTH");
	      strncpy(Particle_Output_Variables[i][j], s_ptr1, strlen(s_ptr1) + 1);
	      printf(" %s", Particle_Output_Variables[i][j]);
	      s_ptr1 = strtok(NULL, " \t\n");
	    }
	}
      
      if(strlen(s_ptr1) + 1 > MAX_PARTICLE_FILENAME_LENGTH)
	EH(-1, "Increase MAX_PARTICLE_FILENAME_LENGTH");
      strncpy(Particle_Filename_Template[i], s_ptr1, strlen(s_ptr1) + 1);
      Particle_Filename_Template[i][strlen(s_ptr1)] = 0;
      printf(" to file %s.\n", Particle_Filename_Template[i]);
    }

  iread = look_for_optional(ifp, "START OF PBC", input, '=');
  if(iread == 1)
    {
      Particle_Number_PBCs = count_list(ifp, "PBC", input, '=', "END OF PBC");
      printf("Found %d PBC's\n", Particle_Number_PBCs);
      PBCs = (PBC_t *)calloc(Particle_Number_PBCs, sizeof(PBC_t));
      for(i = 0; i < Particle_Number_PBCs; i++)
	{
	  PBC = &PBCs[i];
	  look_for(ifp, "PBC", input, '=');
	  if(fscanf(ifp, "%80s", input) != 1)
	    EH(-1, "Error reading PBC.");
	  stringup(input);

	  /* I know it is stupid to do this for an unnecssary token,
	   * but it makes the input look better... */
	  if(fscanf(ifp, "%s", s_tmp) != 1)
	    EH(-1, "Missing SS token on PBC card.");
	  if(strncmp(s_tmp, "SS", 2))
	    EH(-1, "Missing SS token on PBC card.");

	  if(fscanf(ifp, "%d", &(PBC->SS_id)) != 1)
	    EH(-1, "Error reading SS_id on PBC card.");

	  if(!strncmp(input, "OUTFLOW", 7))
	    {
	      PBC->type = PBC_OUTFLOW;
	      puts("Found an OUTFLOW PBC.");
	    }
	  else if(!strncmp(input, "SOURCE", 6))
	    {
	      PBC->type = PBC_SOURCE;
	      if(fscanf(ifp, "%lf", &(PBC->real_data[0])) != 1)
		EH(-1, "Error reading SS specification and float on PBC = SOURCE card.");
	      printf("Found a SOURCE PBC with source = %g.\n",
		     PBC->real_data[0]);
	    }
	  else if(!strncmp(input, "TARGET", 6))
	    {
	      PBC->type = PBC_TARGET;
	      if(fscanf(ifp, "%s", s_tmp) != 1)
		EH(-1, "Missing filename on PBC TARGET card.");
	      if(strlen(s_tmp) + 1 > MAX_PBC_STRING_DATA_LENGTH)
		EH(-1, "Increase MAX_PBC_STRING_DATA_LENGTH");
	      strncpy(PBC->string_data, s_tmp, strlen(s_tmp) + 1);
	      printf("Found a TARGET PBC with filename = '%s'.\n",
		     PBC->string_data);
	    }
	  else if(!strncmp(input, "FREESTREAM_SOURCE", 17))
	    {
	      PBC->type = PBC_FREESTREAM_SOURCE;
	      if(fscanf(ifp, "%lf", &(PBC->real_data[0])) != 1)
		EH(-1, "Error reading SS specification and float on PBC = FREESTREAM_SOURCE card.");
	      printf("Found a FREESTREAM_SOURCE PBC with source = %g.\n",
		     PBC->real_data[0]);
	    }
	  else if(!strncmp(input, "IMPERMEABLE", 11))
	    {
	      PBC->type = PBC_IMPERMEABLE;
	      if(fscanf(ifp, "%lf", &(PBC->real_data[0])) != 1)
		EH(-1, "Error reading distance factor on PBC = IMPERMEABLE card.");
	      if(!fgets(s_tmp, SLEN-1, ifp))
		EH(-1, "Error reading geometry entity name on PBC = IMPERMEABLE card.");
	      strip(s_tmp);
	      if(s_tmp[strlen(s_tmp)-1] == '\n')
		s_tmp[strlen(s_tmp)-1] = 0;
	      if(strlen(s_tmp) + 1 > MAX_PBC_STRING_DATA_LENGTH)
		EH(-1, "Increase MAX_PBC_STRING_DATA_LENGTH");
	      strncpy(PBC->string_data, s_tmp, strlen(s_tmp) + 1);
	      printf("Found an IMPERMEABLE PBC with distance factor = %g to entity '%s'.\n",
		     PBC->real_data[0], PBC->string_data);
	    }
	  else
	    EH(-1, "Error reading PBC type.");
	}
    }
  else
    {
      Particle_Number_PBCs = 0;
      PBCs = NULL;
    }
}
Beispiel #9
0
static int
http_github(http_connection_t *hc, const char *remain, void *opaque)
{
  const char *pid = http_arg_get(&hc->hc_req_args, "project");
  const char *key = http_arg_get(&hc->hc_req_args, "key");


  if(pid == NULL) {
    trace(LOG_WARNING, "github: Missing 'project' in request");
    return 400;
  }

  if(key == NULL) {
    trace(LOG_WARNING, "github: Missing 'key' in request");
    return 400;
  }

  project_cfg(pc, pid);
  if(pc == NULL) {
    trace(LOG_DEBUG, "github: Project '%s' not configured", pid);
    return 404;
  }

  const char *mykey = cfg_get_str(pc, CFG("github", "key"), "");

  if(strcmp(mykey, key)) {
    trace(LOG_WARNING, "github: Invalid key received (%s) for project %s",
          key, pid);
    return 403;
  }

  project_t *p = project_get(pid);

  const char *json = http_arg_get(&hc->hc_req_args, "payload");
  if(json == NULL) {
    plog(p, "github", "github: Missing payload in request");
    return 400;
  }

  char errbuf[256];
  htsmsg_t *msg = htsmsg_json_deserialize(json, errbuf, sizeof(errbuf));
  if(msg == NULL) {
    plog(p, "github", "github: Malformed JSON in github request -- %s",
         errbuf);
    return 400;
  }

  const char *ref = htsmsg_get_str(msg, "ref");
  if(ref != NULL && !strncmp(ref, "refs/heads/", strlen("refs/heads/")))
    ref += strlen("refs/heads/");

  htsmsg_t *list = htsmsg_get_list(msg, "commits");
  if(ref != NULL && list != NULL) {
    htsmsg_field_t *f;
    HTSMSG_FOREACH(f, list) {
      htsmsg_t *c = htsmsg_get_map_by_field(f);
      if(c == NULL)
        continue;

      const char *url = htsmsg_get_str(c, "url");
      const char *msg = htsmsg_get_str(c, "message");
      htsmsg_t *a = htsmsg_get_map(c, "author");
      const char *author = a ? htsmsg_get_str(a, "name") : NULL;

      int added    = count_list(c, "added");
      int removed  = count_list(c, "removed");
      int modified = count_list(c, "modified");

      int len;
      char buf[512];
      char ctx[128];

      url = url ? urlshorten(url) : NULL;

      snprintf(ctx, sizeof(ctx), "changes/%s", ref);

      len = snprintf(buf, sizeof(buf),
                     "Commit in '"COLOR_BLUE"%s"COLOR_OFF"' by "COLOR_PURPLE"%s"COLOR_OFF" [",
                     ref, author ?: "???");

      if(added)
        len += snprintf(buf + len, sizeof(buf) - len,
                        COLOR_GREEN "%d file%s added",
                        added, added == 1 ? "" : "s");

      if(modified)
        len += snprintf(buf + len, sizeof(buf) - len,
                        COLOR_YELLOW "%s%d file%s modified",
                        added ? ", "  : "",
                        modified, modified == 1 ? "" : "s");

      if(removed)
        len += snprintf(buf + len, sizeof(buf) - len,
                        COLOR_RED "%s%d file%s removed",
                        added || modified ? ", "  : "",
                        removed, removed == 1 ? "" : "s");

      snprintf(buf + len, sizeof(buf) - len, COLOR_OFF"]%s%s",
               url ? " " : "", url ?: "");

      plog(p, ctx, "%s", buf);
      plog(p, ctx, "%s", msg);
    }
Beispiel #10
0
Type get_expr_type(Expr *e, Expr *parent,
                   sym_table *table, char *scope_id, int line_no) {

    //Find the type of an expression
    ExprKind kind = e->kind;
    // Switch on kind to print
    switch (kind) {
        case EXPR_ID:
            //Find the symbol and get it's type
            if (retrieve_symbol(e->id, scope_id, table)) {
                //Lets check the type
                Type t = get_type(retrieve_symbol(e->id, scope_id, table));
                e->inferred_type = t;
                return t;
            } else {
                //Not good. Let the user know.
                print_undefined_variable_error(e, parent, line_no);
                isValid = FALSE;
                e->inferred_type = INVALID_TYPE;
                return INVALID_TYPE;
            }
            break;
        case EXPR_CONST:
            if (e != NULL) { //f**k c.
                Type t =  get_const_type(e);
                e->inferred_type = t;
                return t;
            }

            break;
        case EXPR_BINOP:
            //We need the types of each expression
            //Then we determine the type if allowed using the binop
            return get_binop_type(get_expr_type(e->e1, e, table, scope_id,
                line_no), get_expr_type(e->e2, e, table, scope_id, line_no),
                e->binop, line_no, e);
            break;
        case EXPR_UNOP:
            //Get the type of the expression
            //Then we determine the type if allowed using the binop
            return get_unop_type(get_expr_type(e->e1, e, table, scope_id,
                                               line_no), e->unop, line_no, e);
            break;
        case EXPR_ARRAY:
            //We need to check array dimensions, then check all expressions are
            //int equiv.
            if (validate_array_dims(e, scope_id, table)) {
                symbol *a = retrieve_symbol(e->id, scope_id, table);
                validate_array_indices(e->indices, e->id,
                                       line_no, table, scope_id, a);
                e->inferred_type = get_type(a);
                return e->inferred_type;
            } else {
                symbol *a = retrieve_symbol(e->id, scope_id, table);
                if (a != NULL) {
                    // Now check if a is an array
                    if (a->bounds == NULL) {
                        print_not_array_error(e, a->sym_value, line_no);
                    } else {
                        Decl *d = (Decl *) a->sym_value;
                        print_array_dims_error(e, count_array(d->array),
                                               count_list(e->indices), line_no);
                    }
                    isValid = FALSE;
                } else {
                    print_undefined_variable_error(e, NULL, line_no);
                    isValid = FALSE;
                }
                e->inferred_type = INVALID_TYPE;
                return INVALID_TYPE;
            }
            return INVALID_TYPE;
            break;
    }

    return INVALID_TYPE;
}
Beispiel #11
0
Datei: type.c Projekt: mk12/eva
static struct EvalError *check_stdmacro(
		enum StandardMacro stdmacro, struct Expression *args, size_t n) {
	size_t length;
	struct Expression expr;
	struct Set *set;

	switch (stdmacro) {
	case F_DEFINE:
	case F_SET:
		if (args[0].type != E_SYMBOL) {
			return new_eval_error_expr(ERR_TYPE_VAR, args[0]);
		}
		break;
	case F_LAMBDA:
		expr = args[0];
		if (expr.type != E_NULL
				&& expr.type != E_PAIR
				&& expr.type != E_SYMBOL) {
			return new_syntax_error(expr);
		}
		set = new_set();
		while (expr.type != E_NULL) {
			InternId symbol_id;
			if (expr.type == E_PAIR) {
				if (expr.box->car.type != E_SYMBOL) {
					free_set(set);
					return new_eval_error_expr(ERR_TYPE_VAR, expr.box->car);
				}
				symbol_id = expr.box->car.symbol_id;
			} else if (expr.type == E_SYMBOL) {
				symbol_id = expr.symbol_id;
			} else {
				free_set(set);
				return new_eval_error_expr(ERR_TYPE_VAR, expr);
			}
			if (!add_to_set(set, symbol_id)) {
				free_set(set);
				return attach_code(
						new_eval_error_symbol(ERR_DUP_PARAM, symbol_id),
						args[0]);
			}
			if (expr.type == E_SYMBOL) {
				break;
			}
			expr = expr.box->cdr;
		}
		free_set(set);
		break;
	case F_UNQUOTE:
	case F_UNQUOTE_SPLICING:
		return new_eval_error(ERR_UNQUOTE);
	case F_COND:
		for (size_t i = 0; i < n; i++) {
			if (!count_list(&length, args[i]) || length < 2) {
				return new_syntax_error(args[i]);
			}
		}
		break;
	case F_LET:
	case F_LET_STAR:
		expr = args[0];
		set = new_set();
		while (expr.type != E_NULL) {
			if (expr.type == E_PAIR) {
				if (!count_list(&length, expr.box->car) || length != 2) {
					free_set(set);
					return new_syntax_error(expr.box->car);
				}
				if (expr.box->car.box->car.type != E_SYMBOL) {
					free_set(set);
					return new_eval_error_expr(
							ERR_TYPE_VAR, expr.box->car.box->car);
				}
			} else {
				free_set(set);
				return new_syntax_error(args[0]);
			}
			InternId symbol_id = expr.box->car.box->car.symbol_id;
			if (!add_to_set(set, symbol_id)) {
				free_set(set);
				return attach_code(
						new_eval_error_symbol(ERR_DUP_PARAM, symbol_id),
						args[0]);
			}
			expr = expr.box->cdr;
		}
		free_set(set);
		break;
	default:
		break;
	}
	return NULL;
}
Beispiel #12
0
Datei: type.c Projekt: mk12/eva
static struct EvalError *check_stdproc(
		enum StandardProcedure stdproc, struct Expression *args, size_t n) {
	switch (stdproc) {
	case S_APPLY:;
		Arity arity;
		if (!expression_arity(&arity, args[0])) {
			return new_eval_error_expr(ERR_TYPE_OPERATOR, args[0]);
		}
		size_t length;
		if (!count_list(&length, args[n-1])) {
			return new_syntax_error(args[n-1]);
		}
		size_t n_args = length + n - 2;
		if (!arity_allows(arity, n_args)) {
			return new_arity_error(arity, n_args);
		}
		break;
	case S_MACRO:
		if (args[0].type != E_STDPROCEDURE && args[0].type != E_PROCEDURE) {
			return new_type_error(E_PROCEDURE, args, 0);
		}
		break;
	case S_NUM_EQ:
	case S_NUM_LT:
	case S_NUM_GT:
	case S_NUM_LE:
	case S_NUM_GE:
	case S_ADD:
	case S_SUB:
	case S_MUL:
	case S_EXPT:
	case S_INTEGER_TO_CHAR:
	case S_NUMBER_TO_STRING:
		for (size_t i = 0; i < n; i++) {
			CHECK_TYPE(E_NUMBER, i);
		}
		break;
	case S_DIV:
	case S_REMAINDER:
	case S_MODULO:
		for (size_t i = 0; i < n; i++) {
			CHECK_TYPE(E_NUMBER, i);
			if (i > 0 && args[i].number == 0) {
				// This is not technically a type error, but this is the
				// earliest and most convenient place to catch it.
				return new_eval_error(ERR_DIV_ZERO);
			}
		}
		break;
	case S_CAR:
	case S_CDR:
	case S_SET_CAR:
	case S_SET_CDR:
		CHECK_TYPE(E_PAIR, 0);
		break;
	case S_STRING_LENGTH:
	case S_STRING_EQ:
	case S_STRING_LT:
	case S_STRING_GT:
	case S_STRING_LE:
	case S_STRING_GE:
	case S_STRING_COPY:
	case S_STRING_APPEND:
	case S_STRING_TO_SYMBOL:
	case S_STRING_TO_NUMBER:
	case S_LOAD:
		for (size_t i = 0; i < n; i++) {
			CHECK_TYPE(E_STRING, i);
		}
		break;
	case S_MAKE_STRING:
		CHECK_TYPE(E_NUMBER, 0);
		CHECK_TYPE(E_CHARACTER, 1);
		if (args[0].number < 0) {
			return new_eval_error_expr(ERR_NEGATIVE_SIZE, args[0]);
		}
		break;
	case S_STRING_REF:
		CHECK_TYPE(E_STRING, 0);
		CHECK_TYPE(E_NUMBER, 1);
		CHECK_RANGE(0, 1);
		break;
	case S_STRING_SET:
		CHECK_TYPE(E_STRING, 0);
		CHECK_TYPE(E_NUMBER, 1);
		CHECK_TYPE(E_CHARACTER, 2);
		CHECK_RANGE(0, 1);
		break;
	case S_SUBSTRING:
		CHECK_TYPE(E_STRING, 0);
		CHECK_TYPE(E_NUMBER, 1);
		CHECK_TYPE(E_NUMBER, 2);
		CHECK_RANGE(0, 1);
		CHECK_RANGE(0, 2);
		break;
	case S_STRING_FILL:
		CHECK_TYPE(E_STRING, 0);
		CHECK_TYPE(E_CHARACTER, 1);
		break;
	case S_CHAR_EQ:
	case S_CHAR_LT:
	case S_CHAR_GT:
	case S_CHAR_LE:
	case S_CHAR_GE:
	case S_CHAR_TO_INTEGER:
		for (size_t i = 0; i < n; i++) {
			CHECK_TYPE(E_CHARACTER, i);
		}
		break;
	case S_SYMBOL_TO_STRING:
		CHECK_TYPE(E_SYMBOL, 0);
		break;
	default:
		break;
	}
	return NULL;
}
Beispiel #13
0
static int pop3_slowuidl( int sock,  struct query *ctl, int *countp, int *newp)
{
    /* XXX FIXME: this code is severely broken. A Cc:d mailing list
     * message will arrive twice with the same Message-ID, so this
     * slowuidl code will break. Same goes for messages without
     * Message-ID headers at all. This code would best be removed. */
    /* This approach tries to get the message headers from the
     * remote hosts and compares the message-id to the already known
     * ones:
     *  + if the first message containes a new id, all messages on
     *    the server will be new
     *  + if the first is known, try to estimate the last known message
     *    on the server and check. If this works you know the total number
     *    of messages to get.
     *  + Otherwise run a binary search to determine the last known message
     */
    int ok, nolinear = 0;
    int first_nr, list_len, try_id, try_nr, add_id;
    int num;
    char id [IDLEN+1];

    if ((ok = pop3_gettopid(sock, 1, id, sizeof(id))) != 0)
	return ok;

    if( ( first_nr = str_nr_in_list(&ctl->oldsaved, id) ) == -1 ) {
	/* the first message is unknown -> all messages are new */
	*newp = *countp;	
	return 0;
    }

    /* check where we expect the latest known message */
    list_len = count_list( &ctl->oldsaved );
    try_id = list_len  - first_nr; /* -1 + 1 */
    if( try_id > 1 ) {
	if( try_id <= *countp ) {
	    if ((ok = pop3_gettopid(sock, try_id, id, sizeof(id))) != 0)
		return ok;
    
	    try_nr = str_nr_last_in_list(&ctl->oldsaved, id);
	} else {
	    try_id = *countp+1;
	    try_nr = -1;
	}
	if( try_nr != list_len -1 ) {
	    /* some messages inbetween have been deleted... */
	    if( try_nr == -1 ) {
		nolinear = 1;

		for( add_id = 1<<30; add_id > try_id-1; add_id >>= 1 )
		    ;
		for( ; add_id; add_id >>= 1 ) {
		    if( try_nr == -1 ) {
			if( try_id - add_id <= 1 ) {
			    continue;
			}
			try_id -= add_id;
		    } else 
			try_id += add_id;
		    
		    if ((ok = pop3_gettopid(sock, try_id, id, sizeof(id))) != 0)
			return ok;
		    try_nr = str_nr_in_list(&ctl->oldsaved, id);
		}
		if( try_nr == -1 ) {
		    try_id--;
		}
	    } else {
		report(stderr, 
		       GT_("Messages inserted into list on server. Cannot handle this.\n"));
		return -1;
	    }
	}