Exemple #1
0
static gboolean
omicron_read_topo_header(gchar **buffer,
                         OmicronTopoChannel *channel,
                         GError **error)
{
    gchar *line, *p;

    /* Direction */
    NEXT_LINE(buffer, line, FALSE, error);
    gwy_debug("Scan direction: %s", line);
    if (gwy_strequal(line, "Forward"))
        channel->scandir = SCAN_FORWARD;
    else if (gwy_strequal(line, "Backward"))
        channel->scandir = SCAN_BACKWARD;
    else
        channel->scandir = SCAN_UNKNOWN;

    /* Raw range */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->min_raw = atoi(line);
    NEXT_LINE(buffer, line, FALSE, error);
    channel->max_raw = atoi(line);
    gwy_debug("Raw range: [%d, %d]", channel->min_raw, channel->max_raw);

    /* Physical range */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->min_phys = g_ascii_strtod(line, NULL);
    NEXT_LINE(buffer, line, FALSE, error);
    channel->max_phys = g_ascii_strtod(line, NULL);
    gwy_debug("Physical range: [%g, %g]", channel->min_phys, channel->max_phys);

    /* Resolution */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->resolution = g_ascii_strtod(line, NULL);
    gwy_debug("Physical Resolution: %g", channel->resolution);

    /* Units */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->units = line;
    gwy_debug("Units: <%s>", channel->units);

    /* Filename */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->filename = line;
    gwy_debug("Filename: <%s>", channel->filename);

    /* Name */
    NEXT_LINE(buffer, line, TRUE, error);
    channel->name = line;
    gwy_debug("Channel name: <%s>", channel->name);

    return TRUE;
}
Exemple #2
0
int dcl_define(PARAM_T *p,PARAM_T *q)
{
    int     retcod;
    int     key = 0;
    int     i;

    NEXT_LINE();
    if (cmd[C].subr) return(DCL_OK);
    if (!dcl[D].cc[dcl[D].ccl]) return(DCL_OK);

    _STATUS = 0;
    retcod = cmd_parse_line(dcl_line,DEFINE_PARAM,DEFINE_QUAL,p,q);
    if (retcod == DCL_OK) {
        for (i = 0; q[i].tag; i++) {
            if (q[i].flag & PRESENT) 
                if (q[i].tag == 1) {
                    key = 1;
                    } 
            }   /* end for */

        if (key)
            retcod = dcl_define_key(p,q);
        else
            retcod = dcl_define_logical(p,q);
        }

    return(retcod);
}
Exemple #3
0
int dcl_sym_assign(char *sym,char *oper)
{
    int     symlvl;
    char    work[1024];
    char    *ch = dcl_line;

    NEXT_LINE();
    if (cmd[C].subr) return(0);
    if (!dcl[D].cc[dcl[D].ccl]) return(0);
    if (sym == NULL || oper == NULL) return(DCL_ERROR);

    *work = 0;
    if (strcmp(oper,"==")==0 || strcmp(oper,":==")==0)
        symlvl = 0;
    else
        symlvl = D;
    while (*ch && *ch != '=') ch++;
    while (*ch && *ch != ' ') ch++;
    if (*ch) {
        (void) EXP_compute(ch,work);
        if (*work) 
            (void) symbol_put(sym,work,symlvl);
        else
            symbol_del_lvl(sym, symlvl);
    }
    return(0);
}
Exemple #4
0
bool VcImporter::OnProject(const wxString& firstLine, wxString& errMsg)
{
    // first line contains the project name, project file path, and project id
    wxStringTokenizer tkz(firstLine, wxT("="));
    if(tkz.CountTokens() != 2) {
        errMsg = wxT("Invalid 'Project' section found. expected <expr> = <expr>");
        return false;
    }

    tkz.NextToken();
    wxString token = tkz.NextToken();
    TrimString(token);
    wxStringTokenizer tk2(token, wxT(","));
    if(tk2.CountTokens() != 3) {
        errMsg = wxT("Invalid 'Project' section found. expected <project name>, <project file path>, <project id>");
        return false;
    }

    VcProjectData pd;

    pd.name = tk2.NextToken();
    RemoveGershaim(pd.name);

    pd.filepath = tk2.NextToken();
    RemoveGershaim(pd.filepath);

    // Make sure that the project path has a forward slash style
    pd.filepath.Replace(wxT("\\"), wxT("/"));

    pd.id = tk2.NextToken();
    RemoveGershaim(pd.id);

    std::pair<wxString, VcProjectData> p;
    p.first = pd.id;
    p.second = pd;
    m_projects.insert(p);
    // Skip all lines until EndProject section is found
    wxString line;
    while(true) {
        NEXT_LINE(line);
        if(line == wxT("EndProject")) {
            return true;
        }
    }
    return false;
}
Exemple #5
0
int dcl_then(PARAM_T *p,PARAM_T *q)
{
    char token[MAX_TOKEN];
    char *ch;

    UNREFERENCED_PARAM(p);
    UNREFERENCED_PARAM(q);

    NEXT_LINE();
    if (cmd[C].subr) return(DCL_OK);
    if (!dcl[D].cc[dcl[D].ccl]) return(DCL_OK);
    ch = dcl_get_token(dcl_line,token);
    if (*token) {
        strcpy(dcl_line,ch);
        (void) dcl_process_command_line(2);
    }
    return(DCL_OK);
}
Exemple #6
0
static int dcltype_read_sysinput(char *buf)
{
    if (buf == NULL) return(DCL_ERROR);

    (void) memset(buf,0,MAX_TOKEN);
    if (C == 1){
        (void) kbdread(buf,MAX_TOKEN,data_stack,INFINITE_TIMEOUT);
        }
    else {
        (void) rcld(cmd[C].cmd,buf,(unsigned int)cmd[C].ln);
        if (*buf == '$')
            *buf = 0;
        else
            NEXT_LINE();
        }
    if (buf[strlen(buf)-1] == '\n' || buf[strlen(buf)-1] == '\r')
        buf[strlen(buf)-1] = 0;
    return(0);
}
Exemple #7
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);
}
Exemple #8
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);
}
mlib_status
mlib_ImageMaxFilter7x7_F32(
    mlib_f32 *dst,
    const mlib_f32 *src,
    mlib_s32 dlb,
    mlib_s32 slb,
    mlib_s32 w,
    mlib_s32 h)
{
	mlib_s32 i, j, k, row = 0, w2;
	STYPE *sl, *dl;
	TTYPE *rowbf, *prow[2 * (KSIZE + 1)], **prowc;
	TTYPE *prow0, *prow1, *prow2, *prow3, *prow4, *prow5, *prow6, *prow7;
	TTYPE a0, a3, a4, a5, a6, a7, a8, x0, x1, x2, xx;

	slb /= sizeof (STYPE);
	dlb /= sizeof (STYPE);
	sl = (void *)src;
	dl = (STYPE *)(dst + (KSIZE / 2) * (dlb + 1));
	w -= (KSIZE - 1);
	h -= (KSIZE - 1);

	if (w <= 0 || h <= 0)
		return (MLIB_SUCCESS);

	w2 = (w + 1) & ~1;
	rowbf = __mlib_malloc((KSIZE + 1) * sizeof (TTYPE) * w2);

	if (rowbf == NULL)
		return (MLIB_FAILURE);

	for (k = 0; k < (KSIZE + 1); k++) {
		prow[k] = prow[k + (KSIZE + 1)] = rowbf + k * w2;
	}

	for (j = 0; j < (KSIZE - 1); j++) {
		prow0 = prow[j];
		NEXT_LINE(prow0);
	}

	prow1 = prow[1];
	prow2 = prow[2];
	for (i = 0; i < w; i++) {
		prow1[i] = C_COMP(prow1[i], prow2[i]);
	}

	prow3 = prow[3];
	prow4 = prow[4];
	for (i = 0; i < w; i++) {
		prow3[i] = C_COMP(prow3[i], prow4[i]);
	}

	for (j = 0; j <= h - 2; j += 2) {
		prowc = prow + row;
		prow0 = prowc[0];
		prow1 = prowc[1];
		prow3 = prowc[3];
		prow5 = prowc[5];
		prow6 = prowc[6];
		prow7 = prowc[7];

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
		NEXT_LINE(prow6);

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
		NEXT_LINE(prow7);

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
		for (i = 0; i < w; i++) {
			a0 = prow0[i];
			a5 = prow5[i];
			a6 = prow6[i];
			a7 = prow7[i];
			x0 = prow1[i];
			x1 = prow3[i];
			x2 = C_COMP(a5, a6);
			xx = C_COMP(x0, x1);
			xx = C_COMP(xx, x2);
			dl[i] = C_COMP(a0, xx);
			dl[i + dlb] = C_COMP(xx, a7);
			prow5[i] = x2;
		}

		dl += 2 * dlb;
		row += 2;

		if (row >= (KSIZE + 1))
			row = 0;
	}

/* last line */

	if (j < h) {
		prowc = prow + row;
		prow0 = prowc[0];
		prow1 = prowc[1];
		prow3 = prowc[3];
		prow5 = prowc[5];
		prow6 = prowc[6];

		NEXT_LINE(prow6);

		for (i = 0; i < w; i++) {
			a0 = prow0[i];
			a5 = prow5[i];
			a6 = prow6[i];
			x0 = prow1[i];
			x1 = prow3[i];
			x2 = C_COMP(a5, a6);
			xx = C_COMP(x0, x1);
			xx = C_COMP(xx, x2);
			dl[i] = C_COMP(a0, xx);
		}
	}

	__mlib_free(rowbf);

	return (MLIB_SUCCESS);
}
static int radsnmp_send_recv(radsnmp_conf_t *conf, int fd)
{
	fr_strerror();

#define NEXT_LINE(_line, _buffer) \
{ \
	size_t _len; \
	if (stop) return 0; \
	errno = 0;\
	_line = fgets(_buffer, sizeof(_buffer), stdin); \
	if (_line) { \
		_len = strlen(_line); \
		if ((_len > 0) && (_line[_len - 1] == '\n')) _line[_len - 1] = '\0'; \
		DEBUG2("read: %s", _line); \
	} \
}
	/*
	 *	Read commands from pass_persist
	 */
	while (!stop) {
		radsnmp_command_t	command;

		char			buffer[256];
		char			*line;
		ssize_t			slen;

		fr_cursor_t		cursor;
		VALUE_PAIR		*vp;
		RADIUS_PACKET		*request;

		/*
		 *	Alloc a new request so we can start adding
		 *	new pairs to it.
		 */
		request = radsnmp_alloc(conf, fd);
		if (!request) {
			ERROR("Failed allocating request");
			return EXIT_FAILURE;
		}
		fr_cursor_init(&cursor, &request->vps);

		NEXT_LINE(line, buffer);

		/*
		 *	Determine the type of SNMP operation
		 */
		command = fr_str2int(radsnmp_command_str, line, RADSNMP_UNKNOWN);
		switch (command) {
		case RADSNMP_EXIT:
			DEBUG("Empty command, exiting");
			return 0;

		case RADSNMP_PING:
			RESPOND_STATIC("PONG");
			continue;

		case RADSNMP_SET:
		{
			char		value_buff[254];	/* RADIUS attribute length + 1 */
			char		*value;
			char		type_str[64];
			char		*p;
			fr_dict_enum_t	*type;

			NEXT_LINE(line, buffer);	/* Should be the OID */
			NEXT_LINE(value, value_buff);	/* Should be the value */

			p = strchr(value, ' ');
			if (!p) {
				ERROR("No SNMP type specified (or type/value string was malformed)");
				RESPOND_STATIC("NONE");
				continue;
			}

			if ((size_t)(p - value) >= sizeof(type_str)) {
				ERROR("SNMP Type string too long");
				RESPOND_STATIC("NONE");
				continue;
			}

			strlcpy(type_str, value, (p - value) + 1);

			type = fr_dict_enum_by_alias(attr_freeradius_snmp_type, type_str, -1);
			if (!type) {
				ERROR("Unknown type \"%s\"", type_str);
				RESPOND_STATIC("NONE");
				continue;
			}

			slen = radsnmp_pair_from_oid(conf, conf, &cursor, line, type->value->vb_uint32, p + 1);
		}
			break;

		case RADSNMP_GET:
		case RADSNMP_GETNEXT:
			NEXT_LINE(line, buffer);	/* Should be the OID */
			slen = radsnmp_pair_from_oid(conf, conf, &cursor, line, 0, NULL);
			break;

		default:
			ERROR("Unknown command \"%s\"", line);
			RESPOND_STATIC("NONE");
			talloc_free(request);
			continue;
		}

		/*
		 *	Deal with any errors from the GET/GETNEXT/SET command
		 */
		if (slen <= 0) {
			char *spaces, *text;

			fr_canonicalize_error(conf, &spaces, &text, slen, line);

			ERROR("Failed evaluating OID:");
			ERROR("%s", text);
			ERROR("%s^ %s", spaces, fr_strerror());

			talloc_free(spaces);
			talloc_free(text);
			talloc_free(request);
			RESPOND_STATIC("NONE");
			continue;
		}

		/*
		 *	Now add an attribute indicating what the
		 *	SNMP operation was
		 */
		vp = fr_pair_afrom_da(request, attr_freeradius_snmp_operation);
		if (!vp) {
			ERROR("Failed allocating SNMP operation attribute");
			return EXIT_FAILURE;
		}
		vp->vp_uint32 = (unsigned int)command;	/* Commands must match dictionary */
		fr_cursor_append(&cursor, vp);

		/*
		 *	Add message authenticator or the stats
		 *	request will be rejected.
		 */
		MEM(vp = fr_pair_afrom_da(request, attr_message_authenticator));
		fr_pair_value_memcpy(vp, (uint8_t const *)"\0", 1, true);
		fr_cursor_append(&cursor, vp);

		/*
		 *	Send the packet
		 */
		{
			RADIUS_PACKET	*reply = NULL;
			ssize_t		rcode;

			fd_set		set;

			unsigned int	ret;
			unsigned int	i;

			if (fr_radius_packet_encode(request, NULL, conf->secret) < 0) {
				ERROR("Failed encoding request: %s", fr_strerror());
				return EXIT_FAILURE;
			}
			if (fr_radius_packet_sign(request, NULL, conf->secret) < 0) {
				ERROR("Failed signing request: %s", fr_strerror());
				return EXIT_FAILURE;
			}

			/*
			 *	Print the attributes we're about to send
			 */
			if (fr_log_fp) fr_packet_header_print(fr_log_fp, request, false);
			if (fr_debug_lvl > 0) fr_pair_list_fprint(fr_log_fp, request->vps);
#ifndef NDEBUG
			if (fr_log_fp && (fr_debug_lvl > 3)) fr_radius_packet_print_hex(request);
#endif

			FD_ZERO(&set); /* clear the set */
			FD_SET(fd, &set);

			/*
			 *	Any connection issues cause us to exit, so
			 *	the connection can be re-initialised on the
			 *	next call.
			 */
			for (i = 0; i < conf->retries; i++) {
				rcode = write(request->sockfd, request->data, request->data_len);
				if (rcode < 0) {
					ERROR("Failed sending: %s", fr_syserror(errno));
					return EXIT_FAILURE;
				}

				rcode = select(fd + 1, &set, NULL, NULL, &conf->timeout);
				switch (rcode) {
				case -1:
					ERROR("Select failed: %s", fr_syserror(errno));
					return EXIT_FAILURE;

				case 0:
					DEBUG("Response timeout.  Retrying %d/%u...", i + 1, conf->retries);
					continue;	/* Timeout */

				case 1:
					reply = fr_radius_packet_recv(request, request->sockfd, UDP_FLAGS_NONE,
								      RADIUS_MAX_ATTRIBUTES, false);
					if (!reply) {
						ERROR("Failed receiving reply: %s", fr_strerror());
					recv_error:
						RESPOND_STATIC("NONE");
						talloc_free(request);
						continue;
					}
					if (fr_radius_packet_decode(reply, request,
								    RADIUS_MAX_ATTRIBUTES, false, conf->secret) < 0) {
						ERROR("Failed decoding reply: %s", fr_strerror());
						goto recv_error;
					}
					break;

				default:
					DEBUG("Invalid select() return value %zd", rcode);
					return EXIT_FAILURE;
				}
				break;
			}

			if (!reply) {
				ERROR("Server didn't respond");
				return EXIT_FAILURE;
			}

			/*
			 *	Print the attributes we received in response
			 */
			if (fr_log_fp) fr_packet_header_print(fr_log_fp, reply, true);
			if (fr_debug_lvl > 0) fr_pair_list_fprint(fr_log_fp, reply->vps);
#ifndef NDEBUG
			if (fr_log_fp && (fr_debug_lvl > 3)) fr_radius_packet_print_hex(reply);
#endif

			switch (command) {
			case RADSNMP_GET:
			case RADSNMP_GETNEXT:
				ret = radsnmp_get_response(STDOUT_FILENO, conf->snmp_oid_root,
							   attr_freeradius_snmp_type, reply->vps);
				switch (ret) {
				case -1:
					ERROR("Failed converting pairs to varbind response: %s", fr_strerror());
					return EXIT_FAILURE;

				case 0:
					DEBUG("Empty response");
					break;

				default:
					DEBUG("Returned %u varbind responses", ret);
					break;
				}
				break;

			case RADSNMP_SET:
				if (radsnmp_set_response(STDOUT_FILENO, attr_freeradius_snmp_failure, reply->vps) < 0) {
					ERROR("Failed writing SET response: %s", fr_strerror());
					return EXIT_FAILURE;
				}
				break;

			default:
				assert(0);
				return EXIT_FAILURE;
			}


			talloc_free(request);
		}
	}

	return EXIT_SUCCESS;
}
Exemple #11
0
int dcl_copy(PARAM_T *p,PARAM_T *q)
{
    COP_PARAM cop_param;
    char    vms[MAX_TOKEN];
    char    dos[MAX_TOKEN];
    int     i       = 0;
    int     s_recurse = 0;
    int     retcod  = DCL_OK;
    char    *szCmd = "COPY";

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

    SUBDIR = 0;
    _STATUS = 0;
    *vms = 0; *dos = 0;
    cop_param.all = 0;
    cop_param.confirm = 0;
    cop_param.log = 0;
    cop_param.replace = 1;
    cop_param.wildcard = 0;
    cop_param.file_nb = 0;
    cop_param.file_copied = 0;
    cop_param.vms[0] = 0;
    cop_param.before = -1;
    cop_param.since = 0;
    cop_param.ok = 1;
    cop_param.fnew = 0;
    cop_param.recurse = 0;

    retcod = cmd_parse_line(dcl_line,COPY_PARAM,COPY_QUAL,p,q);

    if (retcod == DCL_OK) {
        for (i = 0; q[i].tag; i++) {
            if (q[i].flag & PRESENT) 
                switch (q[i].tag) {
                case 1:                                 /* /ALL     */
                    cop_param.all = TRUE;
                    break;
                case 2:                                 /* /BEFORE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&cop_param.before);
                    break;
                case 3:                                 /*  /CONFIRM */
                    cop_param.confirm = 1;
                    break;
                case 4:                                 /*  /NOCONFIRM */
                    cop_param.confirm = 0;
                    break;
                case 5:                                 /*  /LOG */
                    cop_param.log = 1;
                    break;
                case 6:                                 /*  /NOLOG */
                    cop_param.log = 0;
                    break;
                case 7:                                 /*  /NEW */
                    cop_param.fnew = 1;
                    break;
                case 8:                                 /*  /SINCE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&cop_param.since);
                    break;
                case 9:                                 /*  /SUBDIR */
                    cop_param.recurse = 1;
                    break;
                case 10:                                /*  /NOSUBDIR */
                    cop_param.recurse = 0;
                    break;
                case 11:                                 /*  /REPLACE */
                    cop_param.replace = 1;
                    break;
                case 12:                                /*  /NOREPLACE */
                    cop_param.replace = 0;
                    break;
                default:
                    ;
                } /* end switch */
            }   /* end for */

        dcl_string(p[0].value,vms,MAX_TOKEN);
        dcl_string(p[1].value,cop_param.vms,MAX_TOKEN);
        cvfs_lst_to_dos(vms,dos,&s_recurse);
        if (s_recurse) cop_param.recurse = 1;
        if (dos[strlen(dos)-1] == ':')
            strcat(dos,"*.*");
        cop_param.wildcard = (char)wildcard(dos);
        (void)dcl_searchdirlst(szCmd,dos,cop_param.recurse,dclcopy_do_it,&cop_param);
        if (cop_param.file_nb == 0) {
            if (cop_param.wildcard)
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"No file found.\n");
            else
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"File not found.\n");
            _SEVERITY = 1;
            _STATUS = 2;
            retcod = DCL_ERROR;
        }
        else {
            if (cop_param.log && cop_param.file_copied > 1)
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"%d files copied.\n",cop_param.file_copied);
        }
    }

    
    return(retcod);
}
Exemple #12
0
int dcl_type(PARAM_T *p, PARAM_T *q)
{
    PARAM type_param;
    char    vms[MAX_TOKEN];
    char    outfil[MAX_TOKEN];
    char    dos[MAX_TOKEN];
    char    drive[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    file[_MAX_FNAME];
    char    ext[_MAX_EXT];
    int     i       = 0;
    int     recurse = 0;
    int     s_recurse = 0;
    int     retcod  = 0;
    int     f_output = 0;
    char    *type_command = "TYPE";

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

    _STATUS = 0;
    *vms = 0; *outfil = 0; *dos = 0;
    *drive = 0; *dir = 0; *file = 0; *ext = 0;

    type_param.all = 0;
    type_param.confirm = 0;
    type_param.page = 0;
    type_param.wildcard = 0;
    type_param.file_nb = 0;
    type_param.before = -1;
    type_param.since = 0;
    type_param.output = dcl[D].SYS_OUTPUT;
    type_param.ok = 1;
    type_param.numbers = 0;

    retcod = cmd_parse_line(dcl_line,TYPE_PARAM,TYPE_QUAL,p,q);
    if (retcod != DCL_OK) 
        goto exit_label;

    for (i = 0; q[i].tag; i++) {
        if (q[i].flag & PRESENT) 
            switch (q[i].tag) {
                case 1:                                 /* /ALL     */
                    type_param.all = TRUE;
                    break;
                case 2:                                 /* /BEFORE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&type_param.before);
                    break;
                case 3:                                 /*  /CONFIRM */
                    type_param.confirm = 1;
                    break;
                case 4:                                 /*  /NOCONFIRM */
                    type_param.confirm = 0;
                    break;
                case 5:                                 /*  /PAGE      */
                    type_param.page = 1;
                    break;
                case 6:                                 /*  /OUTPUT    */
                    dcl_string(q[i].value,outfil,MAX_TOKEN);
                    cvfs_vms_to_dos(outfil,dos,&recurse);
                    if (!cvfs_check_device(dos)){
                        _splitpath(dos,drive,dir,file,ext);
                        if (strlen(file) == 0){
                            strcat(dos,"TYPE");
                            }
                        if (strlen(ext) == 0){
                            strcat(dos,".LIS");
                            }
                        }
                    type_param.output = fopen(dos,"at");
                    if (type_param.output == NULL) {
		                (void)dcl_printf(dcl[D].SYS_OUTPUT,"%s: %s\n",outfil,strerror(errno));
                        _SEVERITY = 2;
                        _STATUS = 19;
                        retcod = -1;
                        goto exit_label;
                        }
                    f_output = 1;
                    break;
                case 7:                                 /*  /SINCE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&type_param.since);
                    break;
                case 8:                                 /*  /SUBDIR */
                    recurse = 1;
                    break;
                case 9:                                /*  /NOSUBDIR */
                    recurse = 0;
                    break;
                case 10:                                /*  /NUMBERS */
                    type_param.numbers = 1;
                    break;
                default:
                    ;
            } /* end switch */
    }   /* end for */

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

    if (type_param.page && f_output) {
        (void)dcl_printf(dcl[D].SYS_OUTPUT,"/PAGE and /OUTPUT parameters are mutually exclusives.\n");
        _SEVERITY = 2;
        _STATUS = 19;
        retcod = -1;
        goto exit_label;
    }

    if (strncasecmp(vms,"SYS$INPUT",9)) {
        cvfs_lst_to_dos(vms,dos,&s_recurse);
        if (s_recurse) recurse = 1;
        type_param.wildcard = (char)wildcard(dos);
        (void)dcl_searchdirlst(type_command,dos,recurse,dcltype_do_it,&type_param);
        if (type_param.file_nb == 0){
            if (type_param.wildcard)
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"No file found.\n");
            else
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"File not found.\n");
            _SEVERITY = 1;
            _STATUS = 2;
            retcod = -1;
            goto exit_label;
        }
    }
    else {
        (void)dcltype_sysinput(&type_param);
    }
    
exit_label:
    if (f_output)
        fclose(type_param.output);
    if (HARDERR)
        tio_print_interrupt();

    return(retcod);
}
mlib_status
mlib_ImageMaxFilter5x5_D64(
    STYPE *dst,
    const STYPE *src,
    mlib_s32 dlb,
    mlib_s32 slb,
    mlib_s32 w,
    mlib_s32 h)
{
	mlib_s32 i, j, k, row = 0, w2;
	STYPE *sl, *dl;
	TTYPE *rowbf, *prow[12], *temp, *prow0, *prow1, *prow2, *prow3, *prow4,
	    *prow5;
	TTYPE a0, a3, a4, a5, a6, x0, x1, xx;

	slb /= sizeof (STYPE);
	dlb /= sizeof (STYPE);
	sl = (void *)src;
	dl = dst + 2 * dlb + 2;
	w -= 4;
	h -= 4;

	if (w <= 0 || h <= 0)
		return (MLIB_SUCCESS);

	w2 = (w + 1) & ~1;
	rowbf = __mlib_malloc(7 * sizeof (TTYPE) * w2);

	if (rowbf == NULL)
		return (MLIB_FAILURE);

	for (k = 0; k < 6; k++) {
		prow[k] = prow[k + 6] = rowbf + k * w2;
	}

	temp = rowbf + 6 * w2;

	for (j = 0; j < 4; j++) {
		prow0 = prow[j];
		NEXT_LINE(prow0);
	}

	prow1 = prow[1];
	prow2 = prow[2];
	for (i = 0; i < w; i++) {
		temp[i] = C_COMP(prow1[i], prow2[i]);
	}

	for (j = 0; j <= h - 2; j += 2) {
		prow0 = prow[row];
		prow3 = prow[row + 3];
		prow4 = prow[row + 4];
		prow5 = prow[row + 5];

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
		NEXT_LINE(prow4);

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
		NEXT_LINE(prow5);

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
		for (i = 0; i < w; i++) {
			a0 = prow0[i];
			a3 = prow3[i];
			a4 = prow4[i];
			a5 = prow5[i];
			x0 = temp[i];
			x1 = C_COMP(a3, a4);
			xx = C_COMP(x0, x1);
			dl[i] = C_COMP(a0, xx);
			dl[i + dlb] = C_COMP(xx, a5);
			temp[i] = x1;
		}

		dl += 2 * dlb;
		row += 2;

		if (row >= 6)
			row = 0;
	}

/* last line */

	if (j < h) {
		prow0 = prow[row];
		prow3 = prow[row + 3];
		prow4 = prow[row + 4];

		NEXT_LINE(prow4);

		for (i = 0; i < w; i++) {
			a0 = prow0[i];
			a3 = prow3[i];
			a4 = prow4[i];
			x0 = temp[i];
			x1 = C_COMP(a3, a4);
			xx = C_COMP(x0, x1);
			dl[i] = C_COMP(a0, xx);
		}
	}

	__mlib_free(rowbf);

	return (MLIB_SUCCESS);
}
Exemple #14
0
int dcl_string_assign(char *sym,char *oper)
{
    int     symlvl;
    char    work[1024];
    char    *ch = dcl_line;
    char    *w1;
    int     quoting = 0;
    int     sp = 0;

    NEXT_LINE();
    if (cmd[C].subr) return(0);
    if (!dcl[D].cc[dcl[D].ccl]) return(0);
    if (sym == NULL || oper == NULL) return(DCL_ERROR);

    *work = 0;
    w1 = work;

    if (strncmp(oper,"==",2)==0 || strncmp(oper,":==",2)==0)
        symlvl = 0;
    else
        symlvl = D;
    while (*ch && *ch != '=') ch++;
    while (*ch && *ch == '=') ch++;
    //while (*ch && *ch != ' ' && *ch != '\t') ch++;
    while (*ch && (*ch ==  ' ' || *ch == '\t')) ch++;
    sp = (int)strlen(ch) - 1;
    while (sp && (ch[sp] == ' ' || ch[sp] == '\t')) ch[sp--] = 0;

    while (*ch) {
        switch (*ch){
            case '"' :  if (quoting) {
                            if (*(ch+1)== '"')
                                *w1++ = *ch;
                            quoting = 0;
                            }
                        else {
                            quoting = 1;
                            }
                        sp = 0;
                        break;
            case '\t':  if (quoting) {
                            *w1++ = *ch;
                            sp = 0;
                            break;
                            }
                        else
                            *ch = ' ';
							/*lint -fallthrough */
            case ' ' :  if (quoting) { 
                            *w1++ = *ch;
                            sp = 0;
                            break;
                            }
                        else {
                            sp++;
                            if (sp == 1) *w1++ = *ch;
                            break;
                            }
            default  :  sp = 0;
                        if (quoting)
                            *w1++ = *ch;
                        else
                            *w1++ = (char) toupper(*ch);
                        break;
            }
        *w1 = 0;
        ch++;
        }

    (void) symbol_put(sym,work,symlvl);
    return(0);
}
Exemple #15
0
int dcl_set(PARAM_T *p, PARAM_T *q)
{
    char    *option[] = {"DEFAULT","FILE","ON","NOON","PROMPT",
                         "SYMBOL","TIME","VERIFY","NOVERIFY","STEP","NOSTEP",
                         "TERMINAL","CONTROL","NOCONTROL","DOSVAR",NULL};

    enum    option_tag {OPT_DEFAULT,OPT_FILE,OPT_ON,OPT_NOON,
                        OPT_PROMPT,OPT_SYMBOL,OPT_TIME,OPT_VERIFY,
                        OPT_NOVERIFY,OPT_STEP,OPT_NOSTEP,OPT_TERMINAL,
                        OPT_CONTROL,OPT_NOCONTROL,OPT_DOSVAR};


    char    token[MAX_TOKEN];

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

    _STATUS = 0;
    (void) cmd_parse_line(dcl_line,SET_PARAM,SET_QUAL,p,q);
    dcl_string(p[0].value,token,MAX_TOKEN);
    switch (dcl_search(option,token)){
        case OPT_DEFAULT    :   (void) dcl_set_default(p,q);
                                break;
        case OPT_FILE       :   (void) dcl_set_file(p,q);
                                break;
        case OPT_ON         :   (void) dcl_set_on(p,q);
                                break;
        case OPT_NOON       :   (void) dcl_set_noon(p,q);
                                break;
        case OPT_PROMPT     :   (void) dcl_set_prompt(p,q);
                                break;
        case OPT_SYMBOL     :   (void) dcl_set_symbol(p,q);
                                break;
        case OPT_TIME       :   (void) dcl_set_time(p,q);
                                break;
        case OPT_VERIFY     :   (void) dcl_set_verify(p,q);
                                break;
        case OPT_NOVERIFY   :   (void) dcl_set_noverify(p,q);
                                break;
        case OPT_STEP       :   (void) dcl_set_step(p,q);
                                break;
        case OPT_NOSTEP     :   (void) dcl_set_nostep(p,q);
                                break;
        case OPT_TERMINAL   :   (void) dcl_set_term(p,q);
                                break;
        case OPT_CONTROL    :   (void) dcl_set_control(p,q,TRUE);
                                break;
        case OPT_NOCONTROL  :   (void) dcl_set_control(p,q,FALSE);
                                break;
        case OPT_DOSVAR     :   (void) dcl_set_dosvar(p,q);
                                break;
        case NOT_FOUND:         (void) logical_get("INI$STRICT",INI_VALUE);
                                if (INI_VALUE[0] == 'Y') {
                                    (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid SET option.\n");
                                    _SEVERITY = 2;
                                    _STATUS = 19;
                                }
                                break;
        case AMBIGUOUS:         (void) dcl_printf(dcl[D].SYS_OUTPUT,"Ambiguous SET option.\n");
                                _SEVERITY = 2;
                                _STATUS = 19;
                                break;
        default:                ;
        }
    return(0);
}
Exemple #16
0
static gboolean
omicron_read_spectro_header(gchar **buffer,
                            OmicronSpectroChannel *channel,
                            GError **error)
{
    gchar *line, *p;

    /* Parameter */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->param = line;
    gwy_debug("Parameter: %s", line);

    /* Direction */
    NEXT_LINE(buffer, line, FALSE, error);
    gwy_debug("Scan direction: %s", line);
    if (gwy_strequal(line, "Forward"))
        channel->scandir = SCAN_FORWARD;
    else if (gwy_strequal(line, "Backward"))
        channel->scandir = SCAN_BACKWARD;
    else
        channel->scandir = SCAN_UNKNOWN;

    /* Raw range */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->min_raw = atoi(line);
    NEXT_LINE(buffer, line, FALSE, error);
    channel->max_raw = atoi(line);
    gwy_debug("Raw range: [%d, %d]", channel->min_raw, channel->max_raw);

    /* Physical range */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->min_phys = g_ascii_strtod(line, NULL);
    NEXT_LINE(buffer, line, FALSE, error);
    channel->max_phys = g_ascii_strtod(line, NULL);
    gwy_debug("Physical range: [%g, %g]", channel->min_phys, channel->max_phys);

    /* Resolution */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->resolution = g_ascii_strtod(line, NULL);
    gwy_debug("Physical Resolution: %g", channel->resolution);

    /* Units */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->units = line;
    gwy_debug("Units: <%s>", channel->units);

    /* Number of spectroscopy points */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->npoints = atoi(line);
    gwy_debug("Units: <%d>", channel->npoints);

    /* Parameter Range */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->start = g_ascii_strtod(line, NULL);
    NEXT_LINE(buffer, line, FALSE, error);
    channel->end = g_ascii_strtod(line, NULL);
    gwy_debug("Paramter range: [%g, %g]", channel->start, channel->end);

    /* Resolution */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->inc = g_ascii_strtod(line, NULL);
    gwy_debug("Parameter Increment: %g", channel->inc);

    /* Aquisition Time*/
    NEXT_LINE(buffer, line, FALSE, error);
    channel->tacq = g_ascii_strtod(line, NULL);
    gwy_debug("Acquisition Time: %g", channel->tacq);

    /* Delay Time*/
    NEXT_LINE(buffer, line, FALSE, error);
    channel->tdly = g_ascii_strtod(line, NULL);
    gwy_debug("Acquisition Time: %g", channel->tdly);

    /* Feedback */
    NEXT_LINE(buffer, line, FALSE, error);
    gwy_debug("Feedback: %s", line);
    if (gwy_strequal(line, "On"))
        channel->scandir = FEEDBACK_ON;
    else if (gwy_strequal(line, "Off"))
        channel->scandir = FEEDBACK_OFF;
    else
        channel->scandir = FEEDBACK_UNKNOWN;

    /* Filename */
    NEXT_LINE(buffer, line, FALSE, error);
    channel->filename = line;
    gwy_debug("Filename: <%s>", channel->filename);

    /* Name */
    NEXT_LINE(buffer, line, TRUE, error);
    channel->name = line;
    gwy_debug("Channel name: <%s>", channel->name);

    return TRUE;
}
Exemple #17
0
int dcl_dir(PARAM_T *p,PARAM_T *q)
{
    char    *size_q[7]  = {"NONE","BYTES","BLOCKS","KILOBYTES","MEGABYTES","GIGABYTES",NULL};
    char    *order_q[6] = {"NONE","NAME","EXTENSION","SIZE","DATE",NULL};

    PARAM   dir_param;
    char    vms[MAX_TOKEN];
    char    dos[MAX_TOKEN];
    char    drive[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    file[_MAX_FNAME];
    char    ext[_MAX_EXT];
    int     i       = 0;
    int     j       = 0;
    int     recurse = 0;
    int     s_recurse = 0;
    int     retcod  = DCL_OK;
    int     f_output = 0;

    NEXT_LINE();
    if (cmd[C].subr) return(DCL_OK);
    if (!dcl[D].cc[dcl[D].ccl]) return(DCL_OK);

    _STATUS = 0;
    memset(&dir_param,0,sizeof(dir_param));
    dir_param.brief = 1;
    dir_param.cols = (char)(terminfo.Size.X / 15);
    if (dir_param.cols == 0) dir_param.cols = 1;
    dir_param.heading = 1;
    dir_param.output = dcl[D].SYS_OUTPUT;
    dir_param.before = -1;
    dir_param.since  = 0;
    dir_param.trailing = 1;
    dir_param.order = O_NAME;
    dir_param.line_counter = tio_wherey();

    retcod = cmd_parse_line(dcl_line,DIR_PARAM,DIR_QUAL,p,q);

    for (i = 0; q[i].tag && retcod == DCL_OK; i++) {
        if (q[i].flag & PRESENT)
            switch (q[i].tag) {
                case 1:                                 /* /ALL     */
                    dir_param.all = TRUE;
                    break;
                case 2:                                 /* /ATTR    */
                    dir_param.attr = TRUE;
                    dir_param.brief = 0;
                    dir_param.full = 0;
                    break;
                case 3:                                 /* /BEFORE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&dir_param.before);
                    break;
                case 4:                                 /*  /BRIEF  */
                    dir_param.brief = 1;
                    dir_param.attr  = 0;
                    dir_param.full  = 0;
                    dir_param.date = 0;
                    dir_param.size = 0;
                    break;
                case 5:                                /*  /COLUMNS    */
                    j = atoi(q[i].value);
                    if (j > 0) {
                        dir_param.cols = j;
                        }
                    else {
                        dcl_printf(dcl[D].SYS_OUTPUT,"WARNING: Invalid /COLUMNS parameter.\n");
                        _SEVERITY = _WARNING;
                        _STATUS = 19;
                        }
                    break;
                case 6:                                 /*  /DATE   */
                case 19:                                /*  /TIME   */
                    dir_param.date = 1;
                    dir_param.brief = 0;
                    dir_param.full  = 0;
                    break;
                case 7:                                 /*  /FULL   */
                    dir_param.full  = 1;
                    dir_param.brief = 0;
                    dir_param.date = 0;
                    dir_param.size = 0;
                    dir_param.attr  = 0;
                    break;
                case 8:                                 /*  /TOTAL  */
                    dir_param.total = 1;
                    dir_param.grand_total = 1;
                    break;
                case 9:                                 /*  /HEAD   */
                    dir_param.heading = 1;
                    break;
                case 10:                                /* /NOHEAD  */
                    dir_param.heading = 0;
                    break;
                case 11:                                /* /OUT=    */
                    dcl_string(q[i].value,vms,MAX_TOKEN);
                    cvfs_vms_to_dos(vms,dos,&recurse);
                    if (!cvfs_check_device(dos)){
                        _splitpath(dos,drive,dir,file,ext);
                        if (strlen(file) == 0){
                            strcat(dos,"DIRECTORY");
                            }
                        if (strlen(ext) == 0){
                            strcat(dos,".LIS");
                            }
                        }
                    dir_param.output = fopen(dos,"at");
                    if (dir_param.output == NULL) {
                        dcl_printf(dcl[D].SYS_OUTPUT,"%s: %s\n",vms,strerror(errno));
                        _SEVERITY = 2;
                        _STATUS = 19;
                        retcod = DCL_ERROR;
                        }
                    else
                        f_output = 1;
                    *vms = 0;
                    break;
                case 12:                            /*  /SINCE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&dir_param.since);
                    break;
                case 13:                            /*  /SIZE   */
                    if (!*q[i].value) strcpy(q[i].value,"BYTES");
                    j = dcl_search(size_q,q[i].value);
                    switch (j) {
                        case AMBIGUOUS:
                            dcl_printf(dcl[D].SYS_OUTPUT,"Ambiguous /SIZE qualifier\n");
                            _SEVERITY = 2;
                            _STATUS = 19;
                            retcod = DCL_ERROR;
                            break;
                        case NOT_FOUND:
                            dcl_printf(dcl[D].SYS_OUTPUT,"Invalid /SIZE qualifier\n");
                            _SEVERITY = 2;
                            _STATUS = 19;
                            retcod = DCL_ERROR;
                            break;
                        case BYTES:
                        case BLOCKS:
                        case KILOBYTES:
                        case MEGABYTES:
                        case GIGABYTES:
                            dir_param.size  = j;
                            dir_param.brief = 0;
                            dir_param.full  = 0;
                            break;
                        default:
                            ;
                        }
                    break;
                case 14:                            /*  /SUBDIR */
                    s_recurse = 1;
                    break;
                case 15:                            /*  /NOSUBDIR   */
                    s_recurse = 0;
                    break;
                case 16:                            /*  /TOTAL  */
                    dir_param.total = 1;
                    break;
                case 17:                            /* /TRAIL   */
                    dir_param.trailing = 1;
                    break;
                case 18:                            /*  /NOTRAIL    */
                    dir_param.trailing = 0;
                    break;
                case 20:                            /* /PAGE    */
                    if (f_output) {
                        dcl_printf(dcl[D].SYS_OUTPUT,"/PAGE and /OUTPUT parameters are mutually exclusives.\n");
                        _SEVERITY = 2;
                        _STATUS = 19;
                        retcod = DCL_ERROR;
                        }
                    dir_param.page = 1;
                    break;
                case 21:                            /*  /ORDER   */
                case 22:                            /*  /SORT    */
                    if (!*q[i].value) strcpy(q[i].value,"NAME");
                    j = dcl_search(order_q,q[i].value);
                    switch (j) {
                        case AMBIGUOUS:
                            dcl_printf(dcl[D].SYS_OUTPUT,"Ambiguous /ORDER qualifier\n");
                            _SEVERITY = 2;
                            _STATUS = 19;
                            retcod = DCL_ERROR;
                            break;
                        case NOT_FOUND:
                            dcl_printf(dcl[D].SYS_OUTPUT,"Invalid /ORDER qualifier\n");
                            _SEVERITY = 2;
                            _STATUS = 19;
                            retcod = DCL_ERROR;
                            break;
                        default:
                            dir_param.order = j;
                            ;
                        }
                    break;
                default:
                    ;
                } /* end switch */
        }   /* end for */

    if (retcod == DCL_OK) {
        if (dir_param.heading == 0)
            dir_param.cols = 1;
        dcl_string(p[0].value,vms,MAX_TOKEN);
        if (strcmp(vms,"..") == 0)
            strcpy(vms,"[-]");
        cvfs_vms_to_dos(vms,dos,&recurse);
        if (isdir(dos) && dos[strlen(dos)-1] != SLASH_CHR)
            strcat(dos,SLASH_STR);
        if (s_recurse) recurse = s_recurse;
        dcldir_searchdir(dos,recurse,&dir_param);

        if (CTRL_Y) {
            goto ExitLabel;
        }

        if (dir_param.gt_file_counter == 0) {
            dcl_printf(dir_param.output,"File not found.\n");
            }
        if ((dir_param.dir_counter > 1 && dir_param.trailing)
            || dir_param.grand_total) {
            dcl_printf(dir_param.output,"Grand total of %d directories, %d files",
                    dir_param.dir_counter,dir_param.gt_file_counter);
            if (dir_param.size) {
                dcl_printf(dir_param.output,", %ld",dir_param.gt_tot_size);
                switch (dir_param.size) {
                    case BYTES:
                        dcl_printf(dir_param.output," bytes");
                        break;
                    case BLOCKS:
                        dcl_printf(dir_param.output," blocks");
                        break;
                    case KILOBYTES:
                        dcl_printf(dir_param.output," KBytes");
                        break;
                    case MEGABYTES:
                        dcl_printf(dir_param.output," MBytes");
                        break;
                    case GIGABYTES:
                        dcl_printf(dir_param.output," GBytes");
                        break;
                    default:
                        dcl_printf(dir_param.output," ***");
                    }
                }
            if (dir_param.full) {
                dcl_printf(dir_param.output,", %ld bytes",dir_param.gt_tot_size);
                }
            dcl_printf(dir_param.output,".\n");
            }
        }

ExitLabel:
    if (f_output)
        fclose(dir_param.output);
    if (HARDERR)
        tio_print_interrupt();

    return(retcod);
}
Exemple #18
0
int dcl_write(PARAM_T *p, PARAM_T *q)
{
    FILE    *fp;
    char    token[MAX_TOKEN];
    char    lognam[MAX_TOKEN];
    char    expr[1024];
    char    err_label[MAX_TOKEN];
    char    work[MAX_TOKEN];
    char    temp[MAX_TOKEN];
    char    *w;
    int     i = 0;
    char    openmode;
    int     filenum;
    int     retcod  = 0;
    int     recl    = 0;
    long    rptr    = 0;
    long    wptr    = 0;
    char    line    = 0;
    char    column  = 0;
    char    *ch;

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

    _STATUS = 0;
    memset(token,    0, sizeof(token));
    memset(expr,     0, sizeof(expr));
    memset(lognam,   0, sizeof(lognam));
    memset(err_label,0, sizeof(err_label));
    memset(work     ,0, sizeof(work));
    memset(temp,     0, sizeof(temp));

    (void) cmd_parse_line(dcl_line,WRITE_PARAM,WRITE_QUAL,p,q);
    for (i = 0; q[i].tag; i++) {
        if (q[i].flag & PRESENT)
            switch (q[i].tag) {
            case 1:                                 /*  /ERROR     */
                dcl_string(q[i].value,err_label,MAX_TOKEN);
                if (*err_label == 0) {
                    NEXT_LINE();
                    (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid /ERROR argument\n");
                    _SEVERITY = 2;
                    _STATUS = 19;
                    retcod = -1;
                    goto exit_label;
                }
                break;
            case 2:                                 /*  /POSITION  */
                *work = 0;
                w = work;
                ch = q[i].value;
                while (*ch && (*ch == '(' || isspace((int)*ch))) ch++;
                while (*ch && *ch != ',' && !isspace((int)*ch))
                    *w++ = *ch++;
                *w = 0;
                (void) EXP_compute(work,temp);
                line = (char) atoi(temp);
                if (line == 0) {
                    (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid LINE POSITION qualifier\n");
                    _SEVERITY = 2;
                    _STATUS = 19;
                    retcod = DCL_ERROR;
                }
                line--;
                *work = 0;
                w = work;
                while (*ch && (*ch == ',' || isspace((int)*ch))) ch++;
                while (*ch && *ch != ')' && !isspace((int)*ch))
                    *w++ = *ch++;
                *w = 0;
                (void) EXP_compute(work,temp);
                column = (char) atoi(temp);
                if (column == 0) {
                    (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid COLUMN POSITION qualifier\n");
                    _SEVERITY = 2;
                    _STATUS = 19;
                    retcod = DCL_ERROR;
                }
                column--;
                break;
            default:
                ;
            } /* end switch */
    }   /* end for */

    dcl_string(p[0].value,lognam,LOGICAL_MAX_NAME);
    if (lognam[strlen(lognam)-1] == ':')
        lognam[strlen(lognam)-1] = 0;

    if (p[1].expr != NULL)
        (void) EXP_compute(p[1].expr,expr);
    else
        *expr = 0;

    filenum = -1;

    if (strcasecmp(lognam,"SYS$INPUT")==0) {
        fp = dcl[D].SYS_INPUT;
        openmode = OPEN_MODE_READ;
        strcpy(token, lognam);
    }
    else if (strcasecmp(lognam,"SYS$OUTPUT")==0) {
        fp = dcl[D].SYS_OUTPUT;
        openmode = OPEN_MODE_WRITE;
        strcpy(token, lognam);
    }
    else {
        logical_get_file(lognam,token,&filenum,&openmode,&recl,&rptr,&wptr);

        if (filenum == -1)
            fp = NULL;
        else
            fp = dclfile[filenum];
    }


    if (fp == NULL) {
        if (!*err_label)
            (void) dcl_printf(dcl[D].SYS_OUTPUT,"File %s not open.\n",lognam);
        _SEVERITY = 2;
        _STATUS = 101;
        retcod = -1;
        goto exit_label;
    }

    if (!((openmode & OPEN_MODE_WRITE) || (openmode & OPEN_MODE_APPEND))) {
        if (!*err_label)
            (void) dcl_printf(dcl[D].SYS_OUTPUT,"File %s not open in WRITE mode.\n",lognam);
        _SEVERITY = 2;
        _STATUS = 103;
        retcod = -1;
        goto exit_label;
    }

    fseek(fp,wptr,SEEK_SET);

    if (recl) {
        if (fwrite(expr,(size_t) recl,1,fp) != 1) {
            if (!*err_label)
                (void) dcl_printf(dcl[D].SYS_OUTPUT,"Error writing file %s ",lognam);
            (void) dcl_printf(dcl[D].SYS_OUTPUT,"%s\n",strerror(errno));
            _STATUS = errno;
            _SEVERITY = 2;
            retcod = -1;
            goto exit_label;
        }
    } else {
        if (fp == stdout || fp == stderr) {
            if (line || column)
                tio_gotoxy(column,line);
            (void)tio_printf("%s\n",expr);
        } else {
            if (fputs(expr,fp) == EOF) {
                if (!*err_label)
                    (void) dcl_printf(dcl[D].SYS_OUTPUT,"Error writing file %s ",lognam);
                (void) dcl_printf(dcl[D].SYS_OUTPUT,"%s\n",strerror(errno));
                _STATUS = errno;
                _SEVERITY = 2;
                retcod = -1;
                goto exit_label;
            }
            fputc('\n',fp);
        }
    }
    wptr = ftell(fp);
    (void) logical_put_file(lognam,token,LOG_USER,filenum,openmode,recl,rptr,wptr);

exit_label:

    if (retcod == -1) {
        if (*err_label) {
            sprintf(dcl_line,"GOTO %s",err_label);
            retcod = dcl_process_command_line(0);
        }
    }
    return(retcod);
}
Exemple #19
0
int dcl_assign(PARAM_T *p,PARAM_T *q)
{
	char    token[MAX_TOKEN];
    char    value[LOGICAL_MAX_VALUE];
    char    name[LOGICAL_MAX_NAME];
    char    dosfile[_MAX_PATH];
    char    drive[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    fname[_MAX_FNAME];
    char    ext[_MAX_EXT];
    int     i = 0;
    int     log = 0;
    int     retcod = DCL_OK;


    NEXT_LINE();
    if (cmd[C].subr) return(DCL_OK);
    if (!dcl[D].cc[dcl[D].ccl]) return(DCL_OK);

    *token = 0; *value = 0; *name = 0;

    retcod = cmd_parse_line(dcl_line,ASSIGN_PARAM,ASSIGN_QUAL,p,q);

    if (retcod == DCL_OK) {
        for (i = 0; q[i].tag; i++) {
            if (q[i].flag & PRESENT) 
                switch (q[i].tag) {
                    case 1:                                 /* /LOG     */
                        log = TRUE;
                        break;
                    case 2:                                 /* /NOLOG   */
                        log = FALSE;
                        break;
                    default:
                        ;
                    } /* end switch */
            }   /* end for */

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

	    (void)logical_get(name,token);

        retcod = logical_put(name,value,LOG_USER);
        if (log && *token && !retcod) {
            (void)dcl_printf(dcl[D].SYS_OUTPUT,"%s superseded\n",name);
        }
        if (retcod == DCL_OK) {
            if (strcasecmp(name,"SYS$OUTPUT") == 0) {
                if (dcl[D].SYS_OUTPUT != stdout) {
                    //(void)fclose(dcl[D].SYS_OUTPUT);
                }
                if (strcasecmp(value, "tt") == 0) {
                    dcl[D].SYS_OUTPUT = stdout;
                    strcpy(dcl[D].outname, name);
                }
                else {
                	cvfs_vms_to_dos(name,dosfile,&i);
	                _splitpath(dosfile,drive,dir,fname,ext);
	                if (strlen(ext) == 0) strcat(dosfile,".lis");
	                dcl[D].SYS_OUTPUT = fopen(dosfile,"at");
	                if (dcl[D].SYS_OUTPUT == NULL) {
	                    dcl[D].SYS_OUTPUT = stdout;
                        strcpy(dcl[D].outname, "SYS$OUTPUT");
	                    }
	                else {
                        strncpy(dcl[D].outname,dosfile,_MAX_PATH);
	                }
            	}
            }
        }
    }
    return(retcod);
}