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

📄 snptools.c

📁 这是一个Linux下的集成开发环境
💻 C
📖 第 1 页 / 共 2 页
字号:
 * Override the group (or language) string that must be passed into sn_main. */voidsn_set_group(char *newGroup){  group = newGroup;}/* * Initialise the connection to the project database. */intsn_init(){  Paf_Pipe_Create(incl_to_pipe);  if (xref_filename != NULL && !(cross_ref_fp = fopen(xref_filename, "a")))  {    sn_message("Open error: %s\n", xref_filename);    sn_exit();  }  return(0);}/* * Close the database connection. */intsn_close_db(){  return(Paf_Pipe_Close());}/* * Register a new source file in the project. */intsn_register_filename(FILE ** lexstream, char * filename){    if (*lexstream)    {      fclose(*lexstream);    }        *lexstream = fopen(filename, OPEN_MODE);    if (!(*lexstream))    {      sn_message("Error: unable to open file %s\n", filename);      return(1);    }    else    {      char * highlight_fname = NULL;      /*       * If the -h option was passed then create a tmp file       * and save highlight info into the file. The -s option       * is used in conjunction with -h to indicate a file       * that the name of the highlight file will be saved in.       */      if (highlight) {        if (highlightfp) {          fclose(highlightfp);        }        highlight_fname = Paf_tempnam(NULL,"hj");        if (outfp) {          fprintf(outfp,"%s\n",highlight_fname);        }              highlightfp = fopen(highlight_fname,"w+");        highlight_number = 1;      }      strcpy(currentFilename, filename);      put_status_parsing_file(filename);      put_file(filename, group, highlight_fname);    }    return(0);}/* * Set the current column to a new position. */voidsn_set_column(long c){   column = c;}/* * Reset the column position. */voidsn_reset_column(){   sn_set_column(0);}/* * Advance the column position by `num' positions. */voidsn_advance_column(int num){  column += num;}/* * Set the current line to a new position. */voidsn_set_line(long l){  line = l;}/* * Reset the line position. */voidsn_reset_line(){  sn_set_line(1);}/* * Advance to the next line position. */voidsn_advance_line(){  line++;} /* * Retrieve the current line position. */longsn_line(){  return line;}/* * Retrieve the current column position. */longsn_column(){  return column;}/* * Save the current line position on a stack. */voidsn_push_line(){  savedLine = sn_line();}/* * Pop the stored line position off the stack. */longsn_pop_line(){  long result = savedLine;  savedLine = -1;  return result;} /* * Push the current column position onto the stack. */voidsn_push_column(){  savedColumn = sn_column();}/* * Pop the stored column position off the stack. */longsn_pop_column(){  long result = savedColumn;  savedColumn = -1;  return result;}/* * Parse all the files listed in the source file list specified using -y * on the command line. */voidsn_parse_all(FILE ** lexstream, int (*parse)(), void (*reset)()){  char filename[512];  char * temp;    if (listfp == NULL) return;  while (fgets(filename, sizeof(filename) - 1, listfp))  {    if ((temp = strchr(filename, '\n')))    {      *temp = 0; /* null terminate the string */    }    if (!*filename || *filename == '#')      continue;    if (sn_register_filename(lexstream, filename) == 0)    {      parse();      reset();    }  }}/* * Close all files and the database connection. */voidsn_close(){  sn_close_db();    if (listfp != NULL)  {    fclose(listfp);  }    if (outfp != NULL)  {    fclose(outfp);  }  if (highlightfp != NULL)  {    fclose(highlightfp);  }    if (cross_ref_fp != NULL)  {    fclose(cross_ref_fp);  }}/* * Count the number of line and column advancements in a null-terminated * buffer. */void sn_count_chars(char *buf, int length){  char *p;  int i;  for (p = buf, i = length; i > 0; i--, p--)  {    if (*p == '\n')    {      sn_advance_line();      sn_reset_column();    }    else    {      sn_advance_column(1);    }  }}/* * Return the filename of the current source file. */char *sn_current_file(){  return currentFilename;}/* * Are we meant to be generating cross-referencing information? * Returns 1 if so; 0 if not. */intsn_cross_referencing(){  return (cross_ref_fp != NULL);}/* * Returns a pointer into `buf' indicating where the beginning of the last * non-whitespace region begins.  See `snptools.h' for more information. */ char *sn_afterlastwspace(char * buf){  char * p;  int len;  if ((len = strlen(buf)) == 0)  {    return(buf);  }  for (p = &buf[len - 1]; p >= buf && !isspace((int) *p); p--);  return(p + 1);}/* * Insert a symbol into the project database. * See the API documentation for detailed information. */intsn_insert_symbol(int id_type, char *classname, char *identifier,                 char *filename, int start_lineno, int start_colpos,                 int end_lineno, int end_colpos, unsigned long attr,                 char *ret, char *arg_types, char *arg_names, char *comment,                 int high_start_lineno, int high_start_colpos,                  int high_end_lineno, int high_end_colpos){  return(put_symbol(id_type, classname, identifier, filename, start_lineno,             start_colpos, end_lineno, end_colpos, attr, ret, arg_types,             arg_names, comment, high_start_lineno, high_start_colpos,             high_end_lineno, high_end_colpos));}/* * Insert cross-referencing information into the project database. * See the API documentation for detailed information. */int sn_insert_xref(int type, int scope_type, int scope_level,                   char *classname, char *funcname, char *argtypes,                    char *refclass, char *refsymbol, char *ref_arg_types,                   char *filename, int lineno, int acc){  if (sn_cross_referencing())  {    /* Use special "GLOBAL" namespace, funcname should be NULL.     * Currently, scope_type is changed to a "fu" but it really     * should be "na". Namespace support in the IDE needs to     * be fixed up so that xrefs in namespaces work before     * "na" can be passed.     */    if (scope_type == SN_GLOBAL_NAMESPACE) {        assert(funcname == NULL);        funcname = "GLOBAL";        scope_type = SN_FUNC_DEF;    }    return put_cross_ref(type, scope_type, scope_level, classname, funcname,                          argtypes, refclass, refsymbol, ref_arg_types,                          filename, lineno, acc);  }  return(0);}/* * Insert a comment into the project database. * See the API documentation for detailed information. */int sn_insert_comment(char *classname, char *funcname, char *filename,                      char *comment, int beg_line, int beg_col){  if (sn_getopt(SN_OPT_COMMENTS))   {    return put_comment(classname, funcname, filename, comment, beg_line, beg_col);  }  return(0);}/* * Search the include path for an include file. */intsn_find_file(char * filename, char * buf){        struct stat unused;        char absfilename[MAXPATHLEN];        char * path;        /* Try the working directory. */        if (stat(filename, &unused) == 0)        {           strcpy(buf, filename);           return 0;        }        /* Failed; try the search path. */        path = sn_includepath_first();        while (path != NULL)        {           sprintf(absfilename, "%s%s", path, filename);           if (stat(absfilename, &unused) == 0)           {               strcpy(buf, absfilename);               return 0;           }           path = sn_includepath_next();        }        /* Couldn't find the file anywhere! */        return 1;}

⌨️ 快捷键说明

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