Esempio n. 1
0
int init_SDL(void)
{
    joy[0]=0;
    joy[1]=0;
    joy[2]=0;
    joy[3]=0;

    if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
        return(0);
    }
    sdlscreen = SDL_SetVideoMode(0,0, 16, SDL_SWSURFACE);

    //We handle up to four joysticks
    if(SDL_NumJoysticks())
    {
        int i;
        SDL_JoystickEventState(SDL_ENABLE);

        for(i=0;i<SDL_NumJoysticks();i++) {
            joy[i]=SDL_JoystickOpen(i);

            //Check for valid joystick, some keyboards
            //aren't SDL compatible
            if(joy[i])
            {
                if (SDL_JoystickNumAxes(joy[i]) > 28)
                {
                    SDL_JoystickClose(joy[i]);
                    joy[i]=0;
                    logoutput("Error detected invalid joystick/keyboard\n");
                }
                else
                    joyCount++;
            }
        }
        if(joy[0])
            logoutput("Found %d joysticks\n",joyCount);
    }
    else
        joyCount=1;

    //sq frig number of players for keyboard
    //joyCount=2;

    SDL_EventState(SDL_ACTIVEEVENT,SDL_IGNORE);
    SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE);
    SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE);
    SDL_EventState(SDL_USEREVENT,SDL_IGNORE);
    SDL_ShowCursor(SDL_DISABLE);

    //Initialise dispmanx
    bcm_host_init();

    //Clean exits, hopefully!
    atexit(exitfunc);

    return(1);
}
Esempio n. 2
0
struct client_struct *register_client(unsigned int fd, pid_t pid, uid_t uid, gid_t gid, unsigned char type, int mode)
{
    struct client_struct *client=NULL;

    logoutput("register_client: for pid %i", (int) pid);

    lock_clientslist();

    /* check existing clients */

    client=clients_list;

    while (client) {

        if ( client->pid==pid ) break;
        client=client->next;

    }

    unlock_clientslist();

    if ( client ) {

        logoutput("register_client: client for pid %i does already exist", (int) pid);

    } else {

	client=create_client(fd, pid, uid, gid, type);

	/* insert at begin of list */

	if ( client) {

	    lock_clientslist();

	    add_client_to_list(client);

	    unlock_clientslist();

	    client->owner_id=new_owner_id();
	    client->mode=mode;

	}

    }

    unlock:

    return client;

}
static void workspace_nfs_write(fuse_req_t req, const char *buff, size_t size, off_t offset, struct workspace_fh_struct *fh)
{
    struct resource_struct *resource=fh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data;
    int result=0;

    logoutput("workspace_nfs_write");

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_pwrite(nfs_ctx, nfsfh, offset, size, (void *) (intptr_t) buff);

    pthread_mutex_unlock(&nfs_export->mutex);

    if (result>=0) {

	fuse_reply_write(req, result);

    } else {

	fuse_reply_err(req, abs(result));

    }

}
static void workspace_nfs_open(fuse_req_t req, struct workspace_fh_struct *fh)
{
    struct resource_struct *resource=fh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    char *path=fh->pathinfo.path + fh->relpath;
    struct nfsfh *nfsfh=NULL;
    int result=0;

    if (strlen(path)==0) path=(char *) rootpath;

    logoutput("workspace_nfs_open, path %s", path);

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_open(nfs_ctx, path, fh->flags, &nfsfh);

    pthread_mutex_unlock(&nfs_export->mutex);

    if (result==0) {

	fh->handle.data=(void *) nfsfh;
	fuse_reply_open(req, fh->fi);

    } else {

	fuse_reply_err(req, abs(result));

    }

    free_path_pathinfo(&fh->pathinfo);

}
static void workspace_nfs_release(fuse_req_t req, struct workspace_fh_struct *fh)
{
    struct resource_struct *resource=fh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data;
    struct fuse_file_info *fi=fh->fi;

    logoutput("workspace_nfs_release");

    if (nfsfh) {
	int result=0;

        pthread_mutex_lock(&nfs_export->mutex);

	result=nfs_close(nfs_ctx, nfsfh);

        pthread_mutex_unlock(&nfs_export->mutex);

    }

    free(fh);

    fi->fh=0;

    fuse_reply_err(req, 0);

}
static void workspace_nfs_fgetattr(fuse_req_t req, struct workspace_fh_struct *fh)
{
    struct resource_struct *resource=fh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data;
    int result=0;
    struct stat st;

    logoutput("workspace_nfs_fgetattr");

    memset(&st, 0, sizeof(struct stat));

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_fstat(nfs_ctx, nfsfh, &st);

    pthread_mutex_unlock(&nfs_export->mutex);

    if (result==0) {

	fuse_reply_attr(req, &st, fs_options.attr_timeout);

    } else {

	fuse_reply_err(req, -result);

    }

}
void increase_use_reader_manager()
{
    int res;

    pthread_mutex_lock(&references_mutex);

    if (references==0) {

	res=pthread_create(&reader_manager_pthreadid, NULL, &cdromreader_thread, NULL);

	if ( res==-1 ) {

	    logoutput("Error creating thread for caching audio read results(error: %i).", errno);

	} else {

	    references=1;

	}

    } else {

	references++;

    }

    pthread_mutex_unlock(&references_mutex);

}
Esempio n. 8
0
int send_message(int fd, struct notifyfs_message_body *message, void *data, int len)
{
    struct msghdr msg;
    struct iovec io_vector[2];
    int nreturn=0;

    msg.msg_controllen=0;
    msg.msg_control=NULL;

    msg.msg_name=NULL;
    msg.msg_namelen=0;

    io_vector[0].iov_base=(void *) message;
    io_vector[0].iov_len=sizeof(struct notifyfs_message_body);

    io_vector[1].iov_base=data;
    io_vector[1].iov_len=len;

    msg.msg_iov=io_vector;
    msg.msg_iovlen=2;

    /* the actual sending */

    nreturn=sendmsg(fd, &msg, 0);

    if ( nreturn==-1 ) nreturn=-errno;

    logoutput("send_message: return %i", nreturn);

    out:

    return nreturn;

}
static int fscd_destroy(struct workspace_object_struct *object, unsigned char flags)
{

    logoutput("fscd_destroy");

    fscd_umount(object);

    return 0;
}
Esempio n. 10
0
static void workspace_nfs_opendir(fuse_req_t req, struct workspace_dh_struct *dh)
{
    struct resource_struct *resource=dh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    char *path=dh->pathinfo.path + dh->relpath;
    unsigned int error=0;
    struct directory_struct *directory=dh->directory;
    struct nfsdir *dir=NULL;
    int result=0;

    if (strlen(path)==0) path=(char *) rootpath;

    logoutput("workspace_nfs_opendir: path %s", path);

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_opendir(nfs_ctx, path, &dir);

    pthread_mutex_unlock(&nfs_export->mutex);

    if (result==0) {

	dh->handle.data = (void *) dir;

        fuse_reply_open(req, dh->fi);
	free_path_pathinfo(&dh->pathinfo);

	return;

    } else {

	error=abs(result);

    }

    logoutput("workspace_opendir, error %i", error);

    fuse_reply_err(req, error);
    free_path_pathinfo(&dh->pathinfo);

}
Esempio n. 11
0
QVariant FileListModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid()) {

	logoutput("data: no valid index");
	return QVariant();

    }

    if (role != Qt::DisplayRole) return QVariant();

    if (index.row()>=totalCount) {

	logoutput("data: index row %i bigger than total %i", index.row(), totalCount);
	return QVariant();

    }

    if (index.row()>=0) {
	struct notifyfs_entry_struct *entry=NULL;

	entry=get_cached_entry(index.row());

	if (entry) {
	    char *name=get_data(entry->name);
	    QString entryName = QString::fromAscii(name, strlen(name));

	    // logoutput("data: name %s, entryindex %i, row %i", name, entry->index, index.row());

	    return entryName;

	} else {

	    logoutput("data: no entry found for row %i, internal id %i", index.row(), index.internalId());

	}

    }

    return QVariant();

}
static int fscd_assign(struct resource_struct *resource)
{
    int nreturn=0;

    /* only when dealing with an audio cd apply these calls */

    if (resource->group==RESOURCE_GROUP_CDROM && resource->type==CDROM_TYPE_FS) {

	logoutput("fscd_assign: positive for resource");
	nreturn=1;

    } else {

	logoutput("fscd_assign: not positive for resource");

    }

    return nreturn;

}
Esempio n. 13
0
void remove_old_entries(struct workspace_object_struct *object, struct directory_struct *directory, struct timespec *synctime)
{
    struct entry_struct *entry;

    logoutput("remove_old_entries: synctime %li:%li", synctime->tv_sec, synctime->tv_nsec);

    /* TODO: add locking */

    entry=(struct entry_struct *) directory->first;

    while (entry) {

	if (entry->inode && entry->inode->mode==0) {

	    entry=entry->name_next;
	    continue;

	}

	if (entry->synctime.tv_sec<synctime->tv_sec || 
	    (entry->synctime.tv_sec==synctime->tv_sec && entry->synctime.tv_nsec<synctime->tv_nsec)) {
	    struct entry_struct *next=entry->name_next;
	    unsigned int error=0;

	    logoutput("remove_old_entries: remove %s synctime %li:%li", entry->name.name, entry->synctime.tv_sec, entry->synctime.tv_nsec);

	    remove_entry(entry, &error);

	    if (error==0) queue_remove(object, entry, &error);

	    entry=next;

	} else {

	    entry=entry->name_next;

	}

    }

}
Esempio n. 14
0
static void workspace_nfs_readlink(fuse_req_t req, struct entry_struct *entry, struct call_info_struct *call_info)
{
    struct resource_struct *resource=call_info->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    char *path=call_info->pathinfo.path + call_info->relpath;
    int result=0;
    int len=512;
    char buffer[len];

    if (strlen(path)==0) path=(char *) rootpath;

    logoutput("workspace_nfs_readlink, path %s", path);

    /*
	TODO: make this buffer variable, only how to correct that?
	what error gives nfs_readlink back when buffer is too small?
    */

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_readlink(nfs_ctx, path, buffer, len);

    pthread_mutex_unlock(&nfs_export->mutex);

    if (result<0) {

	logoutput("workspace_nfs_readlink, error reading readlink of %s, error %i:%s", path, abs(result), nfs_get_error(nfs_ctx));

	fuse_reply_err(req, abs(result));

    } else {

	fuse_reply_readlink(req, buffer);

    }

    free_path_pathinfo(&call_info->pathinfo);

}
Esempio n. 15
0
int wait_for_notifyfs_reply(uint64_t unique, unsigned char seconds)
{
    struct notifyfs_reply_struct *notifyfs_reply=NULL;
    struct timespec expire_time;
    int res=0;

    get_current_time(&expire_time);
    expire_time.tv_sec+=seconds;

    pthread_mutex_lock(&received_reply_queue.mutex);

    while(1) {

	notifyfs_reply=lookup_notifyfs_reply(unique, &received_reply_queue);

	if ( ! notifyfs_reply) {

	    res=pthread_cond_timedwait(&received_reply_queue.cond, &received_reply_queue.mutex, &expire_time);

	    if (res==ETIMEDOUT) {

		res=-ETIMEDOUT;
		break;

	    }

	} else {

	    break;

	}

    }

    if (notifyfs_reply) {

	get_notifyfs_reply_queue(notifyfs_reply, &received_reply_queue);
	res=abs(notifyfs_reply->error);

	logoutput("wait_for_notifyfs_reply: received a reply(unique: %li), send at %li.%li, received ar %li.%li", 
	(long int) unique, notifyfs_reply->send_time.tv_sec, notifyfs_reply->send_time.tv_nsec, notifyfs_reply->reply_time.tv_sec, notifyfs_reply->reply_time.tv_nsec);

	free(notifyfs_reply);

    }

    pthread_mutex_unlock(&received_reply_queue.mutex);

    return res;

}
Esempio n. 16
0
void FileListModel::entryremoved(int row1, int row2)
{
    struct notifyfs_entry_struct *parent=NULL;

    parent=get_entry(parentEntry);
    if (! parent) return;

    logoutput("FileListModel::entryremoved");

    beginRemoveRows(QModelIndex(), row1, row2);
    totalCount -= (row2 - row1 + 1);
    endRemoveRows();

}
static int handle_inotify_fd(int fd, void *data, uint32_t events)
{
    char outputstring[256];
    int lenread=0;
    char buff[INOTIFY_BUFF_LEN];

    lenread=read(fd, buff, INOTIFY_BUFF_LEN);

    if ( lenread<0 ) {

        logoutput("handle_inotify_fd: error (%i) reading inotify events (fd: %i)", errno, fd);

    } else {
        int i=0, res;
        struct inotify_event *i_event=NULL;

        while(i<lenread) {

            i_event = (struct inotify_event *) &buff[i];

            if ( (i_event->mask & IN_Q_OVERFLOW) || i_event->wd==-1 ) {

                /* what to do here: read again?? go back ??*/

                goto next;

            }

	    if ( (i_event->mask & IN_ISDIR) && ((i_event->mask & IN_OPEN) || (i_event->mask & IN_CLOSE_NOWRITE))) {

		/* explicit ignore the reading of directories */

		goto next;

	    }

	    evaluate_fsevent_inotify(i_event);

	    next:

            i += INOTIFY_EVENT_SIZE + i_event->len;

    	}

    }

    return 0;

}
Esempio n. 18
0
void FileListModel::fetchMore(const QModelIndex & /* index */)
{
    int count=totalCount;

    logoutput("fetchMore");

    if (count<cachetotalcount) {
	int remainder =  cachetotalcount - count;
	int itemsToFetch = qMin(100, remainder);

	beginInsertRows(QModelIndex(), count, count+itemsToFetch-1);
	totalCount += itemsToFetch;
	endInsertRows();

    }

}
Esempio n. 19
0
static void overlay_releasedir(fuse_req_t req, struct workspace_dh_struct *dh)
{
    struct overlay_readdir_struct *overlay_readdir=(struct overlay_readdir_struct *)dh->handle.data;
    struct directory_struct *directory=NULL;
    struct timespec synctime;
    unsigned int error=0;
    unsigned int mode=0;

    logoutput("RELEASEDIR");

    directory=dh->directory;

    if (overlay_readdir) {

	mode=overlay_readdir->mode;

	close_readdir(overlay_readdir);

	if (overlay_readdir->fd>0) {

	    close(overlay_readdir->fd);
	    overlay_readdir->fd=0;

	}

	free(overlay_readdir);
	overlay_readdir=NULL;

    }

    fuse_reply_err(req, 0);

    if (directory) {

	/* when synced with backend and there were entries at start test these are not synced */

	if ((dh->mode & _WORKSPACE_READDIR_MODE_NONEMPTY) &&  (mode & (_FW_READDIR_MODE_SIMPLE | _FW_READDIR_MODE_FULL))) remove_old_entries(dh->object, directory, &dh->synctime);

	memcpy(&directory->synctime, &dh->synctime, sizeof(struct timespec));

    }

    clean_pathcache();

}
Esempio n. 20
0
static int getSMBremotehost(char *source, char *options, char *host, int len, unsigned char *islocal)
{
    int res;
    int len0=(INET_ADDRSTRLEN>INET6_ADDRSTRLEN) ? INET_ADDRSTRLEN : INET6_ADDRSTRLEN;
    char address[len0];

    logoutput("get_remotehost_cifs: get host for source %s and options %s", source, options);

    /* get the address from the mount source */

    res=get_value_mountoptions(options, "addr", address, len0);

    if (res>0) {
	char port[16];

	memset(port, '\0', 16);

	res=get_value_mountoptions(options, "port", port, 16);

	if (res>0) {

	    /* if port explicit in mountoptions take that */

	    res=get_hostname(address, port, host, len, islocal);

	} else {

	    /* no port found in mountoptions: first take the default 445, then 139 */

	    res=get_hostname(address, "445", host, len, islocal);

	    if (res==-ENOENT) {

		res=get_hostname(address, "139", host, len, islocal);

	    }

	}

    }

    return res;

}
Esempio n. 21
0
static void workspace_nfs_fsync(fuse_req_t req, int datasync, struct workspace_fh_struct *fh)
{
    struct resource_struct *resource=fh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data;
    int result=0;

    logoutput("workspace_nfs_fsync");

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_close(nfs_ctx, nfsfh);

    pthread_mutex_unlock(&nfs_export->mutex);

    fuse_reply_err(req, abs(result));

}
static int fscd_getattr(struct workspace_object_struct *object, struct userpolicy_struct *userpolicy, struct inode_struct *inode, char *path, struct stat *st)
{
    int nreturn=-ENOENT;

    logoutput("fscd_gettatr");

    if (inode) {

	if ( strlen(path)==0 || strcmp(path, "/")==0 || strcmp(path, ".")==0 || strcmp(path, "/.")==0 ) {

	    copy_stat(st, &inode->st);
	    nreturn=0;

	}

    }

    return nreturn;

}
static int fscd_init(struct workspace_object_struct *object)
{
    int nreturn=0, res;

    logoutput("fscd_init");

    /* check the resource is a fs cdrom */

    if (object->role) {

	if (strcmp(object->role->name, "local.dev.cdrom.fs") != 0) {

	    /* not a fs cdrom */

	    goto out;

	}

    } else if ( object->resource ) {

	if (object->resource->group != RESOURCE_GROUP_CDROM) {

	    goto out;

	} else if (object->resource->type != CDROM_TYPE_FS) {

	    goto out;

	}

    } else {

	goto out;

    }

    out:

    return nreturn;

}
struct resource_struct *create_ftp_network_resource()
{
    struct resource_struct *resource=NULL;
    struct net_ftp_network_struct *ftpnetwork=NULL;

    logoutput("create_ftp_network_resource");

    resource=get_resource();
    if (!resource) goto out;

    ftpnetwork=malloc(sizeof(struct net_ftp_network_struct));

    if ( ! ftpnetwork ) {

	free(resource);
	resource=NULL;
	goto out;

    }

    resource->parent=NULL;
    resource->group=RESOURCE_GROUP_FTP;
    resource->type=FTP_TYPE_NETWORK;
    resource->primary=1;

    resource->data=(void *) ftpnetwork;

    ftpnetwork->detect_time.tv_sec=0;
    ftpnetwork->detect_time.tv_nsec=0;

    ftpnetwork->refresh_time.tv_sec=0;
    ftpnetwork->refresh_time.tv_nsec=0;

    /* the other way around compared to resource read from cache */
    add_resource_to_list(resource, &ftp_resource_list);

    out:

    return resource;

}
Esempio n. 25
0
bool FileListModel::canFetchMore(const QModelIndex & /* index */) const
{

    logoutput("canFetchMore");

    /* check three parameters:
	- getViewCount, is what notifyfs reports 
	- getcachedtotalcount, is what is in cache
	- totalCount, is the number of rows in the view
    */

    if (totalCount<cachetotalcount) {

//	logoutput("canFetchMore: totalCount %i less then available %i", totalCount, getViewCount());
	return true;


    }

//    logoutput("canFetchMore: totalCount %i versus available %i", totalCount, getViewCount());
    return false;

}
Esempio n. 26
0
static void workspace_nfs_read(fuse_req_t req, size_t size, off_t offset, struct workspace_fh_struct *fh)
{
    struct resource_struct *resource=fh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data;
    int result=0;
    char *buff;

    buff=malloc(size);

    if (! buff) {

	fuse_reply_err(req, ENOMEM);
	return;

    }

    logoutput("workspace_nfs_read");

    pthread_mutex_lock(&nfs_export->mutex);

    result=nfs_pread(nfs_ctx, nfsfh, offset, size, buff);

    pthread_mutex_unlock(&nfs_export->mutex);

    if (result>=0) {

	fuse_reply_buf(req, buff, result);

    } else {

	fuse_reply_err(req, abs(result));

    }

}
Esempio n. 27
0
static void workspace_nfs_releasedir(fuse_req_t req, struct workspace_dh_struct *dh)
{
    struct resource_struct *resource=dh->object->resource;
    struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data;
    struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data;
    struct nfsdir *dir=(struct nfsdir *) dh->handle.data;
    struct directory_struct *directory=NULL;

    logoutput("workspace_nfs_releasedir");

    directory=dh->directory;

    if (dir) {

        pthread_mutex_lock(&nfs_export->mutex);

	nfs_closedir(nfs_ctx, dir);

        pthread_mutex_unlock(&nfs_export->mutex);

    }

    fuse_reply_err(req, 0);

    if (directory) {

	/* when synced with backend and there were entries at start test these are not synced */

	if (dh->mode & _WORKSPACE_READDIR_MODE_NONEMPTY) remove_old_entries(dh->object, directory, &dh->synctime);
	memcpy(&directory->synctime, &dh->synctime, sizeof(struct timespec));

    }

    // clean_pathcache();

}
int start_cdrom_reader_thread(pthread_t *pthreadid, struct resource_struct *resource)
{
    int nreturn=0;

    //
    // create a thread to read the cd
    //

    nreturn=pthread_create(pthreadid, NULL, cdromreader_thread, (void *) resource);

    if ( nreturn==-1 ) {

	// some error creating the thread

        nreturn=-errno;

	logoutput("Error creating a new thread (error: %i).", abs(nreturn));


    }

    return nreturn;

}
Esempio n. 29
0
void RunTests()
{
	std::string output;

#ifdef IOS
	const std::string baseDirectory = g_Config.flash0Directory + "../";
#else
	const std::string baseDirectory = g_Config.memStickDirectory;
#endif

	CoreParameter coreParam;
	coreParam.cpuCore = g_Config.bJit ? CPU_JIT : CPU_INTERPRETER;
	coreParam.gpuCore = g_Config.bSoftwareRendering ? GPU_SOFTWARE : GPU_GLES;
	coreParam.enableSound = g_Config.bEnableSound;
	coreParam.graphicsContext = PSP_CoreParameter().graphicsContext;
	coreParam.mountIso = "";
	coreParam.mountRoot = baseDirectory + "pspautotests/";
	coreParam.startPaused = false;
	coreParam.printfEmuLog = false;
	coreParam.headLess = true;
	coreParam.renderWidth = 480;
	coreParam.renderHeight = 272;
	coreParam.pixelWidth = 480;
	coreParam.pixelHeight = 272;
	coreParam.collectEmuLog = &output;
	coreParam.unthrottle = true;
	coreParam.updateRecent = false;

	// Never report from tests.
	std::string savedReportHost = g_Config.sReportHost;
	g_Config.sReportHost = "";

	for (size_t i = 0; i < ARRAY_SIZE(testsToRun); i++) {
		const char *testName = testsToRun[i];
		coreParam.fileToStart = baseDirectory + "pspautotests/tests/" + testName + ".prx";
		std::string expectedFile = baseDirectory + "pspautotests/tests/" + testName + ".expected";

		ILOG("Preparing to execute %s", testName);
		std::string error_string;
		output = "";
		if (!PSP_Init(coreParam, &error_string)) {
			ELOG("Failed to init unittest %s : %s", testsToRun[i], error_string.c_str());
			PSP_CoreParameter().pixelWidth = pixel_xres;
			PSP_CoreParameter().pixelHeight = pixel_yres;
			return;
		}

		// Run the emu until the test exits
		while (true) {
			int blockTicks = usToCycles(1000000 / 10);
			while (coreState == CORE_RUNNING) {
				PSP_RunLoopFor(blockTicks);
			}
			// Hopefully coreState is now CORE_NEXTFRAME
			if (coreState == CORE_NEXTFRAME) {
				// set back to running for the next frame
				coreState = CORE_RUNNING;
			} else if (coreState == CORE_POWERDOWN)	{
				ILOG("Finished running test %s", testName);
				break;
			}
		}
	
		std::ifstream expected(expectedFile.c_str(), std::ios_base::in);
		if (!expected) {
			ELOG("Error opening expectedFile %s", expectedFile.c_str());
			break;
		}

		std::istringstream logoutput(output);

		int line = 0;
		while (true) {
			++line;
			std::string e, o;
			std::getline(expected, e);
			std::getline(logoutput, o);
			// Remove stray returns
			e = TrimNewlines(e);
			o = TrimNewlines(o);
			if (e != o) {
				ELOG("DIFF on line %i!", line);
				ELOG("O: %s", o.c_str());
				ELOG("E: %s", e.c_str());
			}
			if (expected.eof()) {
				break;
			}
			if (logoutput.eof()) {
				break;
			}
		}
		PSP_Shutdown();
	}
	glViewport(0,0,pixel_xres,pixel_yres);
	PSP_CoreParameter().pixelWidth = pixel_xres;
	PSP_CoreParameter().pixelHeight = pixel_yres;
	PSP_CoreParameter().headLess = false;
	g_Config.sReportHost = savedReportHost;
}
Esempio n. 30
0
static void read_ftp_config()
{
    FILE *fp;
    pathstring configfile;
    char line[256];
    char *sep, *option, *value;

    /* set defaults */

    strncpy(ftp_options.networkname, "FTP", WORKSPACE_OBJECT_NAMELENMAX);

    ftp_options.enable=1;
    ftp_options.override_uid=1;
    ftp_options.uid_policy=FTP_UIDPOLICY_PUBLIC;

    /* timeout directories are not refreshed */

    ftp_options.dir_timeout=300; /* 5 minutes */

    /* timeout a readdir command will max wait before data is received from peer */

    ftp_options.readdir_peer_timeout=10;

    /* timeout a read command will max wait before data is received from peer */

    ftp_options.read_peer_timeout=10;

    /* timeout a read command will wait for another read command to finish */

    ftp_options.read_finish_timeout=10;

    ftp_options.global_ftpserver_file=NULL;
    ftp_options.private_ftpserver_file=NULL;

    /* where is the ftp config file ?? */

    snprintf(configfile, PATH_MAX, "%s/ftp.settings", DEFAULT_CONFIG_PATH);

    fp=fopen(configfile, "r");

    if (! fp) return;

    while( ! feof(fp)) {

	if ( ! fgets(line, 256, fp)) continue;

	sep=strchr(line, '\n');
	if (sep) *sep='\0';

	sep=strchr(line, '=');

	if (!sep) continue;

	*sep='\0';
	option=line;
	value=sep+1;

	if (strcmp(option, "ftp.global.network.name")==0) {

	    /* global network name for FTP
               note the is a global value, and does not offers differentiation per user (language, preferences) */

	    if (strlen(value)>0) {

		logoutput("read_ftp_config: setting ftp network name %s", value);

		strncpy(ftp_options.networkname, value, WORKSPACE_OBJECT_NAMELENMAX);

	    }

	} else if (strcmp(option, "ftp.override_uid")==0) {

	    /* override the uid/gid with certain values (todo: which) */

	    ftp_options.override_uid=atoi(value);


	} else if (strcmp(option, "ftp.uid_policy")==0) {

	    /* the uid used to override */

	    if (strcmp(value, "private")==0) {

		/* the private user, ie the user who owns the workspace */

		ftp_options.uid_policy=FTP_UIDPOLICY_PRIVATE;

	    } else if (strcmp(value, "public")==0) {

		/* the public user*/

		ftp_options.uid_policy=FTP_UIDPOLICY_PUBLIC;

	    } else if (strcmp(value, "root")==0) {

		/* the root user*/

		ftp_options.uid_policy=FTP_UIDPOLICY_ROOT;

	    }

	} else if (strcmp(option, "ftp.dir_timeout")==0) {

	    /* override the uid/gid with certain values (todo: which) */

	    ftp_options.dir_timeout=atoi(value);

	} else if (strcmp(option, "ftp.global.servers")==0) {

	    /* a file with ftp servers for everyone */

	    ftp_options.global_ftpserver_file=check_path(value);

	    if ( ftp_options.global_ftpserver_file ) {

		logoutput("read_ftp_config: file with global servers %s found", ftp_options.global_ftpserver_file);

	    } else {

		logoutput("read_ftp_config: file with global servers %s not found", value);

	    }

	} else if (strcmp(option, "ftp.private.servers")==0) {

	    /* TODO: make this a template !! */

	    /* a file with ftp servers for everyone */

	    ftp_options.private_ftpserver_file=check_path(value);

	    if ( ftp_options.private_ftpserver_file ) {

		logoutput("read_ftp_config: file with private servers %s found", ftp_options.private_ftpserver_file);

	    } else {

		logoutput("read_ftp_config: file with private servers %s not found", value);

	    }

	}

    }

    if (fp) fclose(fp);

}