Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: Re[2]: lug-bg: .dat s cyrilic(DOS) kam drug data format s cyrilic-1251


  • Subject: Re: Re[2]: lug-bg: .dat s cyrilic(DOS) kam drug data format s cyrilic-1251
  • From: alex@xxxxxx (Alexander Atanasov)
  • Date: Sat, 16 Nov 2002 16:14:50 +0200



        Hello,	

On Fri, 15 Nov 2002 23:31:11 +0200
"Nickolay Todorov" <nickolay@xxxxxxxxxxxxxxxx> wrote:

> Oshte neshto, spored men nachaloto na dannite e 0x1B. Nadiavam se da
> pomogne. :-)

        zapisite sa po 92 bytes
i vytre sa mai (paskalski strings?)
1 bytes dyljina i sledva stringa no niama 0 na kraia

t.e. purvoto e name i e dylgo 27(0x1b) bytes
sledvashtia pochva s 03 koeto shte reche 3 bytes dyljina i t.n.

No spored tova dolu ima oshte neshto koeto e X -  zapisite izliza che sa s razlichen broi poleta?


--
have fun,
alex

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int printpstr(char *ptr)
{	
	char buf[100];
	strncpy(buf,ptr+1,*ptr);
	buf[*ptr] = '\0';
	printf("%s",buf);
	return ((int)*ptr)+1;
}

int main(int argc, char **argv)
{
	int fd,rc;
	char buf[92];
	int flds=0;

	if (argc < 2) {
		fprintf(stderr,"%s datfile\n",argv[0]);
		exit (EXIT_FAILURE);
	}
	fd = open(argv[1],O_RDONLY);
	if (fd < 0) {
		fprintf(stderr,"failed to open:%s %d(%s)\n",argv[1],
				errno,strerror(errno));
		exit (EXIT_FAILURE);
	}

	while (sizeof(buf) == read(fd,buf,sizeof(buf))) {
		rc = 0;
		flds =0;
		printf("(");
		while(rc < sizeof(buf)) {
			if (*(buf+rc)) {
				printf("\'");
				rc+=printpstr(buf+rc);
				printf("\'");
			} else {
				rc++;
				printf("\'\'");
			}
			if (rc < sizeof(buf))
				printf(",");
			flds++;
		}
		printf(")\n");
		fprintf(stderr,"(fields:%d)\n",flds);
	}

	close(fd);

	exit (EXIT_SUCCESS);
}
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================




 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.