home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / LS351.ZIP / LSORT.H < prev    next >
C/C++ Source or Header  |  1994-01-04  |  6KB  |  211 lines

  1. #define C88 Y
  2. #ifdef _WINDOWS32
  3. #define _LSORT32
  4. #endif
  5. #ifdef _OS232
  6. #define _LSORT32
  7. #endif
  8. #ifdef MSC
  9. #define LINT_ARGS Y
  10. #define UNSIGNED unsigned
  11. #else
  12. #define UNSIGNED
  13. #endif
  14.  
  15. #ifdef _OS232
  16. #define CDECL
  17. #else
  18. #ifdef _WINDOWS32
  19. #define CDECL _cdecl
  20. #else
  21. #define CDECL
  22. #endif
  23. #endif
  24.  
  25. #define BIGFILE 0xFFFFFFF
  26. #define MAXFI 16
  27. #define CPMEOF 26
  28. #define MAXSTR 1024
  29. #define MAXLRCL 4096
  30. #define NWAY 9
  31.  
  32. #ifdef _LSORT32
  33. #define MAXREC 256003
  34. #define SBUFLEN (160000l)
  35. #else
  36. #define MAXREC 16003
  37. #define SBUFLEN (64000l)
  38. #endif
  39. #define MBUFLEN (SBUFLEN)
  40. /* Note MIN_SORTRECS * 4 must be big enough to hold 2*MAXLRCL + 4*MAXSTR */
  41. /*      MIN_SBUFLEN must be big enough to hold NWAY*MAXLRCL+10KB (32KB) */
  42. #define MIN_SORTRECS (MAXLRCL + MAXSTR)
  43. #define MIN_SBUFLEN (MAXLRCL*NWAY+10240)
  44. #define MAXFLDS 32
  45. #define NWAY2P1 (2*NWAY + 1)
  46. #define DBMAXFLD 32
  47. #define DB3MAXFLD 128
  48. #define DBFLDSI  16
  49. #define DB3FLDSI 32
  50. #define DBHEDLEN 521
  51. #define WRITEBIN 1
  52. #define READBIN (O_BINARY + O_RDONLY)
  53. #define strmvc strcpy
  54. #define submvc(to,from,len) memcpy(to,from,len)
  55. #define length strlen
  56. #define tget gets
  57. #define tput(s) bdosputs(s),bdosputs("\r\n")
  58. #define strclc strcmp
  59. #define subclc strncmp
  60. #define subcmp strncmp
  61. #define subcpy(to,from,len) memcpy(to,from,len)
  62. #define swrite(f,s) write(f,s,strlen(s)),write(f,"\r\n",2)
  63. #define bswrite(f,s) write(f,s,strlen(s)),write(f,"\r\n",2)
  64. #define sread bsread
  65. #define c80puts puts
  66. #ifdef MSC
  67. #define _move(count,source,dest) memcpy(dest,source,count)
  68. #define _setmem(dest,count,value) memset(dest,value,count)
  69. #endif
  70.  
  71. #ifndef _MAX_DIR
  72. #include <stdlib.h>
  73. #endif
  74.  
  75. #ifndef min
  76. #define min(a,b) (a<b ? a :b)
  77. #endif
  78.  
  79. struct dbfld
  80. {
  81.     UNSIGNED char dbfld_name[11],dbfld_type,dbfld_len,fill_0[2],dbfld_dec;
  82. };
  83. struct dbhed
  84. {
  85.     UNSIGNED char db_id; /*=0x02*/
  86.     short int db_nbr;
  87.     UNSIGNED char db_dte[3];
  88.     short int db_lrecl;
  89.     struct dbfld db_flds[DBMAXFLD]; /*field attributes*/
  90.     UNSIGNED char db_trail; /*should=0*/
  91. };
  92. struct db3fld {
  93.     UNSIGNED char db3fld_name[11];
  94.     UNSIGNED char db3fld_type;
  95.     long db3fld_addr;
  96.     UNSIGNED char db3fld_len;
  97.     UNSIGNED char db3fld_dec;
  98.     char db3fill[14];
  99. };
  100. struct db3hed {
  101.     UNSIGNED char db3_id; /*=0x03 or =x083 (if dbt file) */
  102.     UNSIGNED char db3_dte[3];
  103.     long int db3_nbr;
  104.     short int db3_headrln,db3_lrecl;
  105.     UNSIGNED char db3_headfill[20];
  106.     struct db3fld db3_flds[DB3MAXFLD]; /*field attributes*/
  107.     UNSIGNED char db3_trail; /*should=0d*/
  108.     UNSIGNED char db3_cpmeof; /* set to 26 if needed */
  109. };
  110. struct fieldinfo {
  111.     int (CDECL *lcmpsub) ();
  112.     short int fstart,fcond;
  113.     UNSIGNED char flen,ftype;
  114. };
  115. struct sortparm {
  116.     long int filesize,rcount[MAXSTR];
  117.     short int lrecl,str_wri,maxlrecl,db3hdrln;
  118.     struct fieldinfo lsdata[MAXFLDS];
  119.     UNSIGNED char dbasebuf[DBHEDLEN],mfile[NWAY2P1][_MAX_DIR],infi[_MAX_DIR],otfi[_MAX_DIR];
  120.     UNSIGNED char ansbuf[128],merg_inn,merg_pass,merg_drive,smi,nflds,nway;
  121.     UNSIGNED char drive1,drive2,mount,phase,harddisk,cpmeof;
  122. ;
  123.  
  124. struct mergebuf {
  125.     char *mbuffer;
  126.     unsigned int mbegin,mend,msize,meof,mchann;
  127. };
  128.  
  129. char *parsepp(char **,char);
  130. int is_dbase3(unsigned);
  131. int cscan(char *,char);
  132. int CDECL slngcmp(long *,long *,int);
  133. int CDECL slogcmp(char *,char *,int);
  134. int CDECL shlfcmp(short int *,short int *,int);
  135. int CDECL sfltcmp(float *,float *,int);
  136. int CDECL sdblcmp(double *,double *,int);
  137. int CDECL sxcmp(char *,char *,int);
  138. int CDECL sycmp(char *,char *,int);
  139. int CDECL szcmp(char *,char *,int);
  140. int CDECL sintcmp(char [],char [],int);
  141. int CDECL zonecmp(char [],char [],int);
  142. int CDECL spakcmp(unsigned char *,unsigned char *,int);
  143. void oterr(int otchan,char *msg);
  144. int copyfi(void);
  145. int lssort(void);
  146. void sortout(char *[],int,int,char *);
  147. int sortin(char *[],int *,char *[],long,int,short int,short int *,long *);
  148. void mergrbuf(int lrecl,struct mergebuf *mbf);
  149. char *mergread(struct mergebuf *,int,char);
  150. int mbfint(struct mergebuf *,int,int,int,
  151. char [NWAY2P1][_MAX_DIR],char *,char **,int,char);
  152. int sortread(int,int,char *);
  153. void mergwrite(int,char *,int,struct mergebuf *);
  154. void mergflush(int,struct mergebuf *);
  155. void mountout(char *drive,long size,char *outfile,char harddisk);
  156. void mwork(char *drvie,long size,char harddisk);
  157. int openfi(char *,int);
  158. int create(char *);
  159. int bsread(int,char *);
  160. void fixinfi(char *);
  161. void getsdat(struct db3hed *);
  162. void mhelp(void);
  163. void getfldf(struct db3hed *);
  164. int setcmd(void);
  165. int getstart(char *,struct db3hed *,int *,char *,int,int);
  166. int getlrecl(void);
  167. int gettype(void);
  168. int sortcmp(char *,char *);
  169. char *rtjust(char *,char *,char *,int *,int);
  170. char *dlmfld(char *,int,int *);
  171. int lsfloat(char *,int,char *);
  172. void sortmove(char *tostr,char *frstr,int lrecl);
  173. int userip(char *);
  174. void userop(char *,int);
  175. void lsmerge(struct db3hed *);
  176. int sort(char **,int);
  177. int qksort(int,int,char **);
  178. int hpsort(char **,int);
  179. void sift(int,int,char **);
  180. void chkdbase(UNSIGNED char *,UNSIGNED char *,struct db3hed *);
  181. int getdbase(struct dbhed *);
  182. int getdb3(struct db3hed *,int,int *);
  183. void setcmp(void);
  184. void srchdbh(struct dbhed *,char *,int *,int *,char *);
  185. void srchdb3(struct db3hed *,char *,int *,int *,char *);
  186. int suprcmp(char *,char *,int);
  187. char *pr(char *);
  188. int prmpt(char *,char *);
  189.  
  190. #ifdef MAIN
  191. char temp[255],*blankline;
  192. long mtotbuflen;
  193. #ifdef _LSORT32
  194. long max_sortrecs, max_sbuflen;
  195. #else
  196. unsigned max_sortrecs, max_sbuflen;
  197. #endif
  198. int percentfree,percentuse;
  199. #else
  200.  
  201. extern char temp[255],*blankline;
  202. extern long mtotbuflen;
  203. #ifdef _LSORT32
  204. extern long max_sortrecs, max_sbuflen;
  205. #else
  206. extern unsigned max_sortrecs, max_sbuflen;
  207. #endif
  208. extern int percentfree,percentuse;
  209. #endif
  210.