Beispiel #1
0
static	BOOL	check(t_get *link, t_header *head, char *line)
{
  line = link->line;
  if (NMATCH(NAME_CMD_STRING, line + hempty(line)))
    head->name =  get(NAME_CMD_STRING, line, 0, link->no);
  else if (NMATCH(COMMENT_CMD_STRING, line + hempty(line)))
    head->comment = get(COMMENT_CMD_STRING, line, 1, link->no);
  else
    {
      if (nempty(line, my_strilen(line, COMMENT_CHAR)))
	return (ERROR);
      else if (nempty(line, my_strilen(line, SCOMMENT_CHAR)))
	return (ERROR);
      if (IN(line, COMMENT_CHAR))
	{
	  link->line = my_strndup(line, my_strilen(line, COMMENT_CHAR));
	  free(line);
	}
      line = link->line;
      if (IN(line, SCOMMENT_CHAR))
	{
	  link->line = my_strndup(line, my_strilen(line, SCOMMENT_CHAR));
	  free(line);
	}
      return (CLEAN);
    }
  return (ERROR);
}
Beispiel #2
0
Flist loaddf(char *fname)
{
	Flist df;
	int fd, n;
	char *txt;

	if (!fname)
		return (Flist) 0;
	if (strlen(fname) >= FNSIZE)
		return (Flist) 0;
	if ((fd = open(fname,O_RDONLY|O_BINARY)) < 0)
		return (Flist) 0;
	if ((df = mkFlist(NSIZE,FNSIZE)) == (Flist) 0)  {
		close(fd);
		return (Flist) 0;
	}
	strcpy(Flistdptr(df),fname);
	while ((txt = iquedptr(df,(void *) 0)) != (char *) 0)
		if ((n = read(fd,txt,NSIZE)) < NSIZE)  {
			for (; n < NSIZE; n++)
				txt[n] = '\0';
			break;
		}
	close(fd);
	if (!nempty(df))
		rmFlist(&df);
	return df;
}
Beispiel #3
0
void	scan_export(t_alias **alias)
{
  int		no;
  BOOL		c;
  char		*s;
  FD		file;

  c = TRUE;
  no = 0;
  if ((file = open_it()) == -1)
    return ;
  while ((s = get_next_line(file)) != NULL && c)
    {
      if (NMATCH("export", s))
	c = export_env(s + my_strlen("export")
		       + hempty(s + my_strlen("export")), no);
      else if (NMATCH("alias", s))
	c = export_alias(s + my_strlen("export")
			 + hempty(s + my_strlen("export")),
			 alias, no);
      else if (!nempty(s, my_strilen(s, '#')))
	return ;
      no++;
    }
}
Beispiel #4
0
void addSA(ENTRY* S1,ENTRY* S2,ENTRY* S3) {
	while(1)
	{
	if(empty(S1) && empty(S2))
		break;
    if(nempty(S1) && empty(S2))
	{
         while(1)
		 {
         if (nempty(S1))
		 {
			e1 = S2; 
			S3 = e1;
		 }
         if (empty(S1))
			break;
         }
         break;
    }
    if (empty(S1) && nempty(S2))
	{
         while(1)
		 {
         if (nempty(S2))
		 {	
			e2 = S2; 
			S3 = e2;
		 }
         if (empty(S2))
			break;
         }
         break;
	}
    if (nempty(S1) && nempty(S2)) 
	{
         e1 = S1;
         e2 = S2;
         if ((e1.row == e2.row) && (e1.col == e2.col))
		 {
            e1 = S1;
            e2 = S2;
            initEntry(S3, e1.row, e1.col, e1.value + e2.value);
		}
		 if ((e1.row < e2.row) || ((e1.row == e2.row) && (e1.col < e2.col)))
		 {
            e1 = S1;
			S3 = e1;
		}
        else
		{
            e2 = S2; 
			S3 = e2;
		}
	}
	}
}
Beispiel #5
0
int dcl_call(PARAM_T *p,PARAM_T *q)
{
    char            label[MAX_LABEL];
    char            outfile[MAX_TOKEN];
    CMD_LABEL       LABEL;
    char            *parm[8] = {NULL};
    int             l       = 0;
    unsigned int    i       = 0;
    int             found   = 0;
    char            subr    = 0;
    int             retcod  = DCL_OK;

    if (cmd[C].subr) {
        NEXT_LINE();
        return(DCL_OK);
    }
    if (!dcl[D].cc[dcl[D].ccl]) {
        NEXT_LINE();
        return(DCL_OK);
    }
    
    if (C <= 1) {
        (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid use of CALL command.\n");
        _SEVERITY = 2;
        _STATUS = 19;
        return(DCL_ERROR);
    }

    if (p == NULL || q == NULL) return(DCL_ERROR);

    *label = 0; *outfile = 0;

    retcod = cmd_parse_line(dcl_line,CALL_PARAM,CALL_QUAL,p,q);
    
    if (retcod == DCL_OK) {
        if (q[0].flag & PRESENT) {
            dcl_string(q[0].value,outfile,MAX_TOKEN);
            if (*outfile == 0){
                NEXT_LINE();
                (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid argument\n");
                _SEVERITY = 2;
                _STATUS = 19;
                retcod = DCL_ERROR;
                goto exit_label;
            }
        }

        dcl_string(p[0].value,label,MAX_LABEL-1);
        strcat(label,":");
        while (!found && i <= nempty(cmd[C].label)) {
            if (rcld(cmd[C].label,&LABEL,i)) {
                if (strcasecmp(label,LABEL.name) == 0) {
                    l = LABEL.line;
                    subr = LABEL.subr;
                    found = 1;
                }
            }
            i++;
        }
    
        if (!found) {
            NEXT_LINE();
            (void) dcl_printf(dcl[D].SYS_OUTPUT,"CALL target not found.\n");
            _SEVERITY = 2;
            _STATUS = 19;
            retcod = DCL_ERROR;
            goto exit_label;
        }
    
        if (!subr) {
            NEXT_LINE();
            (void) dcl_printf(dcl[D].SYS_OUTPUT,"CALL target not a subroutine.\n");
            _SEVERITY = 2;
            _STATUS = 19;
            retcod = DCL_ERROR;
            goto exit_label;
        }

        for (i = 0; i < 8; i++) {
            parm[i] = (char *) malloc(MAX_TOKEN);
            if (parm[i] == NULL) {
                NEXT_LINE();
                (void) dcl_printf(dcl[D].SYS_OUTPUT,"ERROR - CA0002\n");
                _SEVERITY = 4;
                _STATUS = 8;
                retcod = DCL_ERROR;
                goto exit_label;
                }
            *parm[i] = 0;
        }

        for (i = 1; i <= 8; i++)
            if (p[i].flag & PRESENT)
                strcpy(parm[i-1],p[i].value);

        i = (unsigned)cmd[C].ln + 1;
        (void) pushdptr(cmd[C].stack,&i);
        cmd[C].ln = l;
        dcl_subr++;
        retcod = dcl_enter_proc_level(outfile,parm);
    }

exit_label:
    for (l = 0;l < 8; l++)
        if (parm[l] != NULL) free(parm[l]);
    return(retcod);
}
Beispiel #6
0
int dcl_recall(PARAM_T *p,PARAM_T *q)
{
    char    token[MAX_TOKEN];
    char    sel[MAX_TOKEN];
    int     i       = 0;
    int     retcod  = 0;
    int     f_all   = 0;
    int     f_erase = 0;
    int     f_save  = 0;

    NEXT_LINE();
    if (cmd[C].subr) return(0);
    if (!dcl[D].cc[dcl[D].ccl]) return(0);
    if (mode != MODE_INTERACTIVE || D != 1) return(0);
    if (p == NULL || q == NULL) return(DCL_ERROR);

    (void)mkcdptr(cmd_stack,1);
    (void)deln(cmd_stack);

    *token = 0; *sel = 0;

    (void)cmd_parse_line(dcl_line,RECALL_PARAM,RECALL_QUAL,p,q);

    for (i = 0; q[i].tag; i++) {
        if (q[i].flag & PRESENT)
            switch (q[i].tag) {
                case 1:                                 /* /ALL     */
                    f_all = TRUE;
                    break;
                case 2:                                 /* /ERASE   */
                    f_erase = TRUE;
                    break;
                case 3:                                 /* /SAVE    */
                    f_save = TRUE;
                    break;
                default:
                    ;
                } /* end switch */
        }   /* end for */

    dcl_string(p[0].value,sel,MAX_TOKEN);

    if (f_all){
        (void)mkcdptr(cmd_stack,0);
        while (nextdptr(cmd_stack,token)) {
            (void) dcl_printf(dcl[D].SYS_OUTPUT,"%3d %s\n",ncur(cmd_stack),token);
            }
        goto exit_label;
    }

    if (f_save){
        FILE    *fp = fopen(history_filename, "w");
        char    buffer[1024];
        if (fp != NULL) {
            (void)mkcdptr(cmd_stack,0); //cmd_stack->nodes
            while(prevdptr(cmd_stack,buffer)) {
                fprintf(fp, "%s\n", buffer);
            }
            (void)fclose(fp);
        }
        goto exit_label;
    }

    if (f_erase){
        (void) clrFlist(cmd_stack);
        goto exit_label;
    }

    i = 1;
    if (*sel){
        i = atoi(sel);
        if (i) {
            if (i < 1 || i > MAX_KBD_STACK){
                (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid value\n");
                _SEVERITY = 2;
                _STATUS = 19;
                retcod = -1;
                goto exit_label;
                }
            if (i > (int) nempty(cmd_stack))
                i = (int) nempty(cmd_stack);
            }
        else {
            (void) mkcdptr(cmd_stack,0);
            while (nextdptr(cmd_stack,token)) {
                if (strncasecmp(token,sel,strlen(sel)) == 0) {
                    i = (int)ncur(cmd_stack);
                    break;
                    }
                }
            if (i == 0) {
                (void) dcl_printf(dcl[D].SYS_OUTPUT,"No command found\n");
                _SEVERITY = 2;
                _STATUS = 19;
                retcod = -1;
                goto exit_label;
                }
            }
        }

    if (rcld(cmd_stack,dcl_line,(unsigned int)i)){
        recall = 1;
        }
    else {
        dcl_line[0] = 0;
        }

exit_label:
    return(retcod);
}
Beispiel #7
0
int dump(char *fname)
{
	Flist df, newdf;
	char c, *txt;
	int i, r, n;

	if ((df = loaddf(fname))
		== (Flist) 0)
		return 1;
	for (c = -Home; c != ESC; c = getPC())  {
		switch (c)  {
		case -PgDn:
			if (ncur(df) < nempty(df))
				txt = nextdptr(df,(void *) 0);
			else
				continue;
			break;
		case -PgUp:
			if (ncur(df) > 1)
				txt = prevdptr(df,(void *) 0);
			else
				continue;
			break;
		case -Home:
			txt = mkcdptr(df,1);
			break;
		case -EndKey:
			txt = mkcdptr(df,nempty(df));
			break;
		case -F1:
			textcolor(mcolor);
			textbackground(mbgrd);
			gotoxy(1,25);
			clreol();
			cprintf("Keys: PgUp, PgDn, Home = top,"
			" End = bottom, F3 = new file, ESC = Quit");
			continue;
		case -F3:
			if ((newdf = loaddf(newFile()))
				!= (Flist) 0)  {
				rmFlist(&df);
				df = newdf;
				txt = mkcdptr(df,1);
			}
			break;
		default:
			continue;
		}
		textcolor(color);
		textbackground(bgrd);
		window(1,1,80,24);
		clrscr();
		cprintf(" Addr      Dword        Dword   "
			"     Dword        Dword           ASCII"
			"\n\r\n\r\n\r");
		for (n = ncur(df) - 1, r = 0;
			r < 16; r++, txt += 16)  {
			cprintf("\n\r%06x ",n * NSIZE + r * 16);
			for (i = 0; i < 16; i++)  {
				if (i % 4 == 0)
					putch(' ');
				cprintf("%02X ",(unsigned char) txt[i]);
			}
			cprintf("  ");
			for (i = 0; i < 16; i++)
				switch (txt[i])  {
					case 7: case 8: case 9:
					case 10: case 13:
						putch(' ');
						break;
					default:
						if (txt[i] < 26)  {  /* ctrl char */
							textcolor(ccolor);
							textbackground(cbgrd);
							putch(txt[i] + 'A' - 1);
							textcolor(color);
							textbackground(bgrd);
						}
						else
						putch(txt[i]);
				}
		}
		textcolor(mcolor);
		textbackground(mbgrd);
		window(1,1,80,25);
		gotoxy(1,25);
		clreol();
		cprintf("Dump file: %s",(char *) Flistdptr(df));
	}
	rmFlist(&df);
	return 0;
}
Beispiel #8
0
int tjPick( tjPickOpts &Opts )
// Does a pick list of items, using the options set in the given options.
{
   key ch;
   int done = 0;
   int index;
   int redraw = 1;

   do
   {
      if( Opts.current < Opts.topline )
      {
         Opts.topline = Opts.current;
         redraw = 1;
      }

      if( Opts.current > Opts.topline+Opts.lines-1 )
      {
         Opts.topline = Opts.current-Opts.lines+1;
         redraw = 1;
      }

      if( redraw )
      {
         redraw = 0;
         for( index = Opts.topline; index < Opts.topline+Opts.lines; index++ )
            Opts.dispfun( Opts, index );
      }

      ch = tjGetKey( );
      switch( ch )
      {
         case Esc:
            done = 1;
            break;

         case Enter:
            done = 1;
            break;

         case UArr:
            if( Opts.current > 1 )
            {
               redraw = 1;
               Opts.current--;
            }
            break;

         case DArr:
            if( Opts.current < nempty( Opts.PickMe ) )
            {
               redraw = 1;
               Opts.current++;
            }
            break;

         default:
            if( Opts.keyhan != NULL )
               done = Opts.keyhan( Opts, ch );
            break;
      }
   } while( !done );
   Opts.lastkey = ch;
   if( ch != Esc )
      return( Opts.current );
   else
      return( 0 );
}