FOSSology  4.4.0
Open Source License Compliance by Open Source Software
finder.c File Reference

Get mime type for specified package. More...

#include "finder.h"
Include dependency graph for finder.c:

Go to the source code of this file.

Functions

char * TaintString (char *S)
 Create a string with taint quoting. More...
 
void DBLoadMime ()
 Populate the DBMime table.
 
int DBFindMime (char *Mimetype)
 Find a mime type in the DBMime table. More...
 
int CheckMimeTypes (char *Ext)
 Given an extension, see if extension exists in the /etc/mime.types. More...
 
int DBCheckFileExtention ()
 Given a pfile, identify any filenames and see if any of them have a known extension based on /etc/mime.types. More...
 
int GetDefaultMime (char *MimeType, char *Filename)
 Get the ID for the default mimetype. More...
 
void DBCheckMime (char *Filename)
 Given a file, check if it has a mime type in the DB. More...
 
char * GetFieldValue (char *Sin, char *Field, int FieldMax, char *Value, int ValueMax)
 Given a string that contains field='value' pairs, save the items. More...
 
int ReadLine (FILE *Fin, char *Line, int MaxLine)
 Read a line each time from one file. More...
 
void Usage (char *Name)
 Here are some suggested options. More...
 

Variables

char SQL [MAXCMD]
 For DB. More...
 
PGresult * DBMime = NULL
 contents of mimetype table
 
int MaxDBMime =0
 how many rows in DBMime
 
PGconn * pgConn
 Database connection. More...
 
int Agent_pk =-1
 agent identifier
 
FILE * FMimetype =NULL
 for /etc/mime.types
 
magic_t MagicCookie
 for Magic More...
 
int Akey = 0
 
char A [MAXCMD]
 input for this system
 

Detailed Description

Get mime type for specified package.

Definition in file finder.c.

Function Documentation

◆ CheckMimeTypes()

int CheckMimeTypes ( char *  Ext)

Given an extension, see if extension exists in the /etc/mime.types.

Parameters
ExtThe extension
Returns
int - if the extension exists in the /etc/mime.types, add metatype to DB and return DB index. Otherwise, return -1.

Definition at line 127 of file finder.c.

◆ DBCheckFileExtention()

int DBCheckFileExtention ( )

Given a pfile, identify any filenames and see if any of them have a known extension based on /etc/mime.types.

Note
Reads pfile id from Akey
Returns
int - return the mimetype id, or -1 if not found.

Definition at line 185 of file finder.c.

◆ DBCheckMime()

void DBCheckMime ( char *  Filename)

Given a file, check if it has a mime type in the DB.

If it does not, then add it.

Parameters
FilenameThe path of the file

Definition at line 281 of file finder.c.

◆ DBFindMime()

int DBFindMime ( char *  Mimetype)

Find a mime type in the DBMime table.

If the Mimetype is already in table mimetype, return mimetype_pk, if not, insert it into table mimetype, then return the mimetype_pk.

Parameters
MimetypeMimetype_name
Returns
int - mimetype ID or -1 if not found.

Definition at line 81 of file finder.c.

◆ GetDefaultMime()

int GetDefaultMime ( char *  MimeType,
char *  Filename 
)

Get the ID for the default mimetype.

Options are:

Mimetype Description
application/x-empty Zero-length file
text/plain 1st 100 characters are printable
application/octet-stream 1st 100 characters contain binary
Parameters
MimeTypeMimetype name
FilenameFile name
Returns
int - return -1 on error, or DB index to metatype.

Definition at line 247 of file finder.c.

◆ GetFieldValue()

char* GetFieldValue ( char *  Sin,
char *  Field,
int  FieldMax,
char *  Value,
int  ValueMax 
)

Given a string that contains field='value' pairs, save the items.

Parameters
[in]SinInput string
[out]FieldField string
[in]FieldMaxCapacity of Field
[out]ValueValue string
[in]ValueMaxCapacity of Field
Returns
Return character pointer to start of next field, or NULL at \0.

Definition at line 414 of file finder.c.

◆ ReadLine()

int ReadLine ( FILE *  Fin,
char *  Line,
int  MaxLine 
)

Read a line each time from one file.

Parameters
[in]FinThe file stream
[out]LineSave a line of content
[in]MaxLineMax character count one time to read a line
Returns
int - the character count of the line

Definition at line 478 of file finder.c.

◆ TaintString()

char* TaintString ( char *  S)

Create a string with taint quoting.

Parameters
[in]SThe string to be tainted
Returns
Static tainted string.

Definition at line 35 of file finder.c.

◆ Usage()

void Usage ( char *  Name)

Here are some suggested options.

Say how to run this program.

Parameters
Name- the name of the executable, usually it is mimetype

Definition at line 510 of file finder.c.

Variable Documentation

◆ MagicCookie

magic_t MagicCookie

for Magic

Magic Cookie.

Definition at line 23 of file finder.c.

◆ pgConn

PGconn* pgConn

Database connection.

DB connection.

Database connection.

Definition at line 18 of file finder.c.

◆ SQL

char SQL[MAXCMD]

For DB.

SQL query to execute.

Definition at line 14 of file finder.c.