Scippy

SCIP

Solving Constraint Integer Programs

dialog.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file dialog.c
17  * @brief methods for user interface dialog
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 #include <ctype.h>
26 
27 #include "scip/scip.h"
28 #include "scip/def.h"
29 #include "blockmemshell/memory.h"
30 #include "scip/set.h"
31 #include "scip/pub_misc.h"
32 #include "scip/dialog.h"
33 
34 #include "scip/struct_dialog.h"
35 
36 #ifdef SCIP_WITH_READLINE
37 #include <stdio.h>
38 #include <readline/readline.h>
39 #include <readline/history.h>
40 #endif
41 
42 
43 
44 /*
45  * read line methods
46  */
47 
48 #ifdef SCIP_WITH_READLINE
49 
50 /** reads a line of input from stdin */
51 static
53  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
54  const char* prompt, /**< prompt to display */
55  SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
56  )
57 {
58  char* s;
59 
60  assert(endoffile != NULL);
61 
62  s = readline(prompt);
63  if( s != NULL )
64  {
65  (void)SCIPstrncpy(&dialoghdlr->buffer[dialoghdlr->bufferpos], s, dialoghdlr->buffersize - dialoghdlr->bufferpos);
66  free(s);
67  *endoffile = FALSE;
68  }
69  else
70  *endoffile = TRUE;
71 
72  return SCIP_OKAY;
73 }
74 
75 /** puts the given string on the command history */
76 static
78  const char* s /**< string to add to the command history */
79  )
80 {
81  add_history(s);
82 
83  return SCIP_OKAY;
84 }
85 
86 /** returns the current length of the history list */
87 static
89  void
90  )
91 {
92 #ifndef NO_REMOVE_HISTORY
93  return history_length;
94 #else
95  return 0;
96 #endif
97 }
98 
99 /** removes a single element from the history list */
100 static
102  int pos /**< list position of history entry to remove */
103  )
104 {
105 #ifndef NO_REMOVE_HISTORY
106  HIST_ENTRY* entry;
107 
108  entry = remove_history(pos);
109 
110  /* Free readline/history storage: there seem to be differences in the versions (and the amount of
111  * data to be freed). The following should be a good approximation; if it doesn't work define
112  * NO_REMOVE_HISTORY - see the INSTALL file. This will produce minor memory leaks.
113  */
114 #if RL_VERSION_MAJOR >= 5
115  (void)free_history_entry(entry);
116 #else
117  if( entry != NULL )
118  {
119  free((void*)entry->line);
120  free(entry);
121  }
122 #endif
123 #endif
124 
125  return SCIP_OKAY;
126 }
127 
128 /** writes command history into file of the specified name */
129 static
131  const char* filename /**< name of file to (over)write history to */
132  )
133 {
134  int retval = write_history(filename);
135 
136  if( retval == 0 )
137  return SCIP_OKAY;
138  else
139  return SCIP_FILECREATEERROR;
140 }
141 
142 #else
143 
144 /** reads a line of input from stdin */
145 static
147  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
148  const char* prompt, /**< prompt to display */
149  SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
150  )
151 {
152  char* s;
153 
154  assert(dialoghdlr != NULL);
155  assert(dialoghdlr->buffer != NULL);
156  assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
157  assert(dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0');
158  assert(endoffile != NULL);
159 
160  /* check for EOF (due to CTRL-D or unexpected end of piped-in file) */
161  if( feof(stdin) )
162  *endoffile = TRUE;
163  else
164  {
165  char* result;
166 
167  /* display prompt */
168  printf("%s", prompt);
169 
170  /* read line from stdin */
171  result = fgets(&dialoghdlr->buffer[dialoghdlr->bufferpos], dialoghdlr->buffersize - dialoghdlr->bufferpos, stdin);
172  assert(result != NULL);
173  (void) result; /* disable compiler warning [-Wunused-result] */
174 
175  /* replace newline with \0 */
176  s = strchr(&dialoghdlr->buffer[dialoghdlr->bufferpos], '\n');
177  if( s != NULL )
178  *s = '\0';
179  *endoffile = FALSE;
180  }
181 
182  return SCIP_OKAY;
183 }
184 
185 /** puts the given string on the command history */
186 static
188  const char* s /**< string to add to the command history */
189  )
190 { /*lint --e{715}*/
191  /* nothing to do here */
192  return SCIP_OKAY;
193 }
194 
195 /** returns the current length of the history list */
196 static
198  void
199  )
200 {
201  return 0;
202 }
203 
204 /** removes a single element from the history list */
205 static
207  int pos /**< list position of history entry to remove */
208  )
209 { /*lint --e{715}*/
210  /* nothing to do here */
211  return SCIP_OKAY;
212 }
213 
214 
215 /** writes command history into file of the specified name */
216 static
218  const char* filename /**< name of file to (over)write history to */
219  )
220 { /*lint --e{715}*/
221  /* nothing to do here */
222  return SCIP_OKAY;
223 }
224 
225 #endif
226 
227 /** frees a single linelist entry, but not its successors */
228 static
230  SCIP_LINELIST** linelist /**< pointer to line list */
231  )
232 {
233  assert(linelist != NULL);
234 
235  BMSfreeMemoryArray(&(*linelist)->inputline);
236  BMSfreeMemory(linelist);
237 }
238 
239 /** frees a linelist entry and all of its successors */
240 static
242  SCIP_LINELIST** linelist /**< pointer to line list */
243  )
244 {
245  assert(linelist != NULL);
246 
247  while( *linelist != NULL )
248  {
249  SCIP_LINELIST* nextline;
250 
251  nextline = (*linelist)->nextline;
252  linelistFree(linelist);
253  *linelist = nextline;
254  }
255 }
256 
257 /** reads a line of input from stdin or from the stored input lines in the input list */
258 static
260  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
261  const char* prompt, /**< prompt to display */
262  SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
263  )
264 {
265  assert(dialoghdlr != NULL);
266  assert(dialoghdlr->buffer != NULL);
267  assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
268  assert(dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0');
269  assert(endoffile != NULL);
270 
271  *endoffile = FALSE;
272 
273  if( dialoghdlr->inputlist == NULL )
274  {
275  /* read a line from stdin */
276  SCIP_CALL( readLine(dialoghdlr, prompt, endoffile) );
277  }
278  else
279  {
280  SCIP_LINELIST* nextline;
281 
282  /* copy the next input line into the input buffer */
283  (void)SCIPstrncpy(&dialoghdlr->buffer[dialoghdlr->bufferpos], dialoghdlr->inputlist->inputline, dialoghdlr->buffersize - dialoghdlr->bufferpos);
284 
285  /* free the input line */
286  nextline = dialoghdlr->inputlist->nextline;
287  if( dialoghdlr->inputlistptr == &(dialoghdlr->inputlist->nextline) )
288  dialoghdlr->inputlistptr = &dialoghdlr->inputlist;
289  linelistFree(&dialoghdlr->inputlist);
290  dialoghdlr->inputlist = nextline;
291  assert(dialoghdlr->inputlistptr != NULL);
292  assert(*dialoghdlr->inputlistptr == NULL);
293  }
294 
295  return SCIP_OKAY;
296 }
297 
298 
299 
300 
301 /*
302  * dialog handler
303  */
304 
305 /** copies the given dialog to a new scip */
307  SCIP_DIALOG* dialog, /**< dialog */
308  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
309  )
310 {
311  assert(dialog != NULL);
312  assert(set != NULL);
313  assert(set->scip != NULL);
314 
315  if( dialog->dialogcopy != NULL )
316  {
317  SCIPsetDebugMsg(set, "including dialog %s in subscip %p\n", SCIPdialogGetName(dialog), (void*)set->scip);
318  SCIP_CALL( dialog->dialogcopy(set->scip, dialog) );
319  }
320  return SCIP_OKAY;
321 }
322 
323 /** creates a dialog handler */
325  SCIP_SET* set, /**< global SCIP settings */
326  SCIP_DIALOGHDLR** dialoghdlr /**< pointer to store dialog handler */
327  )
328 { /*lint --e{715}*/
329 #ifdef SCIP_WITH_READLINE
330  char readlineversion[20];
331 #endif
332 
333  assert(dialoghdlr != NULL);
334 
335  SCIP_ALLOC( BMSallocMemory(dialoghdlr) );
336  (*dialoghdlr)->rootdialog = NULL;
337  (*dialoghdlr)->inputlist = NULL;
338  (*dialoghdlr)->inputlistptr = &(*dialoghdlr)->inputlist;
339  (*dialoghdlr)->buffersize = SCIP_MAXSTRLEN;
340  (*dialoghdlr)->nprotectedhistelems = -1;
341  SCIP_ALLOC( BMSallocMemoryArray(&(*dialoghdlr)->buffer, (*dialoghdlr)->buffersize) );
342 
343  SCIPdialoghdlrClearBuffer(*dialoghdlr);
344 
345 #ifdef SCIP_WITH_READLINE
346  (void) SCIPsnprintf(readlineversion, sizeof(readlineversion), "Readline %s", rl_library_version);
347  SCIP_CALL( SCIPsetIncludeExternalCode(set, readlineversion, "GNU library for command line editing (gnu.org/s/readline)") );
348 #endif
349 
350  return SCIP_OKAY;
351 }
352 
353 /** frees a dialog handler and it's dialog tree */
355  SCIP* scip, /**< SCIP data structure */
356  SCIP_DIALOGHDLR** dialoghdlr /**< pointer to dialog handler */
357  )
358 {
359  assert(dialoghdlr != NULL);
360  if( *dialoghdlr == NULL )
361  return SCIP_OKAY;
362 
363  SCIP_CALL( SCIPdialoghdlrSetRoot(scip, *dialoghdlr, NULL) );
364  linelistFreeAll(&(*dialoghdlr)->inputlist);
365  BMSfreeMemoryArray(&(*dialoghdlr)->buffer);
366  BMSfreeMemory(dialoghdlr);
367 
368  return SCIP_OKAY;
369 }
370 
371 /** executes the root dialog of the dialog handler */
373  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
374  SCIP_SET* set /**< global SCIP settings */
375  )
376 {
377  SCIP_DIALOG* dialog;
378 
379  assert(dialoghdlr != NULL);
380  assert(dialoghdlr->buffer != NULL);
381 
382  /* clear the buffer, start with the root dialog */
383  SCIPdialoghdlrClearBuffer(dialoghdlr);
384  dialog = dialoghdlr->rootdialog;
385 
386  /* execute dialogs until a NULL is returned as next dialog */
387  while( dialog != NULL )
388  {
389  SCIP_CALL( SCIPdialogExec(dialog, set, dialoghdlr, &dialog) );
390 
391  /* reset buffer, it is was consumed completely */
392  if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0' )
393  SCIPdialoghdlrClearBuffer(dialoghdlr);
394  }
395 
396  return SCIP_OKAY;
397 }
398 
399 /** makes given dialog the root dialog of dialog handler; captures dialog and releases former root dialog */
401  SCIP* scip, /**< SCIP data structure */
402  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
403  SCIP_DIALOG* dialog /**< dialog to be the root */
404  )
405 {
406  assert(dialoghdlr != NULL);
407 
408  if( dialoghdlr->rootdialog != NULL )
409  {
410  SCIP_CALL( SCIPdialogRelease(scip, &dialoghdlr->rootdialog) );
411  }
412  assert(dialoghdlr->rootdialog == NULL);
413 
414  dialoghdlr->rootdialog = dialog;
415 
416  if( dialog != NULL )
417  SCIPdialogCapture(dialog);
418 
419  return SCIP_OKAY;
420 }
421 
422 /** returns the root dialog of the dialog handler */
424  SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */
425  )
426 {
427  assert(dialoghdlr != NULL);
428 
429  return dialoghdlr->rootdialog;
430 }
431 
432 /** clears the input command buffer of the dialog handler */
434  SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */
435  )
436 {
437  assert(dialoghdlr != NULL);
438 
439  dialoghdlr->buffer[0] = '\0';
440  dialoghdlr->bufferpos = 0;
441 }
442 
443 /** returns TRUE iff input command buffer is empty */
445  SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */
446  )
447 {
448  assert(dialoghdlr != NULL);
449  assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
450 
451  return (dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0');
452 }
453 
454 /** returns the next line in the handler's command buffer; if the buffer is empty, displays the given prompt or the
455  * current dialog's path and asks the user for further input; the user must not free or modify the returned string
456  */
458  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
459  SCIP_DIALOG* dialog, /**< current dialog */
460  const char* prompt, /**< prompt to display, or NULL to display the current dialog's path */
461  char** inputline, /**< pointer to store the complete line in the handler's command buffer */
462  SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
463  )
464 {
465  char path[SCIP_MAXSTRLEN+1];
466  char p[SCIP_MAXSTRLEN];
467 
468  assert(dialoghdlr != NULL);
469  assert(dialoghdlr->buffer != NULL);
470  assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
471  assert(inputline != NULL);
472 
473  /* get input from the user, if the buffer is empty */
474  if( SCIPdialoghdlrIsBufferEmpty(dialoghdlr) )
475  {
476  int len;
477 
478  /* clear the buffer */
479  SCIPdialoghdlrClearBuffer(dialoghdlr);
480 
481  if( prompt == NULL )
482  {
483  /* use current dialog's path as prompt */
484  SCIPdialogGetPath(dialog, '/', path);
485  (void) SCIPsnprintf(p, SCIP_MAXSTRLEN, "%s> ", path);
486  prompt = p;
487  }
488 
489  /* read command line from stdin or from the input line list */
490  SCIP_CALL( readInputLine(dialoghdlr, prompt, endoffile) );
491 
492  /* strip trailing spaces */
493  len = (int)strlen(&dialoghdlr->buffer[dialoghdlr->bufferpos]);
494  if( len > 0 )
495  {
496  while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1]) )
497  {
498  dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1] = '\0';
499  len--;
500  }
501  }
502 
503  /* insert command in command history */
504  if( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' )
505  {
506  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, NULL, &dialoghdlr->buffer[dialoghdlr->bufferpos], FALSE) );
507  }
508  }
509 
510  /* the last character in the buffer must be a '\0' */
511  dialoghdlr->buffer[dialoghdlr->buffersize-1] = '\0';
512 
513  /* skip leading spaces: find start of first word */
514  while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
515  dialoghdlr->bufferpos++;
516 
517  /* copy the complete line */
518  *inputline = &dialoghdlr->buffer[dialoghdlr->bufferpos];
519 
520  /* go to the end of the line */
521  dialoghdlr->bufferpos += (int)strlen(&dialoghdlr->buffer[dialoghdlr->bufferpos]);
522 
523  if( dialoghdlr->buffer[dialoghdlr->buffersize-1] == '\0' )
524  *endoffile = TRUE;
525 
526  return SCIP_OKAY;
527 }
528 
529 
530 /** returns the next word in the handler's command buffer; if the buffer is empty, displays the given prompt or the
531  * current dialog's path and asks the user for further input; the user must not free or modify the returned string
532  */
534  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
535  SCIP_DIALOG* dialog, /**< current dialog */
536  const char* prompt, /**< prompt to display, or NULL to display the current dialog's path */
537  char** inputword, /**< pointer to store the next word in the handler's command buffer */
538  SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
539  )
540 {
541  char path[SCIP_MAXSTRLEN+1];
542  char p[SCIP_MAXSTRLEN];
543  char* firstword;
544  int pos;
545 
546  assert(dialoghdlr != NULL);
547  assert(dialoghdlr->buffer != NULL);
548  assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
549  assert(inputword != NULL);
550  assert(endoffile != NULL);
551 
552  *endoffile = FALSE;
553 
554  /* get input from the user, if the buffer is empty */
555  if( SCIPdialoghdlrIsBufferEmpty(dialoghdlr) )
556  {
557  int len;
558 
559  /* clear the buffer */
560  SCIPdialoghdlrClearBuffer(dialoghdlr);
561 
562  if( prompt == NULL )
563  {
564  /* use current dialog's path as prompt */
565  SCIPdialogGetPath(dialog, '/', path);
566  (void) SCIPsnprintf(p, SCIP_MAXSTRLEN, "%s> ", path);
567  prompt = p;
568  }
569 
570  /* read command line from stdin or from the input line list */
571  SCIP_CALL( readInputLine(dialoghdlr, prompt, endoffile) );
572 
573  /* strip trailing spaces */
574  len = (int)strlen(&dialoghdlr->buffer[dialoghdlr->bufferpos]);
575  if( len > 0 )
576  {
577  while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1]) )
578  {
579  dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1] = '\0';
580  len--;
581  }
582  }
583 
584  /* insert command in command history */
585  if( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' )
586  {
587  SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, NULL, &dialoghdlr->buffer[dialoghdlr->bufferpos], FALSE) );
588  }
589  }
590 
591  /* the last character in the buffer must be a '\0' */
592  dialoghdlr->buffer[dialoghdlr->buffersize-1] = '\0';
593 
594  /* skip leading spaces: find start of first word */
595  while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
596  dialoghdlr->bufferpos++;
597  firstword = &dialoghdlr->buffer[dialoghdlr->bufferpos];
598 
599  pos = dialoghdlr->bufferpos;
600  while( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' && !isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
601  {
602  assert(pos <= dialoghdlr->bufferpos);
603 
604  switch( dialoghdlr->buffer[dialoghdlr->bufferpos] )
605  {
606  case '"':
607  dialoghdlr->bufferpos++;
608  /* read characters as they are until the next " */
609  while( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' && dialoghdlr->buffer[dialoghdlr->bufferpos] != '"' )
610  {
611  /* watch out for \" and \\ which should be treated as " and \, respectively */
612  if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\\'
613  && (dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '"'
614  || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\\') )
615  {
616  dialoghdlr->bufferpos++;
617  }
618  dialoghdlr->buffer[pos] = dialoghdlr->buffer[dialoghdlr->bufferpos];
619  pos++;
620  dialoghdlr->bufferpos++;
621  }
622  if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '"' )
623  dialoghdlr->bufferpos++; /* skip final " */
624  break;
625  case '\'':
626  dialoghdlr->bufferpos++;
627  /* read characters as they are until the next ' */
628  while( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' && dialoghdlr->buffer[dialoghdlr->bufferpos] != '\'' )
629  {
630  /* watch out for \' and \\ which should be treated as ' and \, respectively */
631  if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\\'
632  && (dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\''
633  || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\\') )
634  {
635  dialoghdlr->bufferpos++;
636  }
637  dialoghdlr->buffer[pos] = dialoghdlr->buffer[dialoghdlr->bufferpos];
638  pos++;
639  dialoghdlr->bufferpos++;
640  }
641  if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\'' )
642  dialoghdlr->bufferpos++; /* skip final ' */
643  break;
644  case '\\':
645  /* if the next character is a space, a ", or a ', read next character as it is;
646  * otherwise, treat the \ as normal character
647  */
648  if( dialoghdlr->buffer[dialoghdlr->bufferpos+1] == ' '
649  || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '"'
650  || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\'' )
651  {
652  dialoghdlr->bufferpos++;
653  }
654  /*lint -fallthrough*/
655  default:
656  dialoghdlr->buffer[pos] = dialoghdlr->buffer[dialoghdlr->bufferpos];
657  pos++;
658  dialoghdlr->bufferpos++;
659  break;
660  }
661  }
662  assert(pos <= dialoghdlr->bufferpos);
663 
664  /* move buffer to the next position */
665  if( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' )
666  dialoghdlr->bufferpos++;
667 
668  /* truncate the command word in the buffer */
669  if( dialoghdlr->buffer[pos] != '\0' )
670  dialoghdlr->buffer[pos] = '\0';
671 
672  /* remove additional spaces */
673  while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
674  dialoghdlr->bufferpos++;
675 
676  *inputword = firstword;
677 
678  SCIPdebugMessage("next word: <%s>\n", *inputword);
679 
680  return SCIP_OKAY;
681 }
682 
683 /** adds a single line of input to the dialog handler which is treated as if the user entered the command line */
685  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
686  const char* inputline /**< input line to add */
687  )
688 {
689  SCIP_LINELIST* linelist;
690  SCIP_RETCODE retcode = SCIP_OKAY;
691 
692  assert(dialoghdlr != NULL);
693  assert(dialoghdlr->inputlistptr != NULL);
694  assert(*dialoghdlr->inputlistptr == NULL);
695  assert(inputline != NULL);
696 
697  SCIP_ALLOC( BMSallocMemory(&linelist) );
698  SCIP_ALLOC_TERMINATE( retcode, BMSduplicateMemoryArray(&linelist->inputline, inputline, strlen(inputline)+1), TERMINATE );
699  linelist->nextline = NULL;
700  *dialoghdlr->inputlistptr = linelist;
701  dialoghdlr->inputlistptr = &linelist->nextline;
702 
703  TERMINATE:
704  if( retcode != SCIP_OKAY )
705  BMSfreeMemory(&linelist);
706 
707  return retcode;
708 }
709 
710 /** adds a command to the command history of the dialog handler; if a dialog is given, the command is preceeded
711  * by the dialog's command path; if no command is given, only the path to the dialog is added to the command history
712  */
714  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
715  SCIP_DIALOG* dialog, /**< current dialog, or NULL */
716  const char* command, /**< command string to add to the command history, or NULL */
717  SCIP_Bool escapecommand /**< should special characters in command be prefixed by an escape char? */
718  )
719 {
720  char s[SCIP_MAXSTRLEN];
721  char h[SCIP_MAXSTRLEN+1];
722  SCIP_Bool cleanuphistory;
723 
724  assert(dialoghdlr != NULL);
725 
726  /* the current history list should be cleaned up if a dialog is given (i.e. the command is not partial) */
727  cleanuphistory = (dialog != NULL);
728 
729  /* generate the string to add to the history */
730  s[SCIP_MAXSTRLEN-1] = '\0';
731 
732  if( command != NULL )
733  {
734  if( escapecommand )
735  SCIPescapeString(h, SCIP_MAXSTRLEN, command);
736  else
737  (void)SCIPstrncpy(h, command, SCIP_MAXSTRLEN);
738  }
739  else
740  h[0] = '\0';
741 
742  while( dialog != NULL && dialog != dialoghdlr->rootdialog )
743  {
744  if( h[0] == '\0' )
745  (void)SCIPstrncpy(h, dialog->name, SCIP_MAXSTRLEN);
746  else
747  {
748  (void)SCIPsnprintf(s, SCIP_MAXSTRLEN, "%s %s", dialog->name, h);
749  (void)SCIPstrncpy(h, s, SCIP_MAXSTRLEN);
750  }
751  dialog = dialog->parent;
752  }
753 
754  /* clean up the unmarked history entries */
755  if( cleanuphistory )
756  {
757  int i;
758 
759  for( i = getHistoryLength()-1; i >= dialoghdlr->nprotectedhistelems; --i )
760  {
761  SCIP_CALL( removeHistory(i) );
762  }
763  }
764 
765  /* add command to history */
766  if( h[0] != '\0' )
767  {
768  SCIP_CALL( addHistory(h) );
769  }
770 
771  /* if the history string was a full command line, protect the history entry from future cleanups */
772  if( cleanuphistory )
773  {
774  dialoghdlr->nprotectedhistelems = getHistoryLength();
775  }
776 
777  return SCIP_OKAY;
778 }
779 
780 
781 
782 
783 /*
784  * dialog
785  */
786 
787 /** ensures, that sub-dialogs array can store at least the given number of sub-dialogs */
788 static
790  SCIP_DIALOG* dialog, /**< dialog */
791  SCIP_SET* set, /**< global SCIP settings */
792  int num /**< minimal storage size for sub-dialogs */
793  )
794 {
795  assert(dialog != NULL);
796 
797  if( num > dialog->subdialogssize )
798  {
799  int newsize;
800 
801  newsize = SCIPsetCalcMemGrowSize(set, num);
802  SCIP_ALLOC( BMSreallocMemoryArray(&(dialog->subdialogs), newsize) );
803  dialog->subdialogssize = newsize;
804  }
805  assert(num <= dialog->subdialogssize);
806 
807  return SCIP_OKAY;
808 }
809 
810 /** creates and captures a user interface dialog */
812  SCIP_DIALOG** dialog, /**< pointer to store the dialog */
813  SCIP_DECL_DIALOGCOPY ((*dialogcopy)), /**< copy method of dialog or NULL if you don't want to copy your plugin into sub-SCIPs */
814  SCIP_DECL_DIALOGEXEC ((*dialogexec)), /**< execution method of dialog */
815  SCIP_DECL_DIALOGDESC ((*dialogdesc)), /**< description output method of dialog, or NULL */
816  SCIP_DECL_DIALOGFREE ((*dialogfree)), /**< destructor of dialog to free user data, or NULL */
817  const char* name, /**< name of dialog: command name appearing in parent's dialog menu */
818  const char* desc, /**< description of dialog used if description output method is NULL */
819  SCIP_Bool issubmenu, /**< is the dialog a sub-menu? */
820  SCIP_DIALOGDATA* dialogdata /**< user defined dialog data */
821  )
822 {
823  SCIP_RETCODE retcode;
824 
825  assert(dialog != NULL);
826  assert(name != NULL);
827 
828  retcode = SCIP_OKAY;
829 
830  SCIP_ALLOC( BMSallocMemory(dialog) );
831  (*dialog)->dialogcopy = dialogcopy;
832  (*dialog)->dialogexec = dialogexec;
833  (*dialog)->dialogdesc = dialogdesc;
834  (*dialog)->dialogfree = dialogfree;
835 
836  SCIP_ALLOC_TERMINATE( retcode, BMSduplicateMemoryArray(&(*dialog)->name, name, strlen(name)+1), TERMINATE );
837  if( desc != NULL )
838  {
839  SCIP_ALLOC_TERMINATE( retcode, BMSduplicateMemoryArray(&(*dialog)->desc, desc, strlen(desc)+1), TERMINATE );
840  }
841  else
842  (*dialog)->desc = NULL;
843 
844  (*dialog)->issubmenu = issubmenu;
845  (*dialog)->parent = NULL;
846  (*dialog)->subdialogs = NULL;
847  (*dialog)->nsubdialogs = 0;
848  (*dialog)->subdialogssize = 0;
849  (*dialog)->nuses = 0;
850  (*dialog)->dialogdata = dialogdata;
851 
852  /* capture dialog */
853  SCIPdialogCapture(*dialog);
854 
855  TERMINATE:
856  if( retcode != SCIP_OKAY )
857  {
858  BMSfreeMemoryArrayNull(&(*dialog)->name);
859  BMSfreeMemory(dialog);
860  }
861 
862  return retcode;
863 }
864 
865 /** frees dialog and all of its sub-dialogs */
866 static
868  SCIP* scip, /**< SCIP data structure */
869  SCIP_DIALOG** dialog /**< pointer to dialog */
870  )
871 {
872  int i;
873 
874  assert(dialog != NULL);
875  assert(*dialog != NULL);
876  assert((*dialog)->nuses == 0);
877 
878  /* call destructor of dialog */
879  if( (*dialog)->dialogfree != NULL )
880  {
881  SCIP_CALL( (*dialog)->dialogfree(scip, *dialog) );
882  }
883 
884  /* release sub-dialogs */
885  for( i = 0; i < (*dialog)->nsubdialogs; ++i )
886  {
887  SCIP_CALL( SCIPdialogRelease(scip, &(*dialog)->subdialogs[i]) );
888  }
889  BMSfreeMemoryArrayNull(&(*dialog)->subdialogs);
890 
891  BMSfreeMemoryArrayNull(&(*dialog)->name);
892  BMSfreeMemoryArrayNull(&(*dialog)->desc);
893  BMSfreeMemory(dialog);
894 
895  return SCIP_OKAY;
896 }
897 
898 /** captures a dialog */
900  SCIP_DIALOG* dialog /**< dialog */
901  )
902 {
903  assert(dialog != NULL);
904 
905  dialog->nuses++;
906 }
907 
908 /** releases a dialog */
910  SCIP* scip, /**< SCIP data structure */
911  SCIP_DIALOG** dialog /**< pointer to dialog */
912  )
913 {
914  assert(dialog != NULL);
915 
916  (*dialog)->nuses--;
917  if( (*dialog)->nuses == 0 )
918  {
919  SCIP_CALL( dialogFree(scip, dialog) );
920  }
921 
922  return SCIP_OKAY;
923 }
924 
925 /** executes dialog */
927  SCIP_DIALOG* dialog, /**< dialog */
928  SCIP_SET* set, /**< global SCIP settings */
929  SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
930  SCIP_DIALOG** nextdialog /**< pointer to store the next dialog to process */
931  )
932 {
933  assert(dialog != NULL);
934  assert(dialog->dialogexec != NULL);
935  assert(set != NULL);
936  assert(nextdialog != NULL);
937 
938  SCIP_CALL( dialog->dialogexec(set->scip, dialog, dialoghdlr, nextdialog) );
939 
940  return SCIP_OKAY;
941 }
942 
943 /** comparison method for sorting dialogs w.r.t. to their name */
944 static
946 {
947  return strcmp( SCIPdialogGetName((SCIP_DIALOG*)elem1), SCIPdialogGetName((SCIP_DIALOG*)elem2) );
948 }
949 
950 /** adds a sub-dialog to the given dialog as menu entry and captures the sub-dialog */
952  SCIP_DIALOG* dialog, /**< dialog */
953  SCIP_SET* set, /**< global SCIP settings */
954  SCIP_DIALOG* subdialog /**< sub-dialog to add as menu entry in dialog */
955  )
956 {
957  assert(dialog != NULL);
958  assert(subdialog != NULL);
959 
960  /* check, if sub-dialog already exists */
961  if( SCIPdialogHasEntry(dialog, SCIPdialogGetName(subdialog)) )
962  {
963  SCIPerrorMessage("dialog entry with name <%s> already exists in dialog <%s>\n",
964  SCIPdialogGetName(subdialog), SCIPdialogGetName(dialog));
965  return SCIP_INVALIDDATA;
966  }
967 
968  /* resize the sub-dialogs array */
969  SCIP_CALL( ensureSubdialogMem(dialog, set, dialog->nsubdialogs+1) );
970 
971  /* link the dialogs as parent-child pair; the sub-dialogs are sorted non-decreasing w.r.t. their name */
972  SCIPsortedvecInsertPtr((void**)dialog->subdialogs, dialogComp, (void*)subdialog, &dialog->nsubdialogs, NULL);
973  subdialog->parent = dialog;
974 
975  /* capture sub-dialog */
976  SCIPdialogCapture(subdialog);
977 
978  return SCIP_OKAY;
979 }
980 
981 /** returns TRUE iff a dialog entry matching exactly the given name is existing in the given dialog */
983  SCIP_DIALOG* dialog, /**< dialog */
984  const char* entryname /**< name of the dialog entry to find */
985  )
986 {
987  SCIP_DIALOG** subdialogs;
988  int nsubdialogs;
989  int i;
990 
991  assert(dialog != NULL);
992  assert(entryname != NULL);
993 
994  /* check entryname w.r.t. available dialog options */
995  subdialogs = SCIPdialogGetSubdialogs(dialog);
996  nsubdialogs = SCIPdialogGetNSubdialogs(dialog);
997  for( i = 0; i < nsubdialogs; ++i )
998  {
999  /* check, if the sub-dialog's name matches entryname */
1000  if( strcmp(entryname, SCIPdialogGetName(subdialogs[i])) == 0 )
1001  return TRUE;
1002  }
1003 
1004  return FALSE;
1005 }
1006 
1007 /** searches the dialog for entries corresponding to the given name;
1008  * If a complete match is found, the entry is returned as "subdialog" and
1009  * the return value is 1.
1010  * If no dialog entry completely matches the given "entryname", the number
1011  * of entries with names beginning with "entryname" is returned. If this
1012  * number is 1, the single match is returned as "subdialog". Otherwise,
1013  * "subdialog" is set to NULL.
1014  */
1016  SCIP_DIALOG* dialog, /**< dialog */
1017  const char* entryname, /**< name of the dialog entry to find */
1018  SCIP_DIALOG** subdialog /**< pointer to store the found dialog entry */
1019  )
1020 {
1021  SCIP_DIALOG** subdialogs;
1022  unsigned int namelen;
1023  int nsubdialogs;
1024  int nfound;
1025  int i;
1026 
1027  assert(dialog != NULL);
1028  assert(entryname != NULL);
1029  assert(subdialog != NULL);
1030 
1031  *subdialog = NULL;
1032 
1033  /* check entryname w.r.t. available dialog options */
1034  subdialogs = SCIPdialogGetSubdialogs(dialog);
1035  nsubdialogs = SCIPdialogGetNSubdialogs(dialog);
1036  namelen = (unsigned int) strlen(entryname);
1037  nfound = 0;
1038  for( i = 0; i < nsubdialogs; ++i )
1039  {
1040  /* check, if the beginning of the sub-dialog's name matches entryname */
1041  if( strncmp(entryname, SCIPdialogGetName(subdialogs[i]), namelen) == 0 )
1042  {
1043  *subdialog = subdialogs[i];
1044  nfound++;
1045 
1046  /* if entryname exactly matches the sub-dialog's name, use this sub-dialog */
1047  if( namelen == (unsigned int) strlen(SCIPdialogGetName(subdialogs[i])) )
1048  return 1;
1049  }
1050  }
1051 
1052  if( nfound != 1 )
1053  *subdialog = NULL;
1054 
1055  return nfound;
1056 }
1057 
1058 /** displays the dialog's menu */
1060  SCIP_DIALOG* dialog, /**< dialog */
1061  SCIP* scip /**< SCIP data structure */
1062  )
1063 {
1064  int i;
1065 
1066  assert(dialog != NULL);
1067 
1068  /* display the dialog's sub menus */
1069  for( i = 0; i < dialog->nsubdialogs; ++i )
1070  {
1071  if( SCIPdialogIsSubmenu(dialog->subdialogs[i]) )
1072  {
1073  SCIP_CALL( SCIPdialogDisplayMenuEntry(dialog->subdialogs[i], scip) );
1074  }
1075  }
1076 
1077  /* display the dialog's menu options */
1078  for( i = 0; i < dialog->nsubdialogs; ++i )
1079  {
1080  if( !SCIPdialogIsSubmenu(dialog->subdialogs[i]) )
1081  {
1082  SCIP_CALL( SCIPdialogDisplayMenuEntry(dialog->subdialogs[i], scip) );
1083  }
1084  }
1085 
1086  if( dialog->nsubdialogs == 0 )
1087  SCIPdialogMessage(scip, NULL, "<no options available>\n");
1088 
1089  return SCIP_OKAY;
1090 }
1091 
1092 /** displays the entry for the dialog in it's parent's menu */
1094  SCIP_DIALOG* dialog, /**< dialog */
1095  SCIP* scip /**< SCIP data structure */
1096  )
1097 {
1098  char name[SCIP_MAXSTRLEN];
1099 
1100  assert(dialog != NULL);
1101 
1102  /* display the dialog's name */
1103  if( dialog->issubmenu )
1104  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "<%s>", dialog->name);
1105  else
1106  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s", dialog->name);
1107  SCIPdialogMessage(scip, NULL, " %-21s ", name);
1108  if( strlen(name) > 21 )
1109  {
1110  /* break the line, and start the description in the next line */
1111  SCIPdialogMessage(scip, NULL, "\n --> ");
1112  }
1113 
1114  /* display the dialog's description */
1115  if( dialog->dialogdesc != NULL )
1116  {
1117  SCIP_CALL( dialog->dialogdesc(scip, dialog) );
1118  }
1119  else
1120  SCIPdialogMessage(scip, NULL, "%s",dialog->desc);
1121  SCIPdialogMessage(scip, NULL, "\n");
1122 
1123  return SCIP_OKAY;
1124 }
1125 
1126 /** displays all dialog entries with names starting with the given "entryname" */
1128  SCIP_DIALOG* dialog, /**< dialog */
1129  SCIP* scip, /**< SCIP data structure */
1130  const char* entryname /**< name of the dialog entry to find */
1131  )
1132 {
1133  SCIP_DIALOG** subdialogs;
1134  unsigned int namelen;
1135  int nsubdialogs;
1136  int i;
1137 
1138  assert(dialog != NULL);
1139  assert(entryname != NULL);
1140 
1141  /* check entryname w.r.t. available dialog options */
1142  subdialogs = SCIPdialogGetSubdialogs(dialog);
1143  nsubdialogs = SCIPdialogGetNSubdialogs(dialog);
1144  namelen = (unsigned int) strlen(entryname);
1145  for( i = 0; i < nsubdialogs; ++i )
1146  {
1147  /* check, if the beginning of the sub-dialog's name matches entryname */
1148  if( strncmp(entryname, SCIPdialogGetName(subdialogs[i]), namelen) == 0 )
1149  {
1150  SCIP_CALL( SCIPdialogDisplayMenuEntry(subdialogs[i], scip) );
1151  }
1152  }
1153 
1154  return SCIP_OKAY;
1155 }
1156 
1157 /** gets the name of the current path in the dialog tree, separated by the given character */
1159  SCIP_DIALOG* dialog, /**< dialog */
1160  const char sepchar, /**< separation character to insert in path */
1161  char* path /**< string buffer to store the path */
1162  )
1163 {
1164  char s[SCIP_MAXSTRLEN];
1165 
1166  assert(dialog != NULL);
1167 
1168  (void)SCIPstrncpy(path, dialog->name, SCIP_MAXSTRLEN);
1169 
1170  dialog = dialog->parent;
1171  while( dialog != NULL )
1172  {
1173  (void)SCIPsnprintf(s, SCIP_MAXSTRLEN, "%s%c%s", dialog->name, sepchar, path);
1174  (void)SCIPstrncpy(path, s, SCIP_MAXSTRLEN);
1175  dialog = dialog->parent;
1176  }
1177 }
1178 
1179 /** gets the command name of the dialog */
1180 const char* SCIPdialogGetName(
1181  SCIP_DIALOG* dialog /**< dialog */
1182  )
1183 {
1184  assert(dialog != NULL);
1185 
1186  return dialog->name;
1187 }
1188 
1189 /** gets the description of the dialog */
1190 const char* SCIPdialogGetDesc(
1191  SCIP_DIALOG* dialog /**< dialog */
1192  )
1193 {
1194  assert(dialog != NULL);
1195 
1196  return dialog->desc;
1197 }
1198 
1199 /** returns whether the dialog is a sub menu */
1201  SCIP_DIALOG* dialog /**< dialog */
1202  )
1203 {
1204  assert(dialog != NULL);
1205 
1206  return dialog->issubmenu;
1207 }
1208 
1209 /** gets the parent dialog of the given dialog */
1211  SCIP_DIALOG* dialog /**< dialog */
1212  )
1213 {
1214  assert(dialog != NULL);
1215 
1216  return dialog->parent;
1217 }
1218 
1219 /** gets the array of sub-dialogs associated with the given dialog */
1221  SCIP_DIALOG* dialog /**< dialog */
1222  )
1223 {
1224  assert(dialog != NULL);
1225 
1226  return dialog->subdialogs;
1227 }
1228 
1229 /** gets the number of sub-dialogs associated with the given dialog */
1231  SCIP_DIALOG* dialog /**< dialog */
1232  )
1233 {
1234  assert(dialog != NULL);
1235 
1236  return dialog->nsubdialogs;
1237 }
1238 
1239 /** gets the user defined data associated with the given dialog */
1241  SCIP_DIALOG* dialog /**< dialog */
1242  )
1243 {
1244  assert(dialog != NULL);
1245 
1246  return dialog->dialogdata;
1247 }
1248 
1249 /** sets user data of dialog; user has to free old data in advance! */
1251  SCIP_DIALOG* dialog, /**< dialog */
1252  SCIP_DIALOGDATA* dialogdata /**< new dialog user data */
1253  )
1254 {
1255  assert(dialog != NULL);
1256 
1257  dialog->dialogdata = dialogdata;
1258 }
1259 
1260 /** writes command history to specified filename */
1262  const char* filename /**< file name for (over)writing history */
1263  )
1264 {
1265  return writeHistory(filename);
1266 }
int SCIPdialogGetNSubdialogs(SCIP_DIALOG *dialog)
Definition: dialog.c:1230
#define NULL
Definition: def.h:246
static SCIP_RETCODE dialogFree(SCIP *scip, SCIP_DIALOG **dialog)
Definition: dialog.c:867
void SCIPdialoghdlrClearBuffer(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:433
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:137
const char * SCIPdialogGetName(SCIP_DIALOG *dialog)
Definition: dialog.c:1180
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:262
SCIP_RETCODE SCIPdialogRelease(SCIP *scip, SCIP_DIALOG **dialog)
Definition: dialog.c:909
#define SCIP_DECL_DIALOGCOPY(x)
Definition: type_dialog.h:53
SCIP_RETCODE SCIPdialogExec(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG **nextdialog)
Definition: dialog.c:926
#define SCIP_MAXSTRLEN
Definition: def.h:267
SCIP_DIALOG ** SCIPdialogGetSubdialogs(SCIP_DIALOG *dialog)
Definition: dialog.c:1220
void SCIPdialogGetPath(SCIP_DIALOG *dialog, const char sepchar, char *path)
Definition: dialog.c:1158
SCIP_RETCODE SCIPdialogDisplayMenuEntry(SCIP_DIALOG *dialog, SCIP *scip)
Definition: dialog.c:1093
SCIP_RETCODE SCIPdialogDisplayCompletions(SCIP_DIALOG *dialog, SCIP *scip, const char *entryname)
Definition: dialog.c:1127
data structures for user interface dialog
#define FALSE
Definition: def.h:72
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10253
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5503
int SCIPdialogFindEntry(SCIP_DIALOG *dialog, const char *entryname, SCIP_DIALOG **subdialog)
Definition: dialog.c:1015
SCIP_LINELIST * nextline
Definition: struct_dialog.h:57
static void linelistFree(SCIP_LINELIST **linelist)
Definition: dialog.c:229
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:112
struct SCIP_DialogData SCIP_DIALOGDATA
Definition: type_dialog.h:42
static void linelistFreeAll(SCIP_LINELIST **linelist)
Definition: dialog.c:241
#define SCIPdebugMessage
Definition: pub_message.h:77
char * inputline
Definition: struct_dialog.h:56
#define BMSfreeMemory(ptr)
Definition: memory.h:134
int SCIPstrncpy(char *t, const char *s, int size)
Definition: misc.c:10296
SCIP_DIALOG * SCIPdialogGetParent(SCIP_DIALOG *dialog)
Definition: dialog.c:1210
static SCIP_RETCODE ensureSubdialogMem(SCIP_DIALOG *dialog, SCIP_SET *set, int num)
Definition: dialog.c:789
void SCIPdialogSetData(SCIP_DIALOG *dialog, SCIP_DIALOGDATA *dialogdata)
Definition: dialog.c:1250
void SCIPdialogCapture(SCIP_DIALOG *dialog)
Definition: dialog.c:899
#define SCIP_DECL_DIALOGDESC(x)
Definition: type_dialog.h:73
static SCIP_RETCODE writeHistory(const char *filename)
Definition: dialog.c:217
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:136
SCIP_DIALOG ** subdialogs
Definition: struct_dialog.h:45
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPdialogWriteHistory(const char *filename)
Definition: dialog.c:1261
static SCIP_RETCODE addHistory(const char *s)
Definition: dialog.c:187
void SCIPescapeString(char *t, int bufsize, const char *s)
Definition: misc.c:10225
SCIP_DIALOG * parent
Definition: struct_dialog.h:44
SCIP_RETCODE SCIPdialogDisplayMenu(SCIP_DIALOG *dialog, SCIP *scip)
Definition: dialog.c:1059
SCIP_RETCODE SCIPdialoghdlrCreate(SCIP_SET *set, SCIP_DIALOGHDLR **dialoghdlr)
Definition: dialog.c:324
const char * SCIPdialogGetDesc(SCIP_DIALOG *dialog)
Definition: dialog.c:1190
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:358
SCIP_VAR * h
Definition: circlepacking.c:59
SCIP_Bool issubmenu
Definition: struct_dialog.h:50
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:132
SCIP_LINELIST * inputlist
Definition: struct_dialog.h:64
int subdialogssize
Definition: struct_dialog.h:48
public data structures and miscellaneous methods
SCIP_RETCODE SCIPdialogCreate(SCIP_DIALOG **dialog, SCIP_DECL_DIALOGCOPY((*dialogcopy)), SCIP_DECL_DIALOGEXEC((*dialogexec)), SCIP_DECL_DIALOGDESC((*dialogdesc)), SCIP_DECL_DIALOGFREE((*dialogfree)), const char *name, const char *desc, SCIP_Bool issubmenu, SCIP_DIALOGDATA *dialogdata)
Definition: dialog.c:811
SCIP_DIALOGDATA * dialogdata
Definition: struct_dialog.h:46
internal methods for user interface dialog
#define SCIP_Bool
Definition: def.h:69
SCIP_Bool SCIPdialogHasEntry(SCIP_DIALOG *dialog, const char *entryname)
Definition: dialog.c:982
SCIP_RETCODE SCIPdialoghdlrAddInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *inputline)
Definition: dialog.c:684
static int getHistoryLength(void)
Definition: dialog.c:197
SCIP_Bool SCIPdialogIsSubmenu(SCIP_DIALOG *dialog)
Definition: dialog.c:1200
SCIP_RETCODE SCIPsetIncludeExternalCode(SCIP_SET *set, const char *name, const char *description)
Definition: set.c:4984
static SCIP_DECL_SORTPTRCOMP(dialogComp)
Definition: dialog.c:945
SCIP_LINELIST ** inputlistptr
Definition: struct_dialog.h:65
#define SCIPsetDebugMsg
Definition: set.h:1940
SCIP_RETCODE SCIPdialoghdlrSetRoot(SCIP *scip, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog)
Definition: dialog.c:400
#define SCIP_DECL_DIALOGFREE(x)
Definition: type_dialog.h:61
SCIP_RETCODE SCIPdialoghdlrGetWord(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *prompt, char **inputword, SCIP_Bool *endoffile)
Definition: dialog.c:533
void SCIPsortedvecInsertPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *keyval, int *len, int *pos)
SCIP_RETCODE SCIPdialoghdlrAddHistory(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *command, SCIP_Bool escapecommand)
Definition: dialog.c:713
#define SCIP_DECL_DIALOGEXEC(x)
Definition: type_dialog.h:87
SCIP_DIALOG * SCIPdialoghdlrGetRoot(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:423
SCIP_RETCODE SCIPdialogCopyInclude(SCIP_DIALOG *dialog, SCIP_SET *set)
Definition: dialog.c:306
SCIP_DIALOG * rootdialog
Definition: struct_dialog.h:63
SCIP_Bool SCIPdialoghdlrIsBufferEmpty(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:444
static SCIP_RETCODE readLine(SCIP_DIALOGHDLR *dialoghdlr, const char *prompt, SCIP_Bool *endoffile)
Definition: dialog.c:146
static SCIP_RETCODE readInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *prompt, SCIP_Bool *endoffile)
Definition: dialog.c:259
#define BMSallocMemory(ptr)
Definition: memory.h:108
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:116
SCIP_RETCODE SCIPdialogAddEntry(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOG *subdialog)
Definition: dialog.c:951
SCIP_RETCODE SCIPdialoghdlrGetLine(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *prompt, char **inputline, SCIP_Bool *endoffile)
Definition: dialog.c:457
SCIP_RETCODE SCIPdialoghdlrExec(SCIP_DIALOGHDLR *dialoghdlr, SCIP_SET *set)
Definition: dialog.c:372
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPdialoghdlrFree(SCIP *scip, SCIP_DIALOGHDLR **dialoghdlr)
Definition: dialog.c:354
SCIP_DIALOGDATA * SCIPdialogGetData(SCIP_DIALOG *dialog)
Definition: dialog.c:1240
#define SCIP_ALLOC_TERMINATE(retcode, x, TERM)
Definition: def.h:389
#define SCIP_ALLOC(x)
Definition: def.h:369
static SCIP_RETCODE removeHistory(int pos)
Definition: dialog.c:206
SCIP callable library.
memory allocation routines