Convert a C pgm

Benoit BESSE benoit.besse at club-internet.fr
Tue Mar 11 17:36:24 EST 2003


You're right, this is just a par of Application that list multicast
directory session.
The module have to parsed Session Description Protocol (RFC 2327).
This is the main ()

Thanks ans escuse for my French english.

#include "x-websd.h"

int main( int argc, char *argv[]) {
  FILE *f;
  int i=0, lineNo=0;
  char buf[1024], *line;

  if (argc != 3) {
    printf("Content-Type: text/plain\n\n");
    printf("usage: %s sessionId mediaNb\n", argv[0]);
    exit(0);
  }

  chdir(BASE_DIRECTORY);
  chdir(SESSION_DIRECTORY);

  f = fopen(argv[1], "r");
  if (f==NULL) {
    printf("Content-Type: text/plain\n\n");
    printf("Launching file is absent. Sorry !\n");
    exit(1);
  }
  fread(buf, 1, 2048, f);
  fclose(f);
  lineNo=atoi(argv[2]);
  printf("Content-Type: application/x-websd\n\n");
  line = strtok(buf, "\n");
  while (i < lineNo) {
    line = strtok(NULL, "\n");
    i++;
  }
  printf("%s\n", line);
  return 0;
}
"Peter Hansen" <peter at engcorp.com> a écrit dans le message de news:
3E6E5BEC.34CB1666 at engcorp.com...
> > Benoit BESSE wrote:
> >
> > Hello,
> > who is able to convert this C program into a Python script or mudule
>
> Uh, nobody?  It might not even be a valid program: it's missing "main()".
>
> Or is there a framework of some kind assumed, in which case it might
> help if you explained the context better.
>
> -Peter






More information about the Python-list mailing list