Hello,  

On Fri, 15 Nov 2002 23:31:11 +0200
"Nickolay Todorov" <[EMAIL PROTECTED]> 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
============================================================================
  • lu... Emil Slavov
    • ... Damyan Ivanov
      • ... Emil Slavov
        • ... Васил Колев
        • ... Nickolay Todorov
        • ... Nickolay Todorov
          • ... Alexander Atanasov
        • ... Damyan Ivanov
    • ... Pavel Mihaylov
    • ... raptor

Reply via email to