IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5919


Ignore:
Timestamp:
Jan 5, 2006, 6:55:37 PM (21 years ago)
Author:
eugene
Message:

split init into general and program init, cleaned up open_image, open_graph, and related

Location:
trunk/Ohana/src/opihi
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/box.c

    r5850 r5919  
    66  Graphdata graphmode;
    77 
    8   if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE);
    9 
    108  strcpy (graphmode.ticks, "2222");
    119  if ((N = get_argument (argc, argv, "-ticks"))) {
     
    4745    remove_argument (N, &argc, argv);
    4846  }
     47  if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE);
    4948
    5049  if (argc != 1) goto usage;
  • trunk/Ohana/src/opihi/dimm/dimm.c

    r4714 r5919  
    88
    99/* program-dependent initialization */
    10 void initialize (int argc, char **argv) {
     10void program_init (int *argc, char **argv) {
    1111 
    1212  auto_break = TRUE;
     
    2424  set_str_variable ("PROMPT", opihi_prompt);
    2525  set_str_variable ("RCFILE", opihi_rcfile);
     26
    2627# ifdef HELPDIR_DEFAULT
    2728  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
    2829# endif
    2930
    30   { /* check history file permission */
    31     FILE *f;
    32     f = fopen (opihi_history, "a");
    33     if (f == NULL) /* no current history file here */
    34       fprintf (stderr, "can't save history.\n");
    35     else
    36       fclose (f);
    37     stifle_history (200);
    38     read_history (opihi_history);
    39   }
    40 
    41   signal (SIGINT, SIG_IGN);
    4231  return;
    4332}
  • trunk/Ohana/src/opihi/dvo/dvo.c

    r5900 r5919  
    88
    99/* program-dependent initialization */
    10 void program_init (int argc, char **argv) {
     10void program_init (int *argc, char **argv) {
    1111 
    1212  auto_break = TRUE;
     
    1818  InitDVO ();
    1919
    20   if (!SetCATDIR (NULL, TRUE)) {
     20  if (!SetCATDIR (NULL, FALSE)) {
    2121    fprintf (stderr, "CATDIR is not defined\n");
    2222  }
  • trunk/Ohana/src/opihi/include/shell.h

    r5900 r5919  
    4444
    4545/*** basic opihi shell functions ***/
    46 void          general_init              PROTO((int argc, char **argv));
    47 void          program_init              PROTO((int argc, char **argv));
    48 void          startup                   PROTO((int argc, char **argv));
     46void          general_init              PROTO((int *argc, char **argv));
     47void          program_init              PROTO((int *argc, char **argv));
     48void          startup                   PROTO((int *argc, char **argv));
    4949int           multicommand              PROTO((char *line));
    5050int           command                   PROTO((char *, char **));
  • trunk/Ohana/src/opihi/lib.data/open_graph.c

    r5850 r5919  
    55# define NXGRAPH 5
    66
    7 static int       IsImage = FALSE;
    87static int       Active;
    98static int       Xgraph[NXGRAPH]; 
    109static Graphdata graphdata[NXGRAPH];
    1110
    12 int GetCurrentDevice () {
    13   return (IsImage);
    14 }
    1511
    16 void SetImageDevice (int state) {
    17   IsImage = state;
    18 }
    1912
    2013void QuitGraph () {
     
    6962
    7063  int fd;
    71   char *kapa_exec;
     64  char *kapa_exec, name[16];
    7265 
    7366  kapa_exec = get_variable ("KAPA");
     
    7770  }
    7871
    79   fd = KiiOpen (kapa_exec, NULL);
     72  snprintf (name, 16, "[%d]", N);
     73  fd = KiiOpen (kapa_exec, name);
     74  free (kapa_exec);
    8075
    8176  if (fd < 0) {
     
    158153  graphdata[Active] = data;
    159154}
     155
     156/** internal tracking of current active device type **/
     157
     158static int       IsImage = FALSE;
     159
     160int GetCurrentDevice () {
     161  return (IsImage);
     162}
     163
     164void SetImageDevice (int state) {
     165  IsImage = state;
     166}
     167
  • trunk/Ohana/src/opihi/lib.data/open_image.c

    r5846 r5919  
    11# include "display.h"
    2 
    32# define DEBUG 0
    43
     
    1110static double    Xzero[NXIMAGE];
    1211static double    Xrange[NXIMAGE];
    13 
    14 /* define a structure to carry the relevant image data, eqiv to GraphData? */
    1512
    1613void QuitImage () {
     
    3633}
    3734
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
    3853/* set SIGPIPE to this function to close cleanly */
    3954void XImageDead (int input) {
     
    4762
    4863  int fd;
    49   char *kii_exec;
     64  char *kii_exec, name[16];
    5065
    5166  kii_exec = get_variable ("KII");
     
    5570  }
    5671
    57   fd = KiiOpen (kii_exec, NULL);
     72  snprintf (name, 16, "[%d]", N);
     73  fd = KiiOpen (kii_exec, name);
    5874  free (kii_exec);
    5975
  • trunk/Ohana/src/opihi/lib.shell/opihi.c

    r5900 r5919  
    88  pid_t ppid;
    99
    10   general_init (argc, argv);
    11   program_init (argc, argv);
    12   startup (argc, argv);
     10  general_init (&argc, argv);
     11  program_init (&argc, argv);
     12  startup (&argc, argv);
    1313  prompt = get_variable("PROMPT");
    1414  history = get_variable("HISTORY");
  • trunk/Ohana/src/opihi/lib.shell/startup.c

    r5900 r5919  
    66 */
    77
    8 void general_init (int argc, char **argv) {
     8void general_init (int *argc, char **argv) {
    99
    1010  /* init srand for rnd numbers elsewhere */
     
    1818
    1919  /* load config data (.ptolemyrc) */
    20   if (!ConfigInit (&argc, argv)) {
     20  if (!ConfigInit (argc, argv)) {
    2121    fprintf (stderr, "can't find config file. some functions will be unavailable\n");
    2222  }
     
    2525}
    2626
    27 void startup (int argc, char **argv) {
     27void startup (int *argc, char **argv) {
    2828   
    2929    int i, N, status, ONLY_INPUT, LOAD_RC;
     
    3131    char *rcfile, **list;
    3232    int Nlist, NLIST;
    33     static char dot[] = ".";
    3433   
    3534    /* load in interesting environment variables */
     
    3736   
    3837    home = getenv ("HOME");
    39     if (home == NULL) home = dot;
    40     set_str_variable ("HOME", home);
     38    if (home == NULL)
     39      set_str_variable ("HOME", ".");
     40    else
     41      set_str_variable ("HOME", home);
    4142    set_str_variable ("KII", "kii");
    4243    set_str_variable ("KAPA", "kapa");
     
    5455    char *opihi_history;
    5556
    56     opihi_history = get_variable ("RCFILE");
     57    opihi_history = get_variable ("HISTORY");
    5758    f = fopen (opihi_history, "a");
    5859    if (f == NULL) /* no current history file here */
     
    8485      }
    8586    }
     87  }
    8688
    8789    LOAD_RC = TRUE;
    88     if ((N = get_argument (argc, argv, "--norc"))) {
    89       remove_argument (N, &argc, argv);
     90    if ((N = get_argument (*argc, argv, "--norc"))) {
     91      remove_argument (N, argc, argv);
    9092      LOAD_RC = FALSE;
    9193    }
    9294   
    9395    ONLY_INPUT = FALSE;
    94     if ((N = get_argument (argc, argv, "--only"))) {
    95       remove_argument (N, &argc, argv);
     96    if ((N = get_argument (*argc, argv, "--only"))) {
     97      remove_argument (N, argc, argv);
    9698      ONLY_INPUT = TRUE;
    9799    }
     
    101103    NLIST = 10;
    102104    ALLOCATE (list, char *, NLIST);
    103     while ((N = get_argument (argc, argv, "--load"))) {
    104       remove_argument (N, &argc, argv);
     105    while ((N = get_argument (*argc, argv, "--load"))) {
     106      remove_argument (N, argc, argv);
    105107      list[Nlist] = strcreate (argv[N]);
    106       remove_argument (N, &argc, argv);
     108      remove_argument (N, argc, argv);
    107109      Nlist++;
    108110      if (Nlist == NLIST) {
     
    113115
    114116    is_script = TRUE;
    115     if (argc == 1) is_script = FALSE;
     117    if (*argc == 1) is_script = FALSE;
    116118    set_int_variable ("SCRIPT", is_script);
    117119
     
    130132      /* generate list argv:0 - argv:n from arguments */
    131133      ALLOCATE (varname, char, 256);
    132       for (i = 2; i < argc; i++) {
     134      for (i = 2; i < *argc; i++) {
    133135        sprintf (varname, "argv:%d", i - 2);
    134136        set_str_variable (varname, argv[i]);
     
    150152    if (ONLY_INPUT) exit (2);
    151153    if (is_script) exit (2);
    152   }
     154    return;
    153155}
  • trunk/Ohana/src/opihi/mana/mana.c

    r4714 r5919  
    88
    99/* program-dependent initialization */
    10 void initialize (int argc, char **argv) {
     10void program_init (int argc, char **argv) {
    1111 
    1212  auto_break = TRUE;
     
    2424  set_str_variable ("PROMPT", opihi_prompt);
    2525  set_str_variable ("RCFILE", opihi_rcfile);
     26
    2627# ifdef HELPDIR_DEFAULT
    2728  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
    2829# endif
    2930
    30   { /* check history file permission */
    31     FILE *f;
    32     f = fopen (opihi_history, "a");
    33     if (f == NULL) /* no current history file here */
    34       fprintf (stderr, "can't save history.\n");
    35     else
    36       fclose (f);
    37     stifle_history (200);
    38     read_history (opihi_history);
    39   }
    40 
    41   signal (SIGINT, SIG_IGN);
    4231  return;
    4332}
  • trunk/Ohana/src/opihi/pantasks/psched.c

    r4763 r5919  
    88
    99/* program-dependent initialization */
    10 void initialize (int argc, char **argv) {
     10void program_init (int *argc, char **argv) {
    1111 
    1212  auto_break = TRUE;
     
    2525  set_str_variable ("PROMPT", opihi_prompt);
    2626  set_str_variable ("RCFILE", opihi_rcfile);
     27
    2728# ifdef HELPDIR_DEFAULT
    2829  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
    2930# endif
    3031
    31   { /* check history file permission */
    32     FILE *f;
    33     f = fopen (opihi_history, "a");
    34     if (f == NULL) /* no current history file here */
    35       fprintf (stderr, "can't save history.\n");
    36     else
    37       fclose (f);
    38     stifle_history (200);
    39     read_history (opihi_history);
    40   }
    41 
    42   signal (SIGINT, SIG_IGN);
    4332  signal (SIGPIPE, gotsignal);
    4433  signal (SIGTSTP, gotsignal);
  • trunk/Ohana/src/opihi/pclient/pclient.c

    r4763 r5919  
    88
    99/* program-dependent initialization */
    10 void initialize (int argc, char **argv) {
     10void program_init (int *argc, char **argv) {
    1111 
    1212  auto_break = TRUE;
     
    3131
    3232  /* ignore the history file.  to change this, see, eg, mana.c */
    33   signal (SIGINT, SIG_IGN);
    3433  signal (SIGPIPE, gotsignal);
    3534  signal (SIGTSTP, gotsignal);
  • trunk/Ohana/src/opihi/pcontrol/pcontrol.c

    r4763 r5919  
    88
    99/* program-dependent initialization */
    10 void initialize (int argc, char **argv) {
     10void program_init (int *argc, char **argv) {
    1111 
    1212  auto_break = TRUE;
     
    2424  set_str_variable ("PROMPT", opihi_prompt);
    2525  set_str_variable ("RCFILE", opihi_rcfile);
     26
    2627# ifdef HELPDIR_DEFAULT
    2728  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
     
    2930
    3031  /* ignore the history file.  to change this, see, eg, mana.c */
    31   signal (SIGINT, SIG_IGN);
    3232  signal (SIGPIPE, gotsignal);
    3333  signal (SIGTSTP, gotsignal);
Note: See TracChangeset for help on using the changeset viewer.