Example #1
0
int main( int argc, char *argv[] ) {

    FILE *scriptfp;

    char linebuffer[BUFSIZE];
    char command[CMDSIZE], par1[PARSIZE], par2[PARSIZE], par3[PARSIZE];
    char *token;

    if( argc != 2 ) {
        fprintf(stderr,"Usage: vfsdriver <scriptfile>\n");
        return(1);
    }

    if( (scriptfp=fopen(argv[1],"r")) == NULL ) {
        fprintf(stderr,"Unable to open script file: %s\n", argv[1]);
        return(2);
    }

    while( fgets(linebuffer, sizeof(linebuffer), scriptfp) != NULL ) {
        /* This output is for debugging... do not uncomment in final version */
#if MAIN_DEBUG
        printf("==================================================\n");
        printf("Processing: %s", linebuffer);
#endif

        /* Remove the extra newline character in the end of line */
        linebuffer[ strlen(linebuffer)-1 ] = '\0';

        /* Get the command and the parameters using tokenizer */
        strcpy( command, (token = strtok(linebuffer, " ")) == NULL ? "" : token );

        strcpy( par1, (token = strtok(NULL, " ")) == NULL ? "" : token );
        strcpy( par2, (token = strtok(NULL, " ")) == NULL ? "" : token );
        strcpy( par3, (token = strtok(NULL, " ")) == NULL ? "" : token );
#if MAIN_DEBUG
        printf("Command:%s:p1:%s:p2:%s:p3:%s\n",command, par1, par2, par3);
        printf("==================================================\n");
#endif

        processcommand( command, par1, par2, par3 );
    }

    v_freeResources();

    return 0;
}
Example #2
0
LRESULT CALLBACK LeftyWndProc (
    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
) {
    Gwidget_t *widget;
    WINDOWPOS *wpos;
    Gevent_t gev;

    widget = findwidget (hwnd, G_VIEWWIDGET);
    switch (message) {
    case WM_WINDOWPOSCHANGED:
        if (Gnocallbacks || !widget)
            return (DefWindowProc(hwnd, message, wparam, lparam));
        wpos = (WINDOWPOS *) lparam;
        if (!(wpos->flags & SWP_NOSIZE))
            handleresize (widget);
        break;
    case WM_COMMAND:
        if (Gnocallbacks || !widget)
            return (DefWindowProc(hwnd, message, wparam, lparam));
        processcommand (widget, wparam, lparam);
        break;
    case WM_CLOSE:
        if (!widget)
            exit (0);
        if (WVU->closing)
            DestroyWindow (hwnd);
        if (Gnocallbacks)
            exit (0);
        gev.type = 0, gev.code = 0, gev.data = 0;
        gev.wi = widget - &Gwidgets[0];
        if (WVU->func)
            (*WVU->func) (&gev);
        else
            exit (0);
        break;
    case WM_PALETTECHANGED:
        palettechanged = (HWND) wparam;
        break;
    default:
        return (DefWindowProc(hwnd, message, wparam, lparam));
    }
    return 0;
}
Example #3
0
void tcp_listen(struct tcp_socket* inputsocket, struct rtlsdrstruct* sdr, struct liquidobjects* dsp) {
	listen(inputsocket->sockfd, 50);
	inputsocket->clilen = sizeof(inputsocket->cli_addr);

	while (sdr->receiverexitflag == false) {

		bool connected = false;

		inputsocket->newsockfd = accept(inputsocket->sockfd, (struct sockaddr *) &inputsocket->cli_addr,
				&inputsocket->clilen);
		if (inputsocket->newsockfd < 0) {
			//Waiting for connectoin
//			printf("Waiting for connection\n");
		} else {
			printf("Client Accepted!\n");
			connected = true;
		}

		while ((connected == true) && (sdr->receiverexitflag == false)) {
			int n;
			bzero(inputsocket->receivebuffer, (100 * sizeof(uint32_t)));
			//receive in loop until a disconnect is received
			n = read(inputsocket->newsockfd, inputsocket->receivebuffer, (1000 * sizeof(char)));

			if (n < 0) {
//				printf("ERROR reading from socket");
				//it was a timeout do nothing
			} else {
				//command received, process command

				uint32_t part1;
				uint32_t part2;
				memcpy(&part1, inputsocket->receivebuffer, 4);
				memcpy(&part2, inputsocket->receivebuffer + 4, 4);

				printf("Command received; %d:%d\n", part1, part2);

				connected = processcommand(inputsocket, sdr, dsp, part1, part2);
			}
		}
	}

}
Example #4
0
LRESULT CALLBACK ArrayWndProc (
    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
) {
    Gwidget_t *widget;
    WINDOWPOS *wpos;

    if (Gnocallbacks || !(widget = findwidget (hwnd, G_ARRAYWIDGET)))
        return (DefWindowProc(hwnd, message, wparam, lparam));
    switch (message) {
    case WM_WINDOWPOSCHANGED:
        wpos = (WINDOWPOS *) lparam;
        if (!(wpos->flags & SWP_NOSIZE))
            handleresize (widget);
        break;
    case WM_COMMAND:
        processcommand (widget, wparam, lparam);
        break;
    default:
        return (DefWindowProc (hwnd, message, wparam, lparam));
    }
    return 0;
}
Example #5
0
LRESULT CALLBACK LabelWndProc (
    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
) {
    Gwidget_t *widget;
    PAINTSTRUCT paintstruct;
    WINDOWPOS *wpos;
    Gevent_t gev;
    RECT r;
    HDC hdc;
    int wi;

    if (Gnocallbacks || !(widget = findwidget (hwnd, G_LABELWIDGET)))
        return (DefWindowProc(hwnd, message, wparam, lparam));
    switch (message) {
    case WM_PAINT:
        hdc = BeginPaint (widget->w, &paintstruct);
        GetWindowText (widget->w, &Gbufp[0], Gbufn);
        GetClientRect (widget->w, &r);
        DrawText (hdc, (LPCSTR) &Gbufp[0], strlen (Gbufp), &r, DT_LEFT);
        EndPaint (widget->w, &paintstruct);
        return (DefWindowProc(hwnd, message, wparam, lparam));
    case WM_WINDOWPOSCHANGED:
        wpos = (WINDOWPOS *) lparam;
        if (!(wpos->flags & SWP_NOSIZE))
            handleresize (widget);
        return 0;
    case WM_COMMAND:
        processcommand (widget, wparam, lparam);
        return 0;
    case WM_KEYDOWN:
    case WM_KEYUP:
        gev.type = G_KEYBD;
        gev.code = (message == WM_KEYDOWN) ? G_DOWN : G_UP;
        gev.data = wparam;
        /* continues after the end of this switch */
        break;
    case WM_LBUTTONDOWN:
    case WM_LBUTTONUP:
    case WM_MBUTTONDOWN:
    case WM_MBUTTONUP:
    case WM_RBUTTONDOWN:
    case WM_RBUTTONUP:
        gev.type = G_MOUSE;
        if (wparam & MK_CONTROL) {
            if (message == WM_LBUTTONDOWN)
                message = WM_MBUTTONDOWN;
            else if (message == WM_LBUTTONUP)
                message = WM_MBUTTONUP;
        }
        switch (message) {
        case WM_LBUTTONDOWN: gev.code = G_DOWN, gev.data = G_LEFT;   break;
        case WM_LBUTTONUP:   gev.code = G_UP,   gev.data = G_LEFT;   break;
        case WM_MBUTTONDOWN: gev.code = G_DOWN, gev.data = G_MIDDLE; break;
        case WM_MBUTTONUP:   gev.code = G_UP,   gev.data = G_MIDDLE; break;
        case WM_RBUTTONDOWN: gev.code = G_DOWN, gev.data = G_RIGHT;  break;
        case WM_RBUTTONUP:   gev.code = G_UP,   gev.data = G_RIGHT;  break;
        }
        /* continues after the end of this switch */
        break;
    default:
        return (DefWindowProc(hwnd, message, wparam, lparam));
    }
    wi = gev.wi = widget - &Gwidgets[0];
    if (widget->u.l->func)
        (*widget->u.l->func) (&gev);
    if (Gpopdownflag) {
        Gpopdownflag = FALSE;
        if (gev.type == G_MOUSE && gev.code == G_DOWN) {
            gev.code = G_UP;
            widget = &Gwidgets[wi];
            if (widget->inuse && widget->u.l->func)
                (*widget->u.l->func) (&gev);
        }
    }
    return 0;
}
Example #6
0
LRESULT CALLBACK CanvasWndProc (
    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
) {
    Gwidget_t *widget;
    WINDOWPOS *wpos;
    PIXpoint_t pp;
    Gevent_t gev;
    POINT p;
    int wi, bn;

    static int cntlflag;

    if (Gnocallbacks || !(widget = findwidget (hwnd, G_CANVASWIDGET)))
        return (DefWindowProc(hwnd, message, wparam, lparam));
    Gpopdownflag = FALSE;
    switch (message) {
    case WM_PAINT:
        if (palettechanged != hwnd)
            RealizePalette (widget->u.c->gc);
        Gneedredraw = widget->u.c->needredraw = TRUE;
        Gadjustclip (widget);
        return (DefWindowProc(hwnd, message, wparam, lparam));
    case WM_WINDOWPOSCHANGED:
        wpos = (WINDOWPOS *) lparam;
        if (!(wpos->flags & SWP_NOSIZE))
            handleresize (widget);
        return 0;
    case WM_MOUSEACTIVATE:
        SetFocus (widget->w);
        return (DefWindowProc(hwnd, message, wparam, lparam));
    case WM_COMMAND:
        processcommand (widget, wparam, lparam);
        return 0;
    case WM_CHAR:
        gev.type = G_KEYBD;
        gev.code = G_DOWN;   /* I don't know how to get up events so I make */
        Gpopdownflag = TRUE; /* the code after this switch send the up event */
        gev.data = wparam;
        GetCursorPos (&p);
        ScreenToClient (widget->w, &p);
        pp.x = p.x, pp.y = p.y;
        gev.p = ppixtodraw (widget, pp);
        /* continues after the end of this switch */
        break;
    case WM_LBUTTONDOWN:
    case WM_LBUTTONUP:
    case WM_MBUTTONDOWN:
    case WM_MBUTTONUP:
    case WM_RBUTTONDOWN:
    case WM_RBUTTONUP:
        gev.type = G_MOUSE;
        if (twobmouse) {
            if (message == WM_LBUTTONDOWN && (wparam & MK_CONTROL))
                message = WM_MBUTTONDOWN, cntlflag = TRUE;
            if (message == WM_LBUTTONUP && cntlflag)
                message = WM_MBUTTONUP, cntlflag = FALSE;
        }
        switch (message) {
        case WM_LBUTTONDOWN: gev.code = G_DOWN, gev.data = G_LEFT;   break;
        case WM_LBUTTONUP:   gev.code = G_UP,   gev.data = G_LEFT;   break;
        case WM_MBUTTONDOWN: gev.code = G_DOWN, gev.data = G_MIDDLE; break;
        case WM_MBUTTONUP:   gev.code = G_UP,   gev.data = G_MIDDLE; break;
        case WM_RBUTTONDOWN: gev.code = G_DOWN, gev.data = G_RIGHT;  break;
        case WM_RBUTTONUP:   gev.code = G_UP,   gev.data = G_RIGHT;  break;
        }
        pp.x = LOWORD (lparam), pp.y = HIWORD (lparam);
        gev.p = ppixtodraw (widget, pp);
        bn = WCU->bstate[gev.data];
        WCU->bstate[gev.data] = (gev.code == G_DOWN) ? 1 : 0;
        bn = WCU->bstate[gev.data] - bn;
        widget->u.c->buttonsdown += bn;
        Gbuttonsdown += bn;
        /* continues after the end of this switch */
        break;
    default:
        return (DefWindowProc(hwnd, message, wparam, lparam));
    }
    wi = gev.wi = widget - &Gwidgets[0];
    if (widget->u.c->func)
        (*widget->u.c->func) (&gev);
    if (Gpopdownflag) {
        Gpopdownflag = FALSE;
        if (gev.code == G_DOWN) {
            gev.code = G_UP;
            widget = &Gwidgets[wi];
            WCU->bstate[gev.data] = 0;
            widget->u.c->buttonsdown--;
            Gbuttonsdown--;
            if (widget->inuse && widget->u.c->func)
                (*widget->u.c->func) (&gev);
        }
    }
    return 0;
}