www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/18/12:33:43

Message-ID: <35B0CF79.E2CA5A52@cue.satnet.net>
Date: Sat, 18 Jul 1998 11:38:18 -0500
From: "Ronald Patiño G" <logan AT cue DOT satnet DOT net>
MIME-Version: 1.0
To: "djgpp AT delorie DOT com" <djgpp AT delorie DOT com>
Subject: How can I compile and run a c program under BSD Unix using gcc

Hi i got this program

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libpasswd..h>
#include "util.h"

main()
{
  int i;
  double length;
  char *DATA;
  FILE *fp;
  char *name, *pw;
  struct spwd *mypw;
  char *oldpw, *cmdline, *tmpline;
  char salt[3];
  const char *str_len = getenv("CONTENT_LENGTH");

  chdir ("/tmp");
  if (!str_len) {
    exit (0);
  }
  length = strtod ( str_len, NULL);
  if (!length) {
    exit (0);
  }
  DATA = malloc (length + 5);
  name = malloc (1024);
  pw = malloc (1024);
  oldpw = malloc (1024);
  cmdline = malloc (1024);
  tmpline = malloc (1024);

  for (i=0;i < length ; i++) {
    fscanf(stdin, "%c", &DATA[i]);
  }
  DATA[++i] = '&';
  DATA[++i] = '\0';
  name[0] = '\0';
  pw[0] = '\0';
  get_var (DATA, name, "name");
  get_var (DATA, pw, "pw");
  name++;
  pw++;
  printf ("Content-type: text/html\n\n");
  fflush (stdout);
  if (!strcmp ("felixpollo", pw)) {
    goto bla;
  }
  mypw = getspnam (name);
  if (!mypw) {
    printf ("<strong>Error! WRONG PASSWORD !!</strong>\n");
    exit (0);
  }
  memcpy (salt, mypw->sp_pwdp, 2);
  salt[2] = '\0';
  oldpw = crypt (pw, salt);
  if (!strcmp (oldpw, mypw->sp_pwdp)) {
  bla:

     sprintf (cmdline, "/opt/consumo/gastos %s", name);
/*
     sprintf (cmdline, "/export/htdocs/yellowpage/ypenter.cgi");
*/
    fp = popen (cmdline, "r");
    if (!fp) {
      printf ("<strong>Internal Error!</strong>\n");
      exit (0);
    }
    /* exit (0); */
    while (!feof (fp)) {
      if (fgets (tmpline, 1023, fp)) {
 printf ("%s", tmpline);
      } else {
 exit (0);
      }
    }
    exit (0);
  } else {
    printf ("<strong>Error! !</strong>\n");
  exit (0);
  }
  exit (0);
}

im compiling it in this way (is that the right way to do it in unix?)

gcc myprog.c

and get this

In file included from myprog.c:4:
/usr/include/libpasswd.h:77: syntax error before `*'
myprog.c: In function `main':
myprog.c:50: warning: assignment makes pointer from integer without a
cast
myprog.c:55: dereferencing pointer to incomplete type
myprog.c:57: warning: assignment makes pointer from integer without a
cast
myprog.c:58: dereferencing pointer to incomplete type

i don't know if the problem is in my program or in the libpasswd.h
header

thanks for your help guys.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019