Beispiel #1
0
const UCHAR *cmd_delete(const char *cmd)
{
	cmd += *cmd + 2;
	if (optmatch(cmd, "file") == 0)
		errend(21); /* delete command error */
	deletefile(pathfix(cmd + (4 + 2), 2));
	return cmd + (*cmd + 2);
}
Beispiel #2
0
void *doftp(void *sd)
{
	int req, msg_ok, ret = 0,dump;
	long ssock = (long)sd;

	ret = auth_user(ssock);
	if (ret == -1)
	{
		close(ssock);
		return;
	}

	while(1)
	{
		req = 0;

		if((readn(ssock,(char *)&req,sizeof(req))) < 0)
		{
			printf("server: read error %d\n",errno);
			return;
		}

		req = ntohs(req);
		switch(req)
		{
			case STOREFILE:
				status=sendfile(ssock);
				break;
			case REQUESTFILE:
				status=recvfile(ssock);
				break;
			case MKDIR:
				status=makedir(ssock);
				break;
			case LIST:
				status=listdir(ssock);
				break;
			case DELETEFILE:
				status=deletefile(ssock);
				break;
			case END:
				printf("Client sent request to end connection.\n");
				close(ssock);
				return;
			default:
				break;
		}
		if(status==-1)
			break;
	}
	return;
}
AppendBehavior PatchFilesResourceSource::AppendResources(const std::vector<const ResourceBlob*> &blobs)
{
    for (const ResourceBlob *blob : blobs)
    {
        std::string filename = GetFileNameFor(*blob);
        std::string fullPath = _gameFolder + "\\" + filename;
        std::string bakPath = _gameFolder + "\\" + filename + ".bak";
        // Write to the bak file
        {
            ScopedFile file(bakPath, GENERIC_WRITE, 0, CREATE_ALWAYS);
            blob->SaveToHandle(file.hFile, true);
        }
        // move it to the main guy
        deletefile(fullPath);
        movefile(bakPath, fullPath);
    }
    return AppendBehavior::Replace;
}
Beispiel #4
0
// 移除数据
bool CArcossCache::Remove( int id, char color, char *vechile )
{
	share::Guard gurad( _mutex ) ;

	ArcossData *p = RemoveIndex( id, color, vechile ) ;
	if ( p == NULL ) {
		return false ;
	}

	CMapArcoss::iterator it = _mapArcoss.find( id ) ;
	if ( it == _mapArcoss.end() ) {
		return false ;
	}

	ArcossHeader *header = it->second ;
	if ( header->_tail == p && header->_head == p ) { // 只有一个元素
		_mapArcoss.erase( it ) ;
		deletefile( id ) ;
		delete header ;
	} else { // 有多个元素的情况
		if ( p == header->_head ){ // 位于头部数据
			header->_head = p->_next ;
			if ( p->_next != NULL ) {
				p->_next->_pre = NULL ;
			}
		} else if ( p == header->_tail ){ // 位于尾部的情况
			header->_tail = p->_pre ;
			if ( p->_pre != NULL ) {
				p->_pre->_next = NULL ;
			}
		} else { // 位于中间的情况
			p->_pre->_next = p->_next ;
			p->_next->_pre = p->_pre ;
		}
		header->_size = header->_size - 1 ;
	}
	delete p ;

	return true ;
}
Beispiel #5
0
static boolean dbnewverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
	
	//
	// 2006-06-20 creedon: for Mac, extend filespec
	//
	// 4.1b5 dmb: new verb
	//
	
	tyodbrecord odbrec;
	boolean fl;
	
	flnextparamislast = true;
	
	if ( ! getfilespecvalue ( hparam1, 1, &odbrec.fs ) )
		return (false);
		
	shellpushdefaultglobals (); // so that config is correct
	
	fl = opennewfile ( &odbrec.fs, config.filecreator, config.filetype, &odbrec.fref );
	
	shellpopglobals ();
	
	if (!fl)
		return (false);
	
	fl = odbnewfile (odbrec.fref);
	
	closefile (odbrec.fref);
	
	if (odberror (fl)) {
		
		deletefile ( &odbrec.fs );
		
		return (false);
		}
	
	return (setbooleanvalue (true, vreturned));
	} // dbnewverb
Beispiel #6
0
function main() {

	printl("filespeed says 'Hello World!'");
	createfile("TEMP");
	var file;
	open("TEMP",file);
	var rec=str("x",1000);

	begintrans();
	for (var ii=0;ii<1000;++ii){
//		print("+");
		write(rec,file,ii);
	}
	printl("written 1000 1000byte records");
	for (int ii=0;ii<1000;++ii){
//		print("-");
		deleterecord(file,ii);
	}
	committrans();
	printl("deleted 1000 1000byte records");

	deletefile("TEMP");
	return 0;
}
Beispiel #7
0
retvalue files_checkincludefile(const char *sourcedir, const char *basefilename, const char *filekey, struct checksums **checksums_p) {
	char *sourcefilename, *fullfilename;
	struct checksums *checksums;
	retvalue r;
	bool improves;

	assert (*checksums_p != NULL);

	r = files_get_checksums(filekey, &checksums);
	if (RET_WAS_ERROR(r))
		return r;
	if (RET_IS_OK(r)) {
		/* there are three sources now:
		 *  - the checksums from the database (may have some we
		 *    do not even know about, and may miss some we can
		 *    generate)
		 *  - the checksums provided (typically only md5sum,
		 *    as this comes from a .changes or .dsc)
		 *  - the checksums of the file
		 *
		 *  to make things more complicated, the file should only
		 *  be read if needed, as this needs time.
		 *  And it can happen the file got lost in the pool, then
		 *  this is the best place to replace it.
		 */
		if (!checksums_check(checksums, *checksums_p, &improves)) {
			fprintf(stderr,
"ERROR: '%s/%s' cannot be included as '%s'.\n"
"Already existing files can only be included again, if they are the same, but:\n",
				sourcedir, basefilename, filekey);
			checksums_printdifferences(stderr, checksums,
					*checksums_p);
			checksums_free(checksums);
			return RET_ERROR_WRONG_MD5;
		}
		r = RET_NOTHING;
		if (improves)
			r = checksums_combine(&checksums, *checksums_p, NULL);
		if (!RET_WAS_ERROR(r))
			r = checkimproveorinclude(sourcedir,
				basefilename, filekey, &checksums, &improves);
		if (!RET_WAS_ERROR(r) && improves)
			r = files_replace_checksums(filekey, checksums);
		if (RET_IS_OK(r))
			r = RET_NOTHING;
		/* return the combined checksum */
		checksums_free(*checksums_p);
		*checksums_p = checksums;
		return r;
	}

	assert (sourcedir != NULL);
	sourcefilename = calc_dirconcat(sourcedir, basefilename);
	if (FAILEDTOALLOC(sourcefilename))
		return RET_ERROR_OOM;

	fullfilename = files_calcfullfilename(filekey);
	if (FAILEDTOALLOC(fullfilename)) {
		free(sourcefilename);
		return RET_ERROR_OOM;
	}

	(void)dirs_make_parent(fullfilename);
	r = checksums_copyfile(fullfilename, sourcefilename, true, &checksums);
	if (r == RET_NOTHING) {
		fprintf(stderr, "Could not open '%s'!\n", sourcefilename);
		r = RET_ERROR_MISSING;
	}
	if (RET_WAS_ERROR(r)) {
		free(fullfilename);
		free(sourcefilename);
		return r;
	}
	if (!checksums_check(*checksums_p, checksums, &improves)) {
		deletefile(fullfilename);
		fprintf(stderr, "ERROR: Unexpected content of file '%s'!\n",
				sourcefilename);
		checksums_printdifferences(stderr, *checksums_p, checksums);
		r = RET_ERROR_WRONG_MD5;
	}
	free(sourcefilename);
	free(fullfilename);
	if (RET_WAS_ERROR(r)) {
		return r;
	}
	if (improves) {
		r = checksums_combine(checksums_p, checksums, NULL);
		checksums_free(checksums);
		if (RET_WAS_ERROR(r))
			return r;
	} else
		checksums_free(checksums);

	return files_add_checksums(filekey, *checksums_p);
}
Beispiel #8
0
static retvalue checkimproveorinclude(const char *sourcedir, const char *basefilename, const char *filekey, struct checksums **checksums_p, bool *improving) {
	retvalue r;
	struct checksums *checksums = NULL;
	bool improves, copied = false;
	char *fullfilename = files_calcfullfilename(filekey);

	if (FAILEDTOALLOC(fullfilename))
		return RET_ERROR_OOM;

	if (checksums_iscomplete(*checksums_p)) {
		r = checksums_cheaptest(fullfilename, *checksums_p, true);
		if (r != RET_NOTHING) {
			free(fullfilename);
			return r;
		}
	} else {
		r = checksums_read(fullfilename, &checksums);
		if (RET_WAS_ERROR(r)) {
			free(fullfilename);
			return r;
		}
	}
	if (r == RET_NOTHING) {
		char *sourcefilename = calc_dirconcat(sourcedir, basefilename);

		if (FAILEDTOALLOC(sourcefilename)) {
			free(fullfilename);
			return RET_ERROR_OOM;
		}

		fprintf(stderr,
"WARNING: file %s was lost!\n"
"(i.e. found in the database, but not in the pool)\n"
"trying to compensate...\n",
				filekey);
		(void)dirs_make_parent(fullfilename);
		r = checksums_copyfile(fullfilename, sourcefilename, false,
				&checksums);
		if (r == RET_ERROR_EXIST) {
			fprintf(stderr,
"File '%s' seems to be missing and existing at the same time!\n"
"To confused to continue...\n",
					fullfilename);
		}
		if (r == RET_NOTHING) {
			fprintf(stderr, "Could not open '%s'!\n",
					sourcefilename);
			r = RET_ERROR_MISSING;
		}
		free(sourcefilename);
		if (RET_WAS_ERROR(r)) {
			free(fullfilename);
			return r;
		}
		copied = true;
	}

	assert (checksums != NULL);

	if (!checksums_check(*checksums_p, checksums, &improves)) {
		if (copied) {
			deletefile(fullfilename);
			fprintf(stderr,
"ERROR: Unexpected content of file '%s/%s'!\n", sourcedir, basefilename);
		} else
// TODO: if the database only listed some of the currently supported checksums,
// and the caller of checkincludefile supplied some (which none yet does), but
// not all (which needs at least three checksums, i.e. not applicaple before
// sha256 get added), then this might also be called if the file in the pool
// just has the same checksums as previously recorded (e.g. a md5sum collision)
// but the new file was listed with another secondary hash than the original.
// In that situation it might be a bit misleading...
			fprintf(stderr,
"ERROR: file %s is damaged!\n"
"(i.e. found in the database, but with different checksums in the pool)\n",
				filekey);
		checksums_printdifferences(stderr, *checksums_p, checksums);
		r = RET_ERROR_WRONG_MD5;
	}
	if (improves) {
		r = checksums_combine(checksums_p, checksums, NULL);
		if (RET_IS_OK(r))
			*improving = true;
	}
	checksums_free(checksums);
	free(fullfilename);
	return r;
}
Beispiel #9
0
int main(int argc, char *argv[])
#endif
{
    u8 sta = 0, cmd;
    int i;

#ifndef __AVR__
    if (argc > 3 || argc < 2) {
        printf("Usage: (sudo) testfat rawdevice  e.g. fat32 /dev/sdb \r\n");
        return 1;
    }
    //    fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
    if (initsec(argv[1]))
        return -1;
#endif

    hwinit();

    printf("\nFAT32 Test\n");
    i = sdhcinit();
    printf("init %d\n", i);
    if (!i) {
        printf( "%lu sects\n", sdnumsectors );
        i = mount(0);
        printf("Mount: %d\n", i);
        if (!i)
            seekfile(0, 0);
#if 1                           // show what is read
        else
            for (i = 0; i < 1; i++) {
                readsec(i);
                dumpsect();
            }
#endif
    }
    if (i)
        printf("Not Ready\n");

    for (;;) {
        cmd = tzgetchar();
        if (cmd >= 'a')
            cmd -= 32;
        switch (cmd) {
#ifdef __AVR__
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            //            while (!tzkbhit()) {
                ADMUX = 0xe0 + cmd - '0';
                ADCSRA = 0xc7;
                while (ADCSRA & 0x40);
                printf("%c %04x\n", cmd, ADC);
                //            }
            break;
#endif
        case 3:
        case 26:
        case 'Q':
            exit(0);
        case 'Y':
            {
                u16 u;
                u = getdirent((u8 *) "");
                printf("%u entries in dir\n", u);
            }
            break;
        case 'I':
            sta = sdhcinit();
            printf("init %d\n", sta);
            if (sta)
                continue;
            printf( "%lu sects\n", sdnumsectors );
            sta = cardinfo(0);
            printf("inf %d\n", sta);
            if (sta)
                continue;
            for (sta = 0; sta < 18; sta++)
                printf("%02X", filesectbuf[sta]);
            printf(" ");
            for (sta = 0; sta < 18; sta++)
                printf("%c", dochar(filesectbuf[sta]));
            printf("\n");
            sta = cardinfo(1);
            printf("inf %d\n", sta);
            if (sta)
                continue;
            for (sta = 0; sta < 18; sta++)
                printf("%02X", filesectbuf[sta]);
            printf(" ");
            for (sta = 0; sta < 18; sta++)
                printf("%c", dochar(filesectbuf[sta]));
            printf("\n");
            break;
        case 'M':
            i = mount(0);
            if (!i)
                printf("Mounted\n");
            else
                printf("Error\n");
            break;
        case 'O':
            printf("Open:\n");
            i = getfname();
            if (i < 0) {
                printf("bad fname\n");
                break;
            }
            i = getdirent(filename);
            if (i == 2)
                printf("Entered Dir\n");
            else if (!i)
                printf("Opened\n");
            else
                printf("Not Found\n");
            break;
        case 'C':
            printf("Create:\n");
            i = getfname();
            if (i < 0) {
                printf("bad fname\n");
                break;
            }
            if (i == 1) {
                printf("Directory:\n");
                i = getfname();
                if (i) {
                    printf("bad fname\n");
                    break;
                }
                i = 0x10;       // directory attribute
            }
            i = newdirent(filename, i);
            if (!i)
                printf("Created\n");
            else if (i == 2)
                printf("Exists\n");
            else
                printf("Error\n");
            break;
        case 'N':
            i = newdirent(NULL, 0);
            if (!i)
                printf("Created Ser Log\n");
            else
                printf("Error\n");
            break;
        case 'L':
            resettodir();
            seekfile(0, 0);
            for (i = 0; i < 16; i++) {
                if (!filesectbuf[i << 5])
                    break;
                if (0xe5 == filesectbuf[i << 5]) {
                    printf("(del)\n");
                    continue;
                }
                if (0xf == filesectbuf[(i << 5) + 11]) {
                    printf("(lfn)\n");
                    continue;
                }
                printf("%8.8s.%3.3s %c\n", &filesectbuf[i << 5], &filesectbuf[(i << 5) + 8],
                  filesectbuf[(i << 5) + 11] & 0x10 ? '/' : ' ');
                if (i == 15) {
                    i = readnextsect();
                    if (i != 512)
                        break;
                    i = -1;
                }
            }
            break;
        case 'W':
            printf("Write: ^c|^z to exit\n");
            for (;;) {
                char cx;
                cx = tzgetchar();
                if (cx == 3 || cx == 26)
                    break;
                writebyte(cx);
                printf("%c", cx);
            }
            printf("\nWritten ");
            flushbuf();
            printf("Flushed ");
            syncdirent(0);
            printf("DSynced\n");
            break;
        case 'F':
            flushbuf();
            printf("Flushed\n");
            break;
        case 'E':
            syncdirent(0);
            printf("dirsynced\n");
            break;
        case 'P':
            syncdirent(1);
            printf("size pushed\n");
            break;
        case 'Z':
            zaphint();
            printf("hint zapped\n");
            break;
        case 'T':
            truncatefile();
            printf("Trunc-ed\n");
            break;
        case 'D':
            i = deletefile();
            if (i == 1)
                printf("no rmdir\n");
            else if (!i)
                printf("Deleted\n");
            else
                printf("Error\n");
            break;
            // will go away when seek is filled in
        case 'A':
            seekfile(0, 2);
            printf("At EOF\n");
            break;
        case 'S':
            {
                u32 x = 0;
                u8 y = 1;
                seekfile(x, y);
                printf("Rewound\n");
            }
            break;
        case 'R':
        case 'V':
        case 'X':
            sta = 0;
            while (!tzkbhit()) {
                i = readbyte();
                if (i < 0) {
                    printf("\n=EOF=\n");
                    break;
                }
                switch (cmd) {
                case 'R':
                    printf("%c", i);
                    break;
                case 'V':
                    printf("%c", dochar(i));
                    break;
                case 'X':
                    if (!(sta++ & 15))
                        printf("\n");
                    printf("%02X", i);
                    break;
                }
            }
            break;
        case 'U':
            resetrootdir();
            seekfile(0, 0);     // for list
            printf("At rootdir\n");
            break;
        case 'G':
            resettodir();
            seekfile(0, 0);     // for list
            printf("At curdir\n");
            break;

        default:
            // help message
            {
                char *c = mainmenu;
                while (pgm_read_byte(c))
                    putchar(pgm_read_byte(c++));
            }
            break;
        }
    }
}
Beispiel #10
0
int main(int argc, char *argv[])
{
	char *hostname = "localhost"; //host to use if none supplied
	char *service = "ftp", filename[50] = "";    //defaulto service port
	char user[50] = "", pass[50] = "", path[50] = "";
	int cmd, connectfd;
	/*User has to give hostname as a cmd line argument */

	if(argc==2)
		hostname = argv[1];
	else
	{
		fprintf(stderr, "usage: ./4_HW2_Q1_client.exe [hostname]\n");
		exit(1);
	}

	//strcpy(service, "4000");

	connectfd = connectTCP(hostname, service);

	printf("Authenticating...\n");
	printf("Enter user name: ");
	scanf("%s", user);
	printf("Enter password: "******"%s", pass);

	auth_user (connectfd, user, pass);

	//	printf("Enter file name: ");
	//	scanf("%s", filename);

	while(1)
	{
		printf("Commands supported.\n100:RETR\n200:STOR\n300:MKDIR\n400:END\n600:DELETEFILE\nEnter command: ");
		//bzero(&cmd, sizeof(cmd));
		scanf("%d", &cmd);
		// fgets(,sizeof Buff,stdin);

		switch(cmd)
		{
			case STOREFILE: 
				printf("Enter file name: ");
				scanf("%s", filename);
				storefile(connectfd,filename);
				break;
			case REQUESTFILE:
				printf("Enter file name: ");
				scanf("%s", filename);
				readfile(connectfd,filename); 	
				break;
			case MKDIR:
				printf("Enter Dir name: ");
				scanf("%s", path);
				makedir(connectfd, path);
				break;
			case DELETEFILE:
				printf("Enter file name: ");
                        	scanf("%s", filename);
		//		printf("Enter path name: ");
          //              	scanf("%s", path);

			deletefile(connectfd,filename,path);
			break;
			case LIST:
				//printf("Enter path name: ");
				//scanf("%s", path);
				//listdir(connectfd, path);
				break;
			case END:
				cmd = htons(END);
				if((writen(connectfd,(char *)&cmd,sizeof(cmd))) < 0)
				{
					printf("client: write error: %s\n", strerror(errno)); 
					exit(0);
				} 
				printf("client: shutting down...\n");
				exit(0);
			default:
				//bzero(&cmd, sizeof(cmd));
				printf("Command not implemented!\n");	
		}
		printf("\n\n");
	}
	exit(0);
}
Beispiel #11
0
void do_select(int msock)
{
	int max_fd, msg_ok, ret = 0, req, max_index, i, client_fd, c_len, total_ready;
	fd_set rset, wholeset;
	int client[FD_SETSIZE], n, sock_fd;
	char buffer[MAXLINE];
	struct sockaddr_in client_addr;

	max_fd = msock;
	max_index = -1;

	for(i=0; i<FD_SETSIZE; i++)
		client[i] = -1;

	FD_ZERO(&wholeset);
	FD_SET(msock, &wholeset);

	while (1)
	{
		memcpy(&rset, &wholeset, sizeof(rset));
		total_ready = select(max_fd + 1, &rset, NULL, NULL, NULL);

		if (FD_ISSET(msock, &rset))
		{
			printf("Waiting for client connection\n");
			//accept an incoming connection
			c_len = sizeof(struct sockaddr_in);
			client_fd = accept(msock, (struct sockaddr *)&client_addr, 
					(socklen_t *)&c_len);
			if(client_fd == -1)
			{
				perror("ERROR: accept()\n");
				exit(1);
			}

			ret = auth_user(client_fd);
			if (ret == -1)
				close(client_fd);
			else
			{
				for(i=0; i<FD_SETSIZE; i++)
				{
					if (client[i] < 0)
					{
						client[i] = client_fd;
						break;
					}
				}

				if (i==FD_SETSIZE)
				{
					perror("Too many clients\n");
					exit(1);
				}
				FD_SET(client_fd, &wholeset);

				if (client_fd > max_fd)
					max_fd = client_fd;

				if(i > max_index)
					max_index = i;

				if (--total_ready <= 0)
					continue;
			}
		}

		for(i=0; i<=max_index; i++)
		{
			if ((sock_fd = client[i]) < 0)
				continue;

			if(FD_ISSET(sock_fd, &rset))
			{
				//doftp((void *)(long)sock_fd);
				n = readn(sock_fd,(char *)&req,sizeof(req));

				if(n <= 0)
				{
					close(sock_fd);
					FD_CLR(sock_fd, &wholeset);
					client[i] = -1;

					if (n < 0)
						printf("server: read error %d\n",errno);
					//status=endexecution(option);
				}
				else
				{
					req = ntohs(req);
					switch(req)
					{
					case STOREFILE:
						status=sendfile(sock_fd);
						break;
					case REQUESTFILE:
						status=recvfile(sock_fd);
						break;
					case MKDIR:
						status=makedir(sock_fd);
						break;
					case LIST:
						status=listdir(sock_fd);
						break;
					case DELETEFILE:
						status=deletefile(sock_fd);
						break;
					case END:
						printf("Client sent request to end connection.\n");
						close(sock_fd);
						FD_CLR(sock_fd, &wholeset);
						client[i] = -1;
						break;
					default:
						break;
					}
				}
				if(--total_ready <= 0)
					break;
			}
		}
	}
}
Beispiel #12
0
void CRecogStep::TestRecognizeDataL()
	{
	TDataRecognitionResult recogResult;
	
	TPtrC tmp;
	GetStringFromConfig(ConfigSection(), _L("fileName"), tmp);
	iFileName = tmp;
	

	TPtrC expectedDataType16;
	GetStringFromConfig(ConfigSection(), _L("expectedDataType"), expectedDataType16);
	HBufC8 *expectedDataBuf8 = ConvertDes16toHBufC8LC(expectedDataType16);

	TInt expectedConfidence;
	GetIntFromConfig(ConfigSection(), _L("expectedConfidence"), expectedConfidence);
	
	TInt maxDataBufSize;
	if (GetIntFromConfig(ConfigSection(), _L("maxDataBufSize"), maxDataBufSize))
		{
		iLs.SetMaxDataBufSize(maxDataBufSize);
		}
		
	TPtrC method;
	GetStringFromConfig(ConfigSection(), _L("method"), method);
		
	TBool checkSpecific = EFalse;
	TBool matchedSpecificMimeType = EFalse;
	TPtrC specificMimeType;
	if (method == KMethodHandle)
		{		
		checkSpecific = GetStringFromConfig(ConfigSection(), _L("checkSpecificMimeType"), specificMimeType);
		}

	TInt usePrivateFile = 0;
	GetIntFromConfig(ConfigSection(), _L("usePrivateFile"), usePrivateFile);
	
	RDeletefile deletefile(iTheFs, iFileName);
	if(!usePrivateFile)
		{
		// Tweak file modification time to defeat the apparch recognizer result cache....
		TTime time;
		User::LeaveIfError(iTheFs.Modified(iFileName, time));
		time += TTimeIntervalSeconds(1);
		User::LeaveIfError(iTheFs.SetModified(iFileName, time));
		}
	else
		{
		// Copy file to private dir, this will make it inaccesible to the recognizer code (except via handle).
		ConvertFileToPrivateL();	
		CleanupClosePushL(deletefile);
		}
	
	
	if (method == KMethodName)
		{
		INFO_PRINTF2(_L("Test Recognizing %S by File Name"), &iFileName);
	    User::LeaveIfError(iLs.RecognizeData(iFileName, KEmptyBuffer8, recogResult));
		}
	else if((method == KMethodHandle) || (method == KMethodBuffer))
		{
		RFile fileToRead;	
		User::LeaveIfError(fileToRead.Open(iTheFs, iFileName, EFileShareReadersOrWriters | EFileRead | EFileStream));
		CleanupClosePushL(fileToRead);
		if(method == KMethodHandle)
			{
			if (checkSpecific)
				{
				HBufC8* specificMimeType8 = ConvertDes16toHBufC8LC(specificMimeType);
				TDataType mime(*specificMimeType8);																					
				INFO_PRINTF2(_L("Test matching specific mime-type %S by Handle"), &iFileName);		
				User::LeaveIfError(iLs.RecognizeSpecificData(fileToRead, mime, matchedSpecificMimeType));
				CleanupStack::PopAndDestroy(specificMimeType8);
				}
			else 
				{
				INFO_PRINTF2(_L("Test Recognizing %S by Handle"), &iFileName);		
			    User::LeaveIfError(iLs.RecognizeData(fileToRead, recogResult));				
				}
			}
		else
			{
			INFO_PRINTF2(_L("Test Recognizing %S by Buffer"), &iFileName);		
			TInt size;
			User::LeaveIfError(fileToRead.Size(size));

			TInt maxBufferSize;
			if(GetIntFromConfig(ConfigSection(), _L("maxBufferSize"), maxBufferSize))
				{
				if(size > maxBufferSize)
					{
					size = maxBufferSize;
					}
				}

			HBufC8* memForFile = HBufC8::NewLC(size);
			TPtr8 fileContent(memForFile->Des());		
			User::LeaveIfError(fileToRead.Read(fileContent, size));
			User::LeaveIfError(iLs.RecognizeData(iFileName, fileContent, recogResult));
			CleanupStack::PopAndDestroy(); //memForFile,
			}
		CleanupStack::PopAndDestroy(&fileToRead);
		}
	else
		{
		ERR_PRINTF1(_L("method not set correctly"));		
		User::Leave(KErrArgument);
		}
	
	
	if (checkSpecific)
		{
		if (matchedSpecificMimeType)
			{
			INFO_PRINTF2(_L("Specific type '%S' matched\n"), &specificMimeType);
			SetTestStepResult(EPass);			
			}
		else 
			{
			INFO_PRINTF2(_L("Specific type '%S' not matched\n"), &specificMimeType);
			SetTestStepResult(EFail);			
			}
		}
    else 
    	{
    	TPtrC result16 = recogResult.iDataType.Des();
    	if (// Expected failure
		((expectedConfidence == CApaDataRecognizerType::ENotRecognized) && 
		 (recogResult.iDataType != expectedDataBuf8->Des())) ||
		// Expected success
		((recogResult.iConfidence == expectedConfidence) && 
		 (recogResult.iDataType == expectedDataBuf8->Des())))
		    {
			INFO_PRINTF3(_L("PASSED - type '%S' confidence=%d\n"), 
						 &result16,
						 recogResult.iConfidence);		
		    SetTestStepResult(EPass);	
		    }
		else
			{
			ERR_PRINTF5(_L("FAILED - expected '%S', got type '%S' - expected confidence=%d got confidence %d\n"), 
						&expectedDataType16,
						&result16,
						expectedConfidence,
						recogResult.iConfidence);		
			SetTestStepResult(EFail);		
			}
    	}
	
	if(usePrivateFile)
		{
		CleanupStack::PopAndDestroy(&deletefile);
		}
	
	CleanupStack::PopAndDestroy(expectedDataBuf8);
	INFO_PRINTF1(KCompleted);
   	}
Beispiel #13
0
function main() {
	printl("testnaturalsort says 'Hello World!'");

	var tempfilename="tempsortfile";
	tempfilename.outputl("tempfilename=");

	var dicttempfilename="dict_"^tempfilename;
	dicttempfilename.outputl("dicttempfilename=");

	deletefile(tempfilename);
	deletefile(dicttempfilename);

	//let everything be one transaction
	//with automatic rollback at close of program ^_^
	//and anyway is REQUIRED for the select() command
	begintrans();

	if (not createfile(tempfilename))
		abort("cant create "^tempfilename);
	if (not createfile(dicttempfilename))
		abort("cant create "^dicttempfilename);
	clearfile(tempfilename);
	clearfile(dicttempfilename);

	var tempfile;
	if (not open(tempfilename,tempfile))
		abort("cannot open "^tempfilename);

	if (not write(
	"F" _FM_
	"0" _FM_
	"ID" _FM_
	_FM_
	_FM_
	_FM_
	_FM_
	_FM_
	"R" _FM_
	"20", dicttempfilename, "ID"))
		abort("cannot write "^dicttempfilename^" ID");

	//var ndigits=9;
	//var nzeros=25;
	var ndigits=3;
	var nzeros=3;

	//create records backwards to test sort
	var ii,jj;
	for (ii=ndigits;ii>=0;--ii)
		for (jj=nzeros;jj>=0;--jj) {
			var key="x"^ii^str("0",jj);
			write("junk",tempfile,key.outputl("key="));
		}
	//read sorted records forwards to check numbers
	if (not tempfile.select("by ID")) {
		tempfile.getlasterror().logputl("lasterror=");
		abort("problem sorting file");
	}
	var key;
	//while (tempfile.readnext(key)) {
	while (tempfile.readnext(key)) {
		printl(key);
	}
	//rely on automatic rollback to rollback all work done
	//deletefile(tempfilename);
	committrans();

	return 0;
}
Beispiel #14
0
static int parse_options(int argc, char *argv[])
{
	int c;
	int opt_index = -1;
	gn_error rc;

	/* Every option should be in this array. */
	static struct option long_options[] = {
		/* FIXME: these comments are nice, but they would be more useful as docs for the user */
		/* Display usage. */
		{ "help",               optional_argument, NULL, OPT_HELP },

		/* Display version and build information. */
		{ "version",            no_argument,       NULL, OPT_VERSION },

		/* Monitor mode */
		{ "monitor",            optional_argument, NULL, OPT_MONITOR },

		/* Alternate config file location */
		{ "config",             required_argument, NULL, OPT_CONFIGFILE },

		/* Alternate phone section from the config */
		{ "phone",              required_argument, NULL, OPT_CONFIGMODEL },

		/* Get Security Code */
		{ "getsecuritycode",    no_argument,   	   NULL, OPT_GETSECURITYCODE },

		/* Enter Security Code mode */
		{ "entersecuritycode",  required_argument, NULL, OPT_ENTERSECURITYCODE },

		/* Get Security Code status */
		{ "getsecuritycodestatus",  no_argument,   NULL, OPT_GETSECURITYCODESTATUS },

		/* Change Security Code */
		{ "changesecuritycode", required_argument, NULL, OPT_CHANGESECURITYCODE },

		/* Set date and time */
		{ "setdatetime",        optional_argument, NULL, OPT_SETDATETIME },

		/* Get date and time mode */
		{ "getdatetime",        no_argument,       NULL, OPT_GETDATETIME },

		/* Set alarm */
		{ "setalarm",           optional_argument, NULL, OPT_SETALARM },

		/* Get alarm */
		{ "getalarm",           no_argument,       NULL, OPT_GETALARM },

		/* Voice call mode */
		{ "dialvoice",          required_argument, NULL, OPT_DIALVOICE },

		/* Answer the incoming call */
		{ "answercall",         required_argument, NULL, OPT_ANSWERCALL },

		/* Hangup call */
		{ "hangup",             required_argument, NULL, OPT_HANGUP },

		/* Get ToDo note mode */
		{ "gettodo",		required_argument, NULL, OPT_GETTODO },

		/* Write ToDo note mode */
		{ "writetodo",          required_argument, NULL, OPT_WRITETODO },

		/* Delete all ToDo notes mode */
		{ "deletealltodos",     no_argument,       NULL, OPT_DELETEALLTODOS },

		/* Get calendar note mode */
		{ "getcalendarnote",    required_argument, NULL, OPT_GETCALENDARNOTE },

		/* Write calendar note mode */
		{ "writecalendarnote",  required_argument, NULL, OPT_WRITECALENDARNOTE },

		/* Delete calendar note mode */
		{ "deletecalendarnote", required_argument, NULL, OPT_DELCALENDARNOTE },

		/* Get display status mode */
		{ "getdisplaystatus",   no_argument,       NULL, OPT_GETDISPLAYSTATUS },

		/* Get memory mode */
		{ "getphonebook",       required_argument, NULL, OPT_GETPHONEBOOK },

		/* Write phonebook (memory) mode */
		{ "writephonebook",     optional_argument, NULL, OPT_WRITEPHONEBOOK },

		/* Delete phonebook entry from memory mode */
		{ "deletephonebook",    required_argument, NULL, OPT_DELETEPHONEBOOK },

		/* Get speed dial mode */
		{ "getspeeddial",       required_argument, NULL, OPT_GETSPEEDDIAL },

		/* Set speed dial mode */
		{ "setspeeddial",       required_argument, NULL, OPT_SETSPEEDDIAL },

		/* Create SMS folder mode */
		{ "createsmsfolder",    required_argument, NULL, OPT_CREATESMSFOLDER },

		/* Delete SMS folder mode */
		{ "deletesmsfolder",    required_argument, NULL, OPT_DELETESMSFOLDER },

		/* Show SMS folder names and its attributes */
		{ "showsmsfolderstatus",no_argument,       NULL, OPT_SHOWSMSFOLDERSTATUS },

		/* Get SMS message mode */
		{ "getsms",             required_argument, NULL, OPT_GETSMS },

		/* Delete SMS message mode */
		{ "deletesms",          required_argument, NULL, OPT_DELETESMS },

		/* Send SMS message mode */
		{ "sendsms",            required_argument, NULL, OPT_SENDSMS },

		/* Ssve SMS message mode */
		{ "savesms",            optional_argument, NULL, OPT_SAVESMS },

		/* Send logo as SMS message mode */
		{ "sendlogo",           required_argument, NULL, OPT_SENDLOGO },

		/* Send ringtone as SMS message */
		{ "sendringtone",       required_argument, NULL, OPT_SENDRINGTONE },

		/* Get ringtone */
		{ "getringtone",        required_argument, NULL, OPT_GETRINGTONE },

		/* Set ringtone */
		{ "setringtone",        required_argument, NULL, OPT_SETRINGTONE },

		/* Play ringtone */
		{ "playringtone",       required_argument, NULL, OPT_PLAYRINGTONE },

		/* Convert ringtone */
		{ "ringtoneconvert",    required_argument, NULL, OPT_RINGTONECONVERT },

		/* Get list of the ringtones */
		{ "getringtonelist",    no_argument,       NULL, OPT_GETRINGTONELIST },

		/* Delete ringtones */
		{ "deleteringtone",     required_argument, NULL, OPT_DELETERINGTONE },

		/* Get SMS center number mode */
		{ "getsmsc",            optional_argument, NULL, OPT_GETSMSC },

		/* Set SMS center number mode */
		{ "setsmsc",            no_argument,       NULL, OPT_SETSMSC },

		/* For development purposes: run in passive monitoring mode */
		{ "pmon",               no_argument,       NULL, OPT_PMON },

		/* NetMonitor mode */
		{ "netmonitor",         required_argument, NULL, OPT_NETMONITOR },

		/* Identify */
		{ "identify",           no_argument,       NULL, OPT_IDENTIFY },

		/* Send DTMF sequence */
		{ "senddtmf",           required_argument, NULL, OPT_SENDDTMF },

		/* Resets the phone */
		{ "reset",              required_argument, NULL, OPT_RESET },

		/* Set logo */
		{ "setlogo",            required_argument, NULL, OPT_SETLOGO },

		/* Get logo */
		{ "getlogo",            required_argument, NULL, OPT_GETLOGO },

		/* View logo */
		{ "viewlogo",           required_argument, NULL, OPT_VIEWLOGO },

		/* Show profile */
		{ "getprofile",         optional_argument, NULL, OPT_GETPROFILE },

		/* Set profile */
		{ "setprofile",         no_argument,       NULL, OPT_SETPROFILE },

		/* Get the active profile */
		{ "getactiveprofile",   no_argument,       NULL, OPT_GETACTIVEPROFILE },

		/* Set the active profile */
		{ "setactiveprofile",   required_argument, NULL, OPT_SETACTIVEPROFILE },

		/* Show texts from phone's display */
		{ "displayoutput",      no_argument,       NULL, OPT_DISPLAYOUTPUT },

		/* Simulate pressing the keys */
		{ "keysequence",        no_argument,       NULL, OPT_KEYPRESS },

		/* Simulate pressing the keys */
		{ "enterchar",          no_argument,       NULL, OPT_ENTERCHAR },

		/* Divert calls */
		{ "divert",		no_argument,       NULL, OPT_DIVERT },

		/* SMS reader */
		{ "smsreader",          no_argument,       NULL, OPT_SMSREADER },

		/* For development purposes: insert you function calls here */
		{ "foogle",             no_argument,       NULL, OPT_FOOGLE },

		/* Get WAP bookmark */
		{ "getwapbookmark",     required_argument, NULL, OPT_GETWAPBOOKMARK },

		/* Write WAP bookmark */
		{ "writewapbookmark",   required_argument, NULL, OPT_WRITEWAPBOOKMARK },

		/* Delete WAP bookmark */
		{ "deletewapbookmark",  required_argument, NULL, OPT_DELETEWAPBOOKMARK },

		/* Get WAP setting */
		{ "getwapsetting",      required_argument, NULL, OPT_GETWAPSETTING },

		/* Write WAP setting */
		{ "writewapsetting",    no_argument, 	   NULL, OPT_WRITEWAPSETTING },

		/* Activate WAP setting */
		{ "activatewapsetting", required_argument, NULL, OPT_ACTIVATEWAPSETTING },

		/* List GSM networks */
		{ "listnetworks",       no_argument,       NULL, OPT_LISTNETWORKS },

		/* Get network info */
		{ "getnetworkinfo",     no_argument,       NULL, OPT_GETNETWORKINFO },

		/* Get (sim)lock info */
		{ "getlocksinfo",       no_argument,       NULL, OPT_GETLOCKSINFO },

                /* Get file list */
		{ "getfilelist",        required_argument, NULL, OPT_GETFILELIST },

                /* Get file details by id */
		{ "getfiledetailsbyid", optional_argument, NULL, OPT_GETFILEDETAILSBYID },

                /* Get file id */
		{ "getfileid",          required_argument, NULL, OPT_GETFILEID },

                /* Get file */
		{ "getfile",            required_argument, NULL, OPT_GETFILE },

                /* Get file by id */
		{ "getfilebyid",        required_argument, NULL, OPT_GETFILEBYID },

		/* Get all files */
		{ "getallfiles",        required_argument, NULL, OPT_GETALLFILES },

                /* Put a file */
		{ "putfile",            required_argument, NULL, OPT_PUTFILE },

		/* Delete a file */
		{ "deletefile",         required_argument, NULL, OPT_DELETEFILE },

		/* Delete a file by id */
		{ "deletefilebyid",     required_argument, NULL, OPT_DELETEFILEBYID },

		/* Shell like interface */
		{ "shell",              no_argument, NULL, OPT_SHELL },

		/* Get MMS message mode */
		{ "getmms",             required_argument, NULL, OPT_GETMMS },

		/* Delete MMS message mode */
		{ "deletemms",          required_argument, NULL, OPT_DELETEMMS },

		/* Check if the phone responds */
		{ "ping",               no_argument, NULL, OPT_PING },

		{ 0, 0, 0, 0 },
	};

	/* Every command which requires arguments should have an appropriate entry
	   in this array. */
	static struct gnokii_arg_len gals[] = {
		{ OPT_HELP,              1, 100, 0 },
		{ OPT_CONFIGFILE,        1, 100, 0 },
		{ OPT_CONFIGMODEL,       1, 100, 0 },
		{ OPT_ENTERSECURITYCODE, 1, 100, 0 },
		{ OPT_CHANGESECURITYCODE,1, 1, 0 },
		{ OPT_SETDATETIME,       0, 5, 0 },
		{ OPT_SETALARM,          0, 2, 0 },
		{ OPT_DIALVOICE,         1, 1, 0 },
		{ OPT_ANSWERCALL,        1, 1, 0 },
		{ OPT_HANGUP,            1, 1, 0 },
		{ OPT_GETTODO,           1, 3, 0 },
		{ OPT_WRITETODO,         2, 3, 0 },
		{ OPT_GETCALENDARNOTE,   1, 3, 0 },
		{ OPT_WRITECALENDARNOTE, 2, 3, 0 },
		{ OPT_DELCALENDARNOTE,   1, 2, 0 },
		{ OPT_GETPHONEBOOK,      2, 4, 0 },
		{ OPT_WRITEPHONEBOOK,    0, 10, 0 },
		{ OPT_DELETEPHONEBOOK,   2, 3, 0 },
		{ OPT_GETSPEEDDIAL,      1, 1, 0 },
		{ OPT_SETSPEEDDIAL,      3, 3, 0 },
		{ OPT_CREATESMSFOLDER,   1, 1, 0 },
		{ OPT_DELETESMSFOLDER,   1, 1, 0 },
		{ OPT_GETSMS,            2, 6, 0 },
		{ OPT_DELETESMS,         2, 3, 0 },
		{ OPT_SENDSMS,           1, 10, 0 },
		{ OPT_SAVESMS,           0, 12, 0 },
		{ OPT_SENDLOGO,          3, 4, GAL_XOR },
		{ OPT_SENDRINGTONE,      2, 2, 0 },
		{ OPT_GETSMSC,           0, 3, 0 },
		{ OPT_GETWELCOMENOTE,    1, 1, 0 },
		{ OPT_SETWELCOMENOTE,    1, 1, 0 },
		{ OPT_NETMONITOR,        1, 1, 0 },
		{ OPT_SENDDTMF,          1, 1, 0 },
		{ OPT_SETLOGO,           1, 4, 0 },
		{ OPT_GETLOGO,           1, 4, 0 },
		{ OPT_VIEWLOGO,          1, 1, 0 },
		{ OPT_GETRINGTONE,       1, 3, 0 },
		{ OPT_SETRINGTONE,       1, 5, 0 },
		{ OPT_PLAYRINGTONE,      1, 3, 0 },
		{ OPT_RINGTONECONVERT,   2, 2, 0 },
		{ OPT_DELETERINGTONE,    1, 2, 0 },
		{ OPT_RESET,             0, 1, 0 },
		{ OPT_GETPROFILE,        0, 3, 0 },
		{ OPT_SETACTIVEPROFILE,  1, 1, 0 },
		{ OPT_DIVERT,            6, 10, 0 },
		{ OPT_GETWAPBOOKMARK,    1, 1, 0 },
		{ OPT_WRITEWAPBOOKMARK,  2, 2, 0 },
		{ OPT_DELETEWAPBOOKMARK, 1, 1, 0 },
		{ OPT_GETWAPSETTING,     1, 2, 0 },
		{ OPT_ACTIVATEWAPSETTING,1, 1, 0 },
		{ OPT_MONITOR,           0, 1, 0 },
		{ OPT_GETFILELIST,       1, 1, 0 },
		{ OPT_GETFILEDETAILSBYID,0, 1, 0 },
		{ OPT_GETFILEID,         1, 1, 0 },
		{ OPT_GETFILE,           1, 2, 0 },
		{ OPT_GETFILEBYID,       1, 2, 0 },
		{ OPT_GETALLFILES,       1, 1, 0 },
		{ OPT_PUTFILE,           2, 2, 0 },
		{ OPT_DELETEFILE,        1, 1, 0 },
		{ OPT_DELETEFILEBYID,    1, 1, 0 },
		{ OPT_SHELL,             0, 0, 0 },
		{ OPT_GETMMS,            2, 6, 0 },
		{ OPT_DELETEMMS,         2, 3, 0 },
		{ OPT_FOOGLE,            0, 0, 0 },
		{ OPT_PING,              0, 0, 0 },
		{ 0, 0, 0, 0 },
	};

	/* Handle command line arguments.
	 * -c equals to --config
	 * -p equals to --phone
	 */
	c = getopt_long(argc, argv, "c:p:", long_options, &opt_index);

	switch (c) {
	/* No argument given - we should display usage. */
	case -1:
		return usage(stderr, -1, NULL);
	/* First, error conditions */
	case '?':
	case ':':
		/* --shell command does not set argv[0] */
		if (argv[0])
			fprintf(stderr, _("Use '%s --help' for usage information.\n"), argv[0]);
		else
			fprintf(stderr, _("Use '--help' for usage information.\n"));
		return 1;
	/* Then, options with no arguments */
	case OPT_VERSION:
		version();
		return 0;
	/* That's a bit ugly... */
	case 'c':
		c = OPT_CONFIGFILE;
		opt_index = 0;
		break;
	case 'p':
		c = OPT_CONFIGMODEL;
		opt_index = 1;
		break;
	}

	/* We have to build an array of the arguments which will be passed to the
	   functions.  Please note that every text after the --command will be
	   passed as arguments.  A syntax like gnokii --cmd1 args --cmd2 args will
	   not work as expected; instead args --cmd2 args is passed as a
	   parameter. */
	if (checkargs(c, gals, argc, long_options[opt_index].has_arg)) {
		return usage(stderr, -1, NULL);
	}

	/* Other options that do not need initialization */
	switch (c) {
	case OPT_CONFIGFILE:
		if (configfile)
			return usage(stderr, -1, NULL);
		configfile = optarg;
		return parse_options(argc, argv);
	case OPT_CONFIGMODEL:
		if (configmodel)
			return usage(stderr, -1, NULL);
		configmodel = optarg;
		return parse_options(argc, argv);
	case OPT_HELP:
		return usage(stdout, argc, argv);
	case OPT_VIEWLOGO:
		return viewlogo(optarg);
	case OPT_LISTNETWORKS:
		list_gsm_networks();
		return GN_ERR_NONE;
	case OPT_RINGTONECONVERT:
		return ringtoneconvert(argc, argv);
	}

	/* Initialise the code for the GSM interface. */
	if (c != OPT_FOOGLE && state == NULL && businit())
		return -1;

	switch (c) {
	/* Monitoring options */
	case OPT_MONITOR:
		rc = monitormode(argc, argv, data, state);
		break;
	case OPT_GETDISPLAYSTATUS:
		rc = getdisplaystatus(data, state);
		break;
	case OPT_DISPLAYOUTPUT:
		rc = displayoutput(data, state);
		break;
	case OPT_NETMONITOR:
		rc = netmonitor(optarg, data, state);
		break;

	/* SMS options */
	case OPT_SENDSMS:
		rc = sendsms(argc, argv, data, state);
		break;
	case OPT_SAVESMS:
		rc = savesms(argc, argv, data, state);
		break;
	case OPT_GETSMS:
		rc = getsms(argc, argv, data, state);
		break;
	case OPT_DELETESMS:
		rc = deletesms(argc, argv, data, state);
		break;
	case OPT_GETSMSC:
		rc = getsmsc(argc, argv, data, state);
		break;
	case OPT_SETSMSC:
		rc = setsmsc(data, state);
		break;
	case OPT_CREATESMSFOLDER:
		rc = createsmsfolder(optarg, data, state);
		break;
	case OPT_DELETESMSFOLDER:
		rc = deletesmsfolder(optarg, data, state);
		break;
	case OPT_SHOWSMSFOLDERSTATUS:
		rc = showsmsfolderstatus(data, state);
		break;
	case OPT_SMSREADER:
		rc = smsreader(data, state);
		break;

	/* Phonebook options */
	case OPT_GETPHONEBOOK:
		rc = getphonebook(argc, argv, data, state);
		break;
	case OPT_WRITEPHONEBOOK:
		rc = writephonebook(argc, argv, data, state);
		break;
	case OPT_DELETEPHONEBOOK:
		rc = deletephonebook(argc, argv, data, state);
		break;

	/* Calendar options */
	case OPT_GETCALENDARNOTE:
		rc = getcalendarnote(argc, argv, data, state);
		break;
	case OPT_WRITECALENDARNOTE:
		rc = writecalendarnote(argc, argv, data, state);
		break;
	case OPT_DELCALENDARNOTE:
		rc = deletecalendarnote(argc, argv, data, state);
		break;

	/* ToDo options */
	case OPT_GETTODO:
		rc = gettodo(argc, argv, data, state);
		break;
	case OPT_WRITETODO:
		rc = writetodo(argc, argv, data, state);
		break;
	case OPT_DELETEALLTODOS:
		rc = deletealltodos(data, state);
		break;

	/* Dialling and call handling options */
	case OPT_GETSPEEDDIAL:
		rc = getspeeddial(optarg, data, state);
		break;
	case OPT_SETSPEEDDIAL:
		rc = setspeeddial(argv, data, state);
		break;
	case OPT_DIALVOICE:
		rc = dialvoice(optarg, data, state);
		break;
	case OPT_SENDDTMF:
		rc = senddtmf(optarg, data, state);
		break;
	case OPT_ANSWERCALL:
		rc = answercall(optarg, data, state);
		break;
	case OPT_HANGUP:
		rc = hangup(optarg, data, state);
		break;
	case OPT_DIVERT:
		rc = divert(argc, argv, data, state);
		break;

	/* Profile options */
	case OPT_GETPROFILE:
		rc = getprofile(argc, argv, data, state);
		break;
	case OPT_SETPROFILE:
		rc = setprofile(data, state);
		break;
	case OPT_GETACTIVEPROFILE:
		rc = getactiveprofile(data, state);
		break;
	case OPT_SETACTIVEPROFILE:
		rc = setactiveprofile(argc, argv, data, state);
		break;

	/* Phone settings options */
	case OPT_RESET:
		rc = reset(optarg, data, state);
		break;
	case OPT_GETDATETIME:
		rc = getdatetime(data, state);
		break;
	case OPT_SETDATETIME:
		rc = setdatetime(argc, argv, data, state);
		break;
	case OPT_GETALARM:
		rc = getalarm(data, state);
		break;
	case OPT_SETALARM:
		rc = setalarm(argc, argv, data, state);
		break;

	/* WAP options */
	case OPT_GETWAPBOOKMARK:
		rc = getwapbookmark(optarg, data, state);
		break;
	case OPT_WRITEWAPBOOKMARK:
		rc = writewapbookmark(argc, argv, data, state);
		break;
	case OPT_DELETEWAPBOOKMARK:
		rc = deletewapbookmark(optarg, data, state);
		break;
	case OPT_GETWAPSETTING:
		rc = getwapsetting(argc, argv, data, state);
		break;
	case OPT_WRITEWAPSETTING:
		rc = writewapsetting(data, state);
		break;
	case OPT_ACTIVATEWAPSETTING:
		rc = activatewapsetting(optarg, data, state);
		break;

	/* Logo options */
	case OPT_SENDLOGO:
		rc = sendlogo(argc, argv, data, state);
		break;
	case OPT_SETLOGO:
		rc = setlogo(argc, argv, data, state);
		break;
	case OPT_GETLOGO:
		rc = getlogo(argc, argv, data, state);
		break;

	/* Ringtone options */
	case OPT_SENDRINGTONE:
		rc = sendringtone(argc, argv, data, state);
		break;
	case OPT_GETRINGTONE:
		rc = getringtone(argc, argv, data, state);
		break;
	case OPT_SETRINGTONE:
		rc = setringtone(argc, argv, data, state);
		break;
	case OPT_PLAYRINGTONE:
		rc = playringtone(argc, argv, data, state);
		break;
	case OPT_GETRINGTONELIST:
		rc = getringtonelist(data, state);
		break;
	case OPT_DELETERINGTONE:
		rc = deleteringtone(argc, argv, data, state);
		break;

	/* Security options */
	case OPT_IDENTIFY:
		rc = identify(state);
		break;
	case OPT_GETLOCKSINFO:
		rc = getlocksinfo(data, state);
		break;
	case OPT_GETSECURITYCODE:
		rc = getsecuritycode(data, state);
		break;
	case OPT_ENTERSECURITYCODE:
		rc = entersecuritycode(optarg, data, state);
		if (rc == GN_ERR_NONE && optind < argc)
			return parse_options(argc, argv);
		break;
	case OPT_GETSECURITYCODESTATUS:
		rc = getsecuritycodestatus(data, state);
		break;
	case OPT_CHANGESECURITYCODE:
		rc = changesecuritycode(optarg, data, state);
			break;

	/* File options */
	case OPT_GETFILELIST:
		rc = getfilelist(optarg, data, state);
		break;
	case OPT_GETFILEDETAILSBYID:
		rc = getfiledetailsbyid(argc, argv, data, state);
		break;
	case OPT_GETFILEID:
		rc = getfileid(optarg, data, state);
		break;
	case OPT_GETFILE:
		rc = getfile(argc, argv, data, state);
		break;
	case OPT_GETFILEBYID:
		rc = getfilebyid(argc, argv, data, state);
		break;
	case OPT_GETALLFILES:
		rc = getallfiles(optarg, data, state);
		break;
	case OPT_PUTFILE:
		rc = putfile(argc, argv, data, state);
		break;
	case OPT_DELETEFILE:
		rc = deletefile(optarg, data, state);
		break;
	case OPT_DELETEFILEBYID:
		rc = deletefilebyid(optarg, data, state);
		break;

	/* Misc options */
	case OPT_PMON:
		rc = pmon(data, state);
		break;
	case OPT_KEYPRESS:
		rc = presskeysequence(data, state);
		break;
	case OPT_ENTERCHAR:
		rc = enterchar(data, state);
		break;
	case OPT_GETNETWORKINFO:
		rc = getnetworkinfo(data, state);
		break;
	case OPT_SHELL:
		rc = shell(data, state);
		break;
	case OPT_PING:
		rc = ping(data, state);
		break;
#ifndef WIN32
	case OPT_FOOGLE:
		rc = foogle(argc, argv);
		break;
#endif
	/* MMS options */
	case OPT_GETMMS:
		rc = getmms(argc, argv, data, state);
		break;
	case OPT_DELETEMMS:
		rc = deletemms(argc, argv, data, state);
		break;
	default:
		rc = GN_ERR_FAILED;
		fprintf(stderr, _("Unknown option: %d\n"), c);
		break;
	}
	return rc;
}
void PatchFilesResourceSource::RemoveEntry(const ResourceMapEntryAgnostic &mapEntry)
{
    std::string filename = GetFileNameFor(mapEntry.Type, mapEntry.Number, mapEntry.Base36Number, _version);
    std::string fullPath = _gameFolder + "\\" + filename;
    deletefile(fullPath);
}
Beispiel #16
0
bool CArcossCache::CheckEx( int id )
{
	share::Guard guard( _mutex ) ;
	if ( _mapArcoss.empty() )
		return false;

	CMapArcoss::iterator it = _mapArcoss.find( id ) ;
	if ( it == _mapArcoss.end() )
		return false;

	ArcossHeader *header = it->second ;
	if ( header->_size == 0 ) {
		_mapArcoss.erase( it ) ;
		delete header ;
		deletefile( id ) ;
		return false ;
	}

	int count = 0 ;

	char szid[128] = {0} ;
	sprintf( szid, "%u", id ) ;

	ArcossData *p = header->_head ;
	while( p != NULL ) {
		if ( p->state != VECHILE_OFF ) {
			p = p->_next ;
			continue ;
		}
		ArcossData *temp = p ;
		p = p->_next ;

		// 向外发送数据处理结果,这里回调外界不会引起死锁
		if ( _handler->HandleQueue( szid , temp, sizeof(ArcossData) , DATA_ARCOSSDAT ) == IOHANDLE_FAILED ){
			// 如果发送数据失败就直接返回了
			break ;
		}

		// 移除数据
		RemoveIndex( id, temp->color, temp->vechile ) ;

		// 只有一个元素
		if ( temp == header->_head && temp == header->_tail ){
			_mapArcoss.erase( it ) ;
			deletefile( id ) ;
			delete header ;
			delete temp ;
			break ;
		}

		// 有多个元素的情况
		if ( temp == header->_head ){ // 位于头部数据
			header->_head = temp->_next ;
			if ( temp->_next != NULL ) {
				temp->_next->_pre = NULL ;
			}
		} else if ( temp == header->_tail ){ // 位于尾部的情况
			header->_tail = temp->_pre ;
			if ( temp->_pre != NULL ) {
				temp->_pre->_next = NULL ;
			}
		} else { // 位于中间的情况
			temp->_pre->_next = temp->_next ;
			temp->_next->_pre = temp->_pre ;
		}
		header->_size = header->_size - 1 ;
		delete temp ;

		++ count ;
	}
	return ( count > 0 ) ;
}
Beispiel #17
0
/*delete a file*/
void dodelete(char* line)
{
	char* name=getargument(line);
	/*make the system call*/
	deletefile(name);
}