Beispiel #1
0
void do_mpcode( char_data* ch, char *argument )
{
  char               tmp  [ MAX_STRING_LENGTH ];
  program_data*    mprog;
  species_data*  species;
  wizard_data*    wizard;

  wizard = (wizard_data*) ch;

  if( ( species = wizard->mob_edit ) == NULL ) {
    send( "You aren't editing any mob - use medit <mob>.\r\n", ch );
    return;
    }

  if( *argument != '\0' ) {
    if( !ch->can_edit( species ) )
      return;
    sprintf( tmp, "mpc: %s", argument );
    mob_log( ch, species->vnum, tmp );
    zero_exp( species );
    }

  if( ( mprog = wizard->mprog_edit ) == NULL )
    mprog = species->attack;

  var_ch = ch;
  mprog->code = edit_string( ch, argument, mprog->code, MEM_MPROG );
  compile( mprog );

  if( mprog == species->attack )
    mprog->active = 1;

  return;
}
Beispiel #2
0
void scrollback_savefile(buffer *pbuf)
{
	char *file = NULL;
	NEWWIN *mywin = create_popup(8, 40);

	win_header(mywin, "Save buffer to file");

	mvwprintw(mywin -> win, 4, 2, "Select file");
	file = edit_string(mywin, 5, 2, 40, find_path_max(), 0, NULL, HELP_SCROLLBACK_SAVEFILE_ENTER_FILENAME, -1, &cmdfile_h, NULL);
	if (file)
	{
		FILE *fh = fopen(file, "w");
		if (fh)
		{
			int loop;

			for(loop=0; loop<pbuf -> curpos; loop++)
			{
				if ((pbuf -> be)[loop].Bline)
				{
					char display = 1;
					char *error;
					int dummy = -1;
					regmatch_t *pmatch = NULL;

					/* check filter */
					if (!IS_MARKERLINE((pbuf -> be)[loop].pi))
					{
						(void)check_filter((pbuf -> be)[loop].pi, (pbuf -> be)[loop].Bline, &pmatch, &error, &dummy, 0, &display);
						if (error)
						{
							fprintf(fh, "%s\n", error);
							myfree(error);
						}
					}
					if (display)
					{
						fprintf(fh, "%s\n", USE_IF_SET((pbuf -> be)[loop].Bline, ""));
					}

					if (pmatch) myfree(pmatch);
				}
			}

			fclose(fh);
		}
		else
		{
			error_popup("Save scrollback buffer", -1, "Cannot write to file, reason: %s", strerror(errno));
		}
	}

	delete_popup(mywin);
}
Beispiel #3
0
void scrollback_find_popup(char **find_str, mybool_t *pcase_insensitive)
{
	char *dummy;
	NEWWIN *mywin = create_popup(5, 40);

	win_header(mywin, "Find");

	dummy = edit_string(mywin, 3, 2, 40, 80, 0, reuse_searchstring?*find_str:NULL, HELP_SCROLLBACK_EDIT_SEARCH_STRING, -1, &search_h, pcase_insensitive);
	myfree(*find_str);
	*find_str = dummy;

	delete_popup(mywin);
}
Beispiel #4
0
FCPPT_PP_POP_WARNING

int main()
{
	std::cout << divide_by_1000(10.0) << '\n';
	// Would give a compiler error
	//std::cout << divide_by_1000(10) << '\n';
	std::string s("foobar");
	std::cout << edit_string(s) << '\n';
	// Would give a compiler error, although operator+ is defined
	//std::cout << edit_string(10) << '\n';

	apple foo;

	foo.worm();
}
Beispiel #5
0
void do_mpdata( char_data* ch, char* argument )
{
  program_data*    mprog;
  species_data*  species;
  wizard_data*    wizard;

  wizard = (wizard_data*) ch;
  mprog  = wizard->mprog_edit;

  if( ( species = wizard->mob_edit ) == NULL ) {
    send( ch, "You aren't editing any mob.\r\n" );
    return;
    }

  if( mprog == NULL )
    mprog = species->attack;

  if( wizard->mpdata_edit != NULL ) {
    if( !strcasecmp( argument, "exit" ) ) {
      wizard->mpdata_edit = NULL;
      send( ch, "Mpdata now operates on the data list.\r\n" );
      return;
      }
    wizard->mpdata_edit->text = edit_string( ch, 
      argument, wizard->mpdata_edit->text, MEM_EXTRA );
    }
  else {
    edit_extra( mprog->data, wizard,
      offset( &wizard->mpdata_edit, wizard ), argument, "mprog" );
    }

  var_ch = ch;
  compile( mprog ); 

  if( mprog == species->attack )
    mprog->active = 1;

  return;
}
Beispiel #6
0
void determine_panel_labels(PLOT_SPEC *plspec, long panel_index)
{
  long i, request, file, first, datasets;
  long j, plane, scaleCount, group, set, index, ig;
  static char buffer[SDDS_MAXLINE], s[SDDS_MAXLINE];
  PLOT_DATA **dataset;
  time_t timeValue;
  static unsigned long ticksetTime[2] = {TICKSET_XTIME, TICKSET_YTIME}, flags;
  char *newLabel, *editCommand;
  
  /* Construct labels for each scale for each plane */
  first = 1;
  dataset = plspec->panel[panel_index].dataset;
  datasets = plspec->panel[panel_index].datasets;
#if defined(DEBUG)
  fprintf(stderr, "panel label determination: %ld datasets for panel %ld\n", 
          datasets, panel_index);
#endif
  newLabel = NULL;
  for (plane=0; plane<2; plane++) {
    scaleCount = 0;
    for (ig=0; ig<plspec->panel[panel_index].scalesUsed[plane]; ig++) {
      group = plspec->panel[panel_index].scalesGroupIndex[plane][ig];
      /* each scales group has a separate label */
      if (plspec->scaleLabelInfo[plane][group].flags!=SCALE_LABEL_USED)
          continue;
      plspec->scaleLabelInfo[plane][group].flags = 0;
      plspec->scaleLabelInfo[plane][group].scaleNumber = -1;
      plspec->scaleLabelInfo[plane][group].label = newLabel = editCommand = NULL;
      for (set=0; set<datasets; set++) {
        /* scan for datasets that belong to this group */
        if (dataset[set]->scalesGroupIndex[plane]!=group)
          continue;
        request = dataset[set]->request_index;
	if (plspec->plot_request[request].overlay.flags)
	  continue;
        /* If we get to this point, then a scale will be made for
         * this group.
         */
        if (plspec->scaleLabelInfo[plane][group].scaleNumber==-1)
          plspec->scaleLabelInfo[plane][group].scaleNumber = ++scaleCount;
        /* For each scales group, the label may have been specified by 
         * a -label option for one request.
         */
        if ((index=plspec->scalesGroupData[plane][group].labelSpecRequestIndex)>=0 &&
            index==request &&
            (flags=plspec->plot_request[index].label[plane].flags)) {
          if (flags&(LABEL_STRING_GIVEN+LABEL_PARAMETER_GIVEN+
                     LABEL_USE_NAME+LABEL_USE_SYMBOL+LABEL_USE_DESCRIPTION)) {
            if (newLabel)
              free(newLabel);
            if (!SDDS_CopyString(&newLabel, dataset[set]->label[plane]))
              SDDS_Bomb("Memory allocation failure (determine_panel_labels)");
          }
          if (flags&LABEL_EDITCOMMAND_GIVEN)
            editCommand = plspec->plot_request[index].label[plane].edit_command;
          if (flags&LABEL_SCALE_GIVEN) {
            plspec->scaleLabelInfo[plane][group].flags |= SCALE_LABEL_SCALEGIVEN;
            plspec->scaleLabelInfo[plane][group].scale = plspec->plot_request[index].label[plane].scale;
          }
          if (flags&LABEL_OFFSET_GIVEN) {
            plspec->scaleLabelInfo[plane][group].flags |= SCALE_LABEL_OFFSETGIVEN;
            plspec->scaleLabelInfo[plane][group].offset = plspec->plot_request[index].label[plane].offset;
          }
          if (flags&LABEL_THICKNESS_GIVEN) {
            plspec->scaleLabelInfo[plane][group].flags |= SCALE_LABEL_THICKNESSGIVEN;
            plspec->scaleLabelInfo[plane][group].thickness = plspec->plot_request[index].label[plane].thickness;
          }
          if (flags&LABEL_LINETYPE_GIVEN) {
            plspec->scaleLabelInfo[plane][group].flags |= SCALE_LABEL_LINETYPEGIVEN;
            plspec->scaleLabelInfo[plane][group].linetype = plspec->plot_request[index].label[plane].linetype;
          }
          break;
        }
      }
      if (plspec->scaleLabelInfo[plane][group].scaleNumber==-1)
        continue;

      if (!newLabel) {
        /* No explicit label was given or generated */
        if ((index=plspec->scalesGroupData[plane][group].tickSettingsRequestIndex)>=0 &&
            plspec->plot_request[index].tick_settings.flags&ticksetTime[plane]) {
          /* Use calendar time scales, per user request. */
          timeValue = plspec->scalesGroupData[plane][group].limit[0];
          if (!(newLabel = SDDS_Malloc(sizeof(*newLabel)*50)))
            SDDS_Bomb("Memory allocation failure (determine_panel_labels)");
          if (timeValue!=DBL_MAX)
            sprintf(newLabel, "Time starting %s", ctime(&timeValue));
          else
            sprintf(newLabel, "Undefined time values!");
          delete_chars(newLabel, "\n");
        } 
        else {
          /* Make a label using the names of the columns.  This is the default
           * if no commandline options are given. */
          if (!(newLabel=makeNameUnitsLabel(plspec, panel_index, plane, group))) 
            SDDS_Bomb("Unable to make label (determine_panel_labels)");
        }
      }
      if (editCommand) {
        /* Edit the label per user request. */
        strcpy_ss(buffer, newLabel);
        free(newLabel);
        edit_string(buffer, editCommand);
        if (plspec->scaleLabelInfo[plane][group].label)
          free(plspec->scaleLabelInfo[plane][group].label);
        if (!SDDS_CopyString(&plspec->scaleLabelInfo[plane][group].label, buffer))
          SDDS_Bomb("String copy problem (determine_panel_labels)");
      }
      else {
        /* Store the label for latter placement on plot. */
        if (plspec->scaleLabelInfo[plane][group].label)
          free(plspec->scaleLabelInfo[plane][group].label);
        plspec->scaleLabelInfo[plane][group].label = newLabel;
        newLabel = NULL;
      }
    }
  }
  

  /* This section creates labels for the title (0) and topline (1) */
  for (j=0; j<2; j++) {
    if (plspec->panel[panel_index].titleSpec[j].label)
      SDDS_CopyString(plspec->panel[panel_index].title+j, plspec->panel[panel_index].titleSpec[j].label);
    else {
      /* Stuff in some default labels... */
      if (j==0 &&
          plspec->plot_request[dataset[0]->request_index].description_text[dataset[0]->file_index]) 
        /* title from description text of first dataset, if there is any */
        SDDS_CopyString(plspec->panel[panel_index].title+j, 
                        plspec->plot_request[dataset[0]->request_index].
                        description_text[dataset[0]->file_index]);
      else
        SDDS_CopyString(plspec->panel[panel_index].title+j, "");
    }
    if ((editCommand=plspec->panel[panel_index].titleSpec[j].edit_command)) {
      strcpy_ss(buffer, plspec->panel[panel_index].title[j]);
      edit_string(buffer, editCommand);
      free(plspec->panel[panel_index].title[j]);
      SDDS_CopyString(plspec->panel[panel_index].title+j, buffer);
    }
  }

  if (plspec->panel[panel_index].flags&PLREQ_FNONTOPLINE) {
    /* User requested filenames on topline */
    char **filename;
    char buffer[1024];
    filename = tmalloc(sizeof(*filename)*plspec->panel[panel_index].datasets);
    for (i=0; i<plspec->panel[panel_index].datasets; i++) {
      request = plspec->panel[panel_index].dataset[i]->request_index;
      file = plspec->panel[panel_index].dataset[i]->file_index;
      filename[i] = plspec->plot_request[request].filename[file];
      if (plspec->plot_request[request].filenamesOnToplineEditCmd) {
        strcpy_ss(buffer, filename[i]);
        edit_string(buffer, plspec->plot_request[request].filenamesOnToplineEditCmd);
        SDDS_CopyString(&filename[i], buffer);
      }
    }
    qsort(filename, plspec->panel[panel_index].datasets, sizeof(*filename),
          string_cmpasc);
    i = unique(filename, plspec->panel[panel_index].datasets, sizeof(*filename),
               string_cmpasc, string_copy);
    if (plspec->panel[panel_index].title[1][0])
      sprintf(s, "%s  ", plspec->panel[panel_index].title[1]);
    else
      s[0] = 0;
    for (j=0; j<i; j++) {
      if ((strlen(s)+strlen(filename[j])+3)>1024)
        break;
      if (j)
        strcat(s, ", ");
      strcat(s, filename[j]);
    }
    SDDS_CopyString(plspec->panel[panel_index].title+1, s);
  }

  if (plspec->panel[panel_index].flags&PLREQ_YLONTOPLINE) {
    /* This is probably impossible with the multiple scales... */
  }
}
Beispiel #7
0
int insert_symbol(int n, int m, char c)
{
    int i;
    struct MyString *tmpstring;
    struct MySymbol *tmpsymbol, *newsymbol, *tmp2symbol, *tmp3symbol;
    is_saved = 0;
    if (n > N)
        return -3;
    tmpstring = my_strings_start;
    for (i = 0; i < n-1; i++)
    {
        tmpstring = tmpstring->next_string;
    }
    
    if (m > tmpstring->cur_size)
    {
        tmp2symbol  = malloc(sizeof(struct MySymbol));
        if (tmp2symbol == NULL)
            return exit_force();
        tmpsymbol = tmp2symbol;
        
        if (tmpstring->last_symbol == NULL)
            tmpstring->first_symbol = tmpsymbol;
        else
            tmpstring->last_symbol->next_symbol = tmpsymbol;
        
        tmpsymbol->prev_symbol = tmpstring->last_symbol;
        tmpstring->last_symbol = tmpsymbol;
        tmpsymbol->symbol = '0';
        tmpsymbol->next_symbol = NULL;
        tmpstring->cur_size++;
        edit_string(n, tmpstring->cur_size, c);
        return 0;
    }
    if (m <= 1)
    {
        tmp2symbol  = malloc(sizeof(struct MySymbol));
        if (tmp2symbol == NULL)
            return exit_force();
        tmpsymbol = tmp2symbol;
        
        if (tmpstring->first_symbol == NULL)
            tmpstring->last_symbol = tmpsymbol;
        else
            tmpstring->first_symbol->prev_symbol = tmpsymbol;
        
        tmpsymbol->prev_symbol = NULL;
        tmpsymbol->next_symbol = tmpstring->first_symbol;
        tmpstring->first_symbol = tmpsymbol;
        tmpsymbol->symbol = '0';
        tmpstring->cur_size++;
        edit_string(n, 1, c);
        return 0;
    }
    
    tmpsymbol =tmpstring->first_symbol;
    for (i = 0; i < m-1; i++)
    {
        tmpsymbol = tmpsymbol->next_symbol;
    }
    
    tmp3symbol = malloc(sizeof(struct MySymbol));
    if (tmp3symbol == NULL)
        return exit_force();
    newsymbol = tmp3symbol;
    
    newsymbol->prev_symbol = tmpsymbol->prev_symbol;
    newsymbol->next_symbol = tmpsymbol;
    newsymbol->symbol = 0;
    tmpsymbol->prev_symbol->next_symbol = newsymbol;
    tmpsymbol->prev_symbol = newsymbol;
    tmpstring->cur_size++;
    edit_string(n, m, c);
    return 0;
}