Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2003, 03:02 PM   PM User | #1
Ph45mA
New Coder

 
Join Date: Jan 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Ph45mA is an unknown quantity at this point
Missing File

Hello All.

I am trying to compile some code I recieved and am receiving but one error. A missing file. This is a necessary file for the program to work.

Missing File:

fggets.c

If anybody knows where to find this file, that would be great. Or if one of you has this file that could send it to me. That would be great as well.

Thank you.

[note] I can post the source code of the program if someone might have an idea as to how I'd go about getting around it.[/note]
Ph45mA is offline   Reply With Quote
Old 01-14-2003, 10:14 PM   PM User | #2
CRASH_OVERRIDE
Regular Coder

 
Join Date: Aug 2002
Location: IN, USA
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
CRASH_OVERRIDE is an unknown quantity at this point
I think we should see some code
__________________
Just call me Crash...
"Crash- and BURN!"
-Cereal Killer
CRASH_OVERRIDE is offline   Reply With Quote
Old 01-15-2003, 03:43 PM   PM User | #3
Ph45mA
New Coder

 
Join Date: Jan 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Ph45mA is an unknown quantity at this point
Here's the code.

Here is the source code.

Code:
#include <stdio.h>
#include "fggets.c"
#include <stdlib.h>
#include <string.h>
#define SAVE_FORM "$SavedForm"
#define MAXSTRING 4000
#define EOLN0x0
FILE *infile;
int done = 0;
char *line;
char linebuf[4000];
char *cline;
char newlinebuf[4000];
char *name;
char namelinebuf[400];
char *savename;
char savelinebuf[400];
char *valuestr;
char valuelinebuf[400];
char *typestr;
char typelinebuf[400];
char *p;
char *q;
char * last_bracket(char * s, char * ty);
void retrieve_value(char *s, char *n);
void retrieve_name(char *s, char *n);
void retrieve_type(char *s, char *n);
void main( int argc, char *argv[] )
    {
    line = (char *) (&linebuf);
    cline = (char *) (&newlinebuf);
    name = (char *) (&namelinebuf);
    savename = (char *) (&savelinebuf);
    valuestr = (char *) (&valuelinebuf);
    typestr = (char *) (&typelinebuf);
    if (argc <= 1)
        {
        strcpy(line, argv[0]);
        if (cline = strrchr(line, '\\'))
        cline++;
        else
        cline = line;
        p = strstr(cline, ".EXE");
        if (!p[0]) p = strstr(cline, ".exe");
        if (p[0]) p[0] = EOLN;
        printf( "Usage:\n%s input-file\n\nOr:\n",
        cline);
        printf( "%s input-file > output-file\n\n",
        cline);
        exit( 0 );
    }
    if( (infile = fopen( argv[1], "rt" )) == NULL )
        {
        perror( "Can't open input file" );
        exit( 1 );
    }
    printf("#!/usr/local/bin/perl \n");
    printf("&return_html(); \n");
    printf("\n\nsub return_html\n");
    printf("{\n\n");
    printf("print \"Content-type: text/html\\n\\n\";\n");
    while( !done )
        {
        fggets( line, MAXSTRING, &done, infile );
        line[strlen(line)] = EOLN;
        line[strlen(line) + 1] = EOLN;
        p = line;
        q = cline;
        while (p[0])
            {
            if ((p[0] == '\\') || (p[0] == '@') || (p[0] == '$') ||
            (p[0] == '&') || (p[0] == '"') || (p[0] == '#'))
                {
                q[0] = '\\';
                q++;
            }
            if (p[0] < 0x20)
            q[0] = 0x20;
            else
            q[0] = p[0];
            p++;
            q++;
        }
        q[0] = EOLN;
        q++;
        q[0] = EOLN;
        if ((strstr(cline, "<SELECT")) || (strstr(cline, "<select")))
            {
            retrieve_name(cline, name);
            sprintf(savename, "%s{'%s'}", SAVE_FORM, name);
            printf("print \"%s\";\n", cline);
            printf("if (%s) {\n", savename);
            printf(" print \"<OPTION>\";\n");
            printf(" print \"%s\\n\";\n", savename);
            printf("}\n");
        }
        else
        if (((strstr(cline, "<INPUT")) || strstr(cline, "<input")) &&
        ((strstr(cline, "TYPE=")) || strstr(cline, "type=")))
            {
            retrieve_name(cline, name);
            sprintf(savename, "%s{'%s'}", SAVE_FORM, name);
            retrieve_type(cline, typestr);
            if (strcmp(typestr, "TEXT") == 0)
                {
                p = last_bracket(cline, "TEXT");
                p[0] = EOLN;
                printf("print \"%s\";\n", cline);
                printf("print \" VALUE=\\\"%s\\\">\\n\";\n",
                savename);
                p++;
                printf("print \"%s\\n\";\n", p);
                continue;
            }
            if (strcmp(typestr, "RADIO") == 0)
                {
                retrieve_value(cline, valuestr);
                p = last_bracket(cline, "RADIO");
                p[0] = EOLN;
                printf("print \"%s\";\n", cline);
                printf("if (%s =~ '%s') { print \" CHECKED>\\n\"; }\n",
                savename, valuestr);
                printf("else { print \">\\n\"; }\n");
                p++;
                printf("print \"%s\\n\";\n", p);
                continue;
            }
            if ((strcmp(typestr, "CHECK") == 0) ||
            (strcmp(typestr, "CHECKBOX") == 0))
                {
                p = last_bracket(cline, "CHECK");
                p[0] = EOLN;
                printf("print \"%s\";\n", cline);
                printf("if (%s) { print \" CHECKED>\\n\"; }\n",
                savename);
                printf("else { print \">\\n\"; }\n");
                p++;
                printf("print \"%s\\n\";\n", p);
                continue;
            }
            if ((strcmp(typestr, "HIDDEN") == 0))
                {
                p = last_bracket(cline, "HIDDEN");
                p[0] = EOLN;
                			printf("print \"%s > \";\n", cline);
            }
        }
        else
        if ((strstr(cline, "<TEXTAREA")) || strstr(cline, "<textarea"))
            {
            retrieve_name(cline, name);
            sprintf(savename, "%s{'%s'}", SAVE_FORM, name);
            p = last_bracket(cline, "TEXTAREA");
            p[0] = EOLN;
            printf("print \"%s>\";", cline);
            printf("print \"%s\";\n", savename);
            p++;
            printf("print \"%s\\n\";\n", p);
        }
        else
        printf("print \"%s\\n\";\n", cline);
        if( feof( infile ) )
        break;
    }
    printf("\n}\n\n");
    fclose(infile);
}
void retrieve_value(char *s, char *n)
    {
    char * t;
    char * r;
    n[0] = EOLN;
    t = strstr(s, "VALUE=");
    if (!t) t = strstr(s, "value=");
    if (!t) t = strstr(s, "Value=");
    if (!t)
    return;
    else
    r = strchr(t, '=');
    r++;
    while ((r[0]) && ((r[0] == '\\') || (r[0] == '"')))
    r++;
    strcpy(n, r);
    r = n;
    while ((r[0]) && ((r[0] != '\\') && (r[0] != ' ') && (r[0] != '"')))
    r++;
    r[0] = EOLN;
}
void retrieve_type(char *s, char *n)
    {
    char * t;
    char * r;
    n[0] = EOLN;
    t = strstr(s, "TYPE=");
    if (!t) t = strstr(s, "type=");
    if (!t) t = strstr(s, "Type=");
    if (!t)
    return;
    else
    r = strchr(t, '=');
    r++;
    while ((r[0]) && ((r[0] == '\\') || (r[0] == '"')))
    r++;
    strcpy(n, r);
    r = n;
    while ((r[0]) && ((r[0] != '\\') && (r[0] != ' ') && (r[0] != '"')))
    r++;
    r[0] = EOLN;
    r = n;
    while (r[0])
        {
        r[0] = toupper(r[0]);
        r++;
    }
}
void retrieve_name(char *s, char *n)
    {
    char * t;
    char * r;
    n[0] = EOLN;
    t = strstr(s, "NAME=");
    if (!t) t = strstr(s, "name=");
    if (!t) t = strstr(s, "Name=");
    if (!t)
    return;
    else
    r = strchr(t, '=');
    r++;
    while ((r[0]) && ((r[0] == '\\') || (r[0] == '"')))
    r++;
    strcpy(n, r);
    r = n;
    while ((r[0]) && ((r[0] != '\\') && (r[0] != ' ') &&
    		 (r[0] != '"') && (r[0] != '>')))
    r++;
    r[0] = EOLN;
}
char * last_bracket(char * s, char * ty)
    {
    char * r;
    if (strcmp(ty, "TEXTAREA") == 0)
        {
        r = strstr(s, "TEXTAREA");
        if (!r) r = strstr(s, "textarea");
        if (!r) r = strstr(s, "Textarea");
    }
    if (strcmp(ty, "HIDDEN") == 0)
        {
        r = strstr(s, "HIDDEN");
        if (!r) r = strstr(s, "hidden");
        if (!r) r = strstr(s, "Hidden");
    }
    if (strcmp(ty, "TEXT") == 0)
        {
        r = strstr(s, "TEXT");
        if (!r) r = strstr(s, "text");
        if (!r) r = strstr(s, "Text");
    }
    if (strcmp(ty, "RADIO") == 0)
        {
        r = strstr(s, "RADIO");
        if (!r) r = strstr(s, "radio");
        if (!r) r = strstr(s, "Radio");
    }
    if (strcmp(ty, "CHECK") == 0)
        {
        r = strstr(s, "CHECK");
        if (!r) r = strstr(s, "check");
        if (!r) r = strstr(s, "Check");
    }
    while ((r[0]) && (r[0] != '>'))
    r++;
    return r;
}
The problem I am having once again, is compiling. Because I do not have the file "fggets.c". Any suggestions would be greatly appreciated.
Ph45mA is offline   Reply With Quote
Old 01-15-2003, 09:34 PM   PM User | #4
CRASH_OVERRIDE
Regular Coder

 
Join Date: Aug 2002
Location: IN, USA
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
CRASH_OVERRIDE is an unknown quantity at this point
I cant help much with the code, to much for me to go through right now... 2 suggestions (simple, yes): make sure the file is in the same directory; go to compiler's site and see if any patches
btw
nice coding, brings back memories. lol.
__________________
Just call me Crash...
"Crash- and BURN!"
-Cereal Killer
CRASH_OVERRIDE is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:41 PM.


Advertisement
Log in to turn off these ads.