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

 

начало

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

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

семинари ...

документи

как да ...

 

 

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

Re: lug-bg: grep ? cat? tail?


  • Subject: Re: lug-bg: grep ? cat? tail?
  • From: edac@xxxxxxxxxxx (Ilia Trendafilov)
  • Date: Fri, 17 May 2002 16:02:37 +0300



> Ako nqkoi sega natrqska edin parser na C kolekciqta funkcionalni resheniq
> shte e pylna :)

/*
WARNING!!! Highly insecure&&exploitable code
*/

#include <stdio.h>
#include <errno.h>

int main(int argc,char *argv[])
{
  FILE *f;
  int s,e,c=0;
  char l[100000];
  
  if (argc!=4)
  {
    printf("Usage: %s <filename> <start> <end>\n",argv[0]);
    return 1;
  }
  
  if ((f=fopen(argv[1],"r"))==NULL) {perror("fopen()");return 1;}

  sscanf(argv[2],"%d",&s);
  sscanf(argv[3],"%d",&e);

  while (fgets(l,100000,f))
  {
    c++;
    if ((s<=c)&&(c<=e)) fputs(l,stdout);
    if (c>e) break;
  }

  fclose(f);
  return 0;
}

Tva go napisah za 5 minuti just for fun, znam che sigurno e bugavo :)
Ama poneje kolegata otpravi predizvikatelstvo :)
Moga i na C++ s iostreams da go napisha, ama aide tova niakoi drug :)
============================================================================
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.