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

Copy a file into the repository. More...

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include "libfossrepo.h"
Include dependency graph for repcopyin.c:

Go to the source code of this file.

Functions

void CopyFile (char *Source, char *Type, char *Name)
 
int ReadLine (FILE *Fin, char *Line, int MaxLine)
 
int Hex2Dec (char C)
 
int UnUnicodeHex (char *S)
 
void ProcessPairs (FILE *Fin, char *Type)
 
void ProcessXML (FILE *Fin, char *TypeSource, char *Type)
 Process Ununpack XML. More...
 
int main (int argc, char *argv[])
 

Variables

long TotalImported = 0
 
long TotalDuplicate = 0
 
long TotalError = 0
 

Detailed Description

Copy a file into the repository.

Input can be from stdin or command-line. stdin can be pairs of files, or xml.

Definition in file repcopyin.c.

Function Documentation

◆ CopyFile()

void CopyFile ( char *  Source,
char *  Type,
char *  Name 
)

Given one file, copy it.

Parameters
SourceSource file path
TypeType of source
NameDestination file name
See also
fo_RepImport()

Definition at line 39 of file repcopyin.c.

◆ Hex2Dec()

int Hex2Dec ( char  C)

Given a hex character, return decimal value.

Parameters
CHex character to convert
Returns
Decimal value of C

Definition at line 87 of file repcopyin.c.

◆ ProcessPairs()

void ProcessPairs ( FILE *  Fin,
char *  Type 
)

Process pairs of names in format: dest src

Parameters
FinFP to read from
TypeType of file

Definition at line 117 of file repcopyin.c.

◆ ProcessXML()

void ProcessXML ( FILE *  Fin,
char *  TypeSource,
char *  Type 
)

Process Ununpack XML.

Format comes from Ununpack -L. We care about fuid and source fields. We want to skip directories and artifacts.

Parameters
FinFile pointer
TypeSourceType of source
TypeType of destination

Definition at line 168 of file repcopyin.c.

◆ ReadLine()

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

Read a line from stdin.

Parameters
FinFile to read from (STDIN)
[out]LineLine read
MaxLineMax length of line
Returns
Number of bytes loaded.

Definition at line 64 of file repcopyin.c.

◆ UnUnicodeHex()

int UnUnicodeHex ( char *  S)

Convert "&#xAA;" to hex.

Parameters
SUnicode character
Returns
Returns hex or -1 on error.

Definition at line 100 of file repcopyin.c.