#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_WIN32)
#define DEFAULT_LF_TYPE "dos"
#elif defined(MACOS)
#define DEFAULT_LF_TYPE "mac"
#ifndef ALWAYS_KANJI_CONV
#define ALWAYS_KANJI_CONV
#endif
#else
#define DEFAULT_LF_TYPE "unix"
#define SUPPORT_LF_CONV
#endif
#define LINE_SIZE 4096
#ifdef ALWAYS_KANJI_CONV
#define SPCAT_HELP_MESSAGE "Concatenate files and print it with NKF kanji conversion"
#else
#define SPCAT_HELP_MESSAGE "Concatenate files and print it"
#endif
#ifdef ALWAYS_KANJI_CONV
#else
#endif
static char line_feed_type[SP_MAX_LINE] = DEFAULT_LF_TYPE;
#ifndef ALWAYS_KANJI_CONV
{"-k", "-kanji", "convert kanji code using NKF engine", NULL,
#endif
{"-v", NULL, "display NKF usage", NULL,
{"-C", "-code", "display kanji code only", NULL,
#ifdef SUPPORT_LF_CONV
{"-L", "-lf", "line feed type (dos,mac,unix)", NULL,
SP_TYPE_STRING_S, line_feed_type, DEFAULT_LF_TYPE},
#endif
{"-N", "-number", "use line numbers", NULL,
{"-h", "-help", "display this message", NULL,
};
static const char *filelabel[] = {
"[input file...]",
};
static int fdumpdata(int count, FILE *fp)
{
int i;
static unsigned char lin[LINE_SIZE] = "";
static unsigned char lout[LINE_SIZE] = "";
for (i = count; fgetsn((char *)lin, LINE_SIZE, fp) != NULL; i++) {
} else {
fprintf(stdout, "%6d ", i);
}
fputs((char *)lout, stdout);
} else {
fputs((char *)lin, stdout);
}
if (streq(line_feed_type, "dos")) {
fputs("\r\n", stdout);
} else if (streq(line_feed_type, "mac")) {
fputs("\r", stdout);
} else {
fputs("\n", stdout);
}
}
}
}
return i;
}
int main(int argc, char *argv[])
{
int count;
FILE *fp;
const char *filename;
}
}
if ((filename =
spGetFile(options)) == NULL) {
fp = stdin;
fdumpdata(1, fp);
} else {
count = 1;
while (filename != NULL) {
if ((fp = fopen(filename, "r")) == NULL) {
spError(1,
"Can't open file: %s", filename);
} else {
count = fdumpdata(count, fp);
fclose(fp);
}
}
}
return 0;
}
void spError(int status, const char *format,...)
#define SP_FALSE_STRING
Definition spDefs.h:253
int spBool
Definition spDefs.h:248
#define SP_TRUE
Definition spDefs.h:250
#define SP_FALSE
Definition spDefs.h:251
spKanjiCode spConvertKanji(const unsigned char *lin, unsigned char *lout, int size)
void spSetKanjiCode(spKanjiCode icode, spKanjiCode ocode)
spKanjiCode spGetLocaleKanjiCode(const char *lang)
const char * spGetKanjiCodeLabel(spKanjiCode code)
int spSetKanjiOptions(int n, const char **options)
#define spGetOptions(argc, argv, option, file_label)
Definition spOption.h:161
struct _spOptions * spOptions
Definition spOption.h:62
void spGetOptionsValue(int argc, char **argv, spOptions options)
const char * spGetFile(spOptions options)
void spSetHelpMessage(spBool *flag, const char *format,...)
void spIgnoreUnknownOption(spOptions options, spBool flag)