⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadsfx.c

📁 后缀数存储算法
💻 C
字号:
/************************************************************************** *                                                                        * * loadsfx 1.0                                                            * * Copyright (C) 2001 Fabien Menemenlis (nihilist@dead-inside.org)        * *                                                                        * * This program is free software; you can redistribute it and/or          * * modify it under the terms of the GNU General Public License            * * as published by the Free Software Foundation; either version 2         * * of the License, or (at your option) any later version.                 * *                                                                        * * This program is distributed in the hope that it will be useful,        * * but WITHOUT ANY WARRANTY; without even the implied warranty of         * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          * * GNU General Public License for more details.                           * *                                                                        * * You should have received a copy of the GNU General Public License      * * along with this program; if not, write to the Free Software            * * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, * * USA                                                                    * *                                                                        * **************************************************************************/#include <stdio.h>#include <stdlib.h>#include "sfxdisk.h"void to_bin(char *buffer){  char *ptr;  int c;  char car[3];  ptr = buffer;  while (*buffer != '\0' && *buffer != '\n')  {    car[2] = '\0';    memcpy(car, buffer, 2);    c = strtol(car, NULL, 16);    buffer += 2;    snprintf(car, 2, "%c", c);    *(ptr++) = car[0];  }  *ptr = '\0';}int main(int argc, char *argv[]){  STFile *stfile;  char *buffer;  int size_buffer, size;  char key[TELEM + 1];  if (argc != 2)  {    fprintf(stderr, "%s <suffix tree file>\n"	    "input on stdin\n", argv[0]);    return(1);  }  if ((stfile = STopen(argv[1], ST_RDWRITE)) == NULL)  {    perror(argv[1]);    return(1);  }  buffer = (char *)malloc(4096);  size_buffer = 4096;  while (fgets(buffer, size_buffer, stdin) != NULL)  {    to_bin(buffer);    strncpy(key, buffer, TELEM);    fgets(buffer, size_buffer, stdin);    to_bin(buffer);    size = atoi(buffer);    if (size * 2 + 2 > size_buffer)    {      size_buffer = size * 2 + 2;      buffer = (char *)realloc(buffer, size_buffer);      if (buffer == NULL)      {	perror(argv[0]);	return(1);      }    }    fgets(buffer, size * 2 + 2, stdin);    to_bin(buffer);    STinsert(stfile, key, buffer, size);  }  STclose(stfile);  return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -