/* --------- */ /* najicat.c */ /* --------- */ /* naji standard output (usually screen) functions */ /* this .c file is a part */ /* of libnaji version 0.6.1 */ /* libnaji is based on */ /* the original najitool */ /* both najitool and libnaji */ /* are public domain and are */ /* made by the same author */ /* please read license.txt */ /* made by NECDET COKYAZICI */ /* cat_tail, cat_head, showline */ /* made by SACHIN MANE */ #include "libnaji.h" void naji_license(void) { printf("\nTHIS PROGRAM IS NON-COPYRIGHTED PUBLIC DOMAIN AND DISTRIBUTED IN THE\n"); printf("HOPE THAT IT WILL BE USEFUL BUT THERE IS NO WARRANTY FOR THE PROGRAM,\n"); printf("THE PROGRAM IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER\n"); printf("EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"); printf("WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\n"); printf("THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS\n"); printf("WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n"); printf("ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n"); return; } void naji_credits(void) { printf("\n"); printf(" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"); printf(" najitool 0.8.1 and libnaji 0.6.1 Credits\n"); printf(" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"); printf(" in order of joining the project najitool\n"); printf("\n"); printf("NECDET COKYAZICI - England, London - cokyazici@yahoo.co.uk\n"); printf("Main author, programmer, planner, designer, tester, debugger,\n"); printf("and project manager. Wrote everything that someone else didn't write.\n"); printf("\n"); printf("SELCUK OZDOGAN - Turkey, Istanbul - selcuk198@yahoo.com\n"); printf("Programmer. Wrote charbefr, charaftr.\n"); printf("\n"); printf("POLIKARP - Poland - polikarp@users.sourceforge.net\n"); printf("Programmer. Wrote strbline, streline, chchar.\n"); printf("\n"); printf("SAMUEL CHANG - Australia - badp1ayer@hotmail.com\n"); printf("Programmer. Wrote ttt, the fun Tic-Tac-Toe game with clever AI.\n"); nextpage(); printf("ARKAINO (YEHRCL) - Argentina - arkaino@gmail.com\n"); printf("Programmer. Wrote getlinks, find_basis,\n"); printf("findi_line, chstr, skipstr, naji_mp3.c\n"); printf("\n"); printf("SACHIN MANE - America, Arizona - sachin.mane@gmail.com\n"); printf("Programmer. Wrote cat_tail, cat_head, showline, bremline, eremline.\n"); printf("\n"); printf("MANUEL LE BOETTE - France - askoan@yahoo.fr\n"); printf("Programmer. Wrote lensorts, lensortl.\n"); printf("\n"); } void kitten(char *namein) { int a=0; najin(namein); loop { a = fgetc(naji_input); if (a == EOF) endloop; fputc(a, stdout); } najinclose(); } void cat_text(char *namein) { int a=0; najin(namein); loop { a = fgetc(naji_input); if (a == EOF) endloop; if ( ( (a > 31) && (a < 127) ) || ( (a == '\n') ) || ( (a == '\r') ) || ( (a == '\t') ) ) fputc(a, stdout); } najinclose(); } /* this is better for unix because you don't really need \r on unix do you */ void cat_text_faster(char *namein) { int a=0; najin(namein); loop { a = fgetc(naji_input); if (a == EOF) endloop; if ( ( (a > 31) && (a < 127) ) || ( (a == '\n') ) || ( (a == '\t') ) ) fputc(a, stdout); } najinclose(); } /* this is the fastest but doesn't include newlines or tabs */ /* because the ascii people didn't do them close by */ void cat_text_fastest(char *namein) { int a=0; najin(namein); loop { a = fgetc(naji_input); if (a == EOF) endloop; if ( ( (a > 31) && (a < 127) ) ) fputc(a, stdout); } najinclose(); } void repcat(char *namein, unsigned int repeat) { int a=0; unsigned int i=0; najin(namein); repeat++; loop { a = fgetc(naji_input); if (a == EOF) endloop; for (i=0; i= 32) && (hexbuf[i] <= 126)) fputc(hexbuf[i], stdout); else fputc('.', stdout); } fputc('\n', stdout); break; } if (counter == 0 || counter == 16) { if (offset == 0xFFFFFFF0) { fprintf(stdout, "OFFLIMIT: "); } else { fprintf(stdout, "%08X: ", offset); } } hexbuf[counter]=a; fprintf(stdout, "%02X ", a); if (counter == 3 || counter == 7 || counter == 11 || counter == 15 ) fputc(' ', stdout); counter++; if (counter == 16) { if (offset != 0xFFFFFFF0) offset += 16; for (i=0; i<16; i++) { if ((hexbuf[i] >= 32) && (hexbuf[i] <= 126)) fputc(hexbuf[i], stdout); else fputc('.', stdout); } fputc('\n', stdout); counter = 0; } } najinclose(); } void coffset(char *namein, long startpos, long endpos) { long filesize=0; long i; najin(namein); filesize=najinsize(); if (startpos > endpos) { fprintf(stderr, "Error, start position cannot be greater than end possition.\n\n"); exit(15); } if (startpos > filesize) { fprintf(stderr, "Error, start position is greater than the file size.\n\n"); exit(16); } if (endpos > filesize) { fprintf(stderr, "Error, end position is greater than the file size.\n\n"); exit(17); } fseek(naji_input, startpos, SEEK_SET); for (i=startpos; i endpos) { fprintf(stderr, "Error, start position cannot be greater than end possition.\n\n"); exit(15); } if (startpos > filesize) { fprintf(stderr, "Error, start position is greater than the file size.\n\n"); exit(16); } if (endpos > filesize) { fprintf(stderr, "Error, end position is greater than the file size.\n\n"); exit(17); } fseek(naji_input, startpos, SEEK_SET); for (i=startpos; i