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

📄 gftpui.c

📁 一个linux下的ftp程序。它是使用文件传输协议的一系列程序的集合。
💻 C
📖 第 1 页 / 共 4 页
字号:
                        void *other_uidata, gftp_request * other_request,                        const char *command){  gftpui_callback_data * cdata;  if (!GFTP_IS_CONNECTED (request))    {      request->logging_function (gftp_logging_error, request,                                 _("Error: Not connected to a remote site\n"));      return (1);    }  else if (*command == '\0')    {      request->logging_function (gftp_logging_error, request,                     _("usage: site <site command>\n"));    }  else    {      cdata = g_malloc0 (sizeof (*cdata));      cdata->request = request;      cdata->uidata = uidata;      cdata->input_string = (char *) command;      cdata->run_function = gftpui_common_run_site;      gftpui_common_run_callback_function (cdata);      g_free (cdata);    }  return (1);}static intgftpui_common_cmd_mkdir (void *uidata, gftp_request * request,                         void *other_uidata, gftp_request * other_request,                         const char *command){  gftpui_callback_data * cdata;  if (!GFTP_IS_CONNECTED (request))    {      request->logging_function (gftp_logging_error, request,                                 _("Error: Not connected to a remote site\n"));      return (1);    }  else if (*command == '\0')    {      request->logging_function (gftp_logging_error, request,                     _("usage: mkdir <new directory>\n"));    }  else    {      cdata = g_malloc0 (sizeof (*cdata));      cdata->request = request;      cdata->uidata = uidata;      cdata->input_string = (char *) command;      cdata->run_function = gftpui_common_run_mkdir;      gftpui_common_run_callback_function (cdata);      g_free (cdata);    }  return (1);}static intgftpui_common_cmd_chdir (void *uidata, gftp_request * request,                         void *other_uidata, gftp_request * other_request,                         const char *command){  gftpui_callback_data * cdata;  char *tempstr, *newdir = NULL;  if (!GFTP_IS_CONNECTED (request))    {      request->logging_function (gftp_logging_error, request,                                 _("Error: Not connected to a remote site\n"));      return (1);    }  else if (*command == '\0')    {      request->logging_function (gftp_logging_error, request,                                 _("usage: chdir <directory>\n"));      return (1);    }  else if (request->protonum == GFTP_LOCAL_NUM)    {      if (*command != '/' && request->directory != NULL)        {          tempstr = gftp_build_path (request, request->directory, command,                                     NULL);          newdir = gftp_expand_path (request, tempstr);          g_free (tempstr);        }      else        newdir = gftp_expand_path (request, command);      if (newdir == NULL)        {          request->logging_function (gftp_logging_error, request,                                     _("usage: chdir <directory>\n"));          return (1);        }    }  cdata = g_malloc0 (sizeof (*cdata));  cdata->request = request;  cdata->uidata = uidata;  cdata->input_string = newdir != NULL ? newdir : (char *) command;  cdata->run_function = gftpui_common_run_chdir;  cdata->dont_clear_cache = 1;  gftpui_common_run_callback_function (cdata);  g_free (cdata);  if (newdir != NULL)    g_free (newdir);  return (1);}static intgftpui_common_cmd_close (void *uidata, gftp_request * request,                         void *other_uidata, gftp_request * other_request,                         const char *command){  gftp_disconnect (request);  return (1);}static intgftpui_common_cmd_pwd (void *uidata, gftp_request * request,                       void *other_uidata, gftp_request * other_request,                       const char *command){  if (!GFTP_IS_CONNECTED (request))    {      request->logging_function (gftp_logging_error, request,                                 _("Error: Not connected to a remote site\n"));      return (1);    }  request->logging_function (gftp_logging_misc, request,                             "%s\n", request->directory);  return (1);}static intgftpui_common_cmd_quit (void *uidata, gftp_request * request,                        void *other_uidata, gftp_request * other_request,                        const char *command){  gftp_shutdown();  return (0);}static intgftpui_common_cmd_clear (void *uidata, gftp_request * request,                         void *other_uidata, gftp_request * other_request,                         const char *command){  if (strcasecmp (command, "cache") == 0)    gftp_clear_cache_files ();  else    {      gftpui_common_logfunc (gftp_logging_error, request,                             _("Invalid argument\n"));    }  return (1);}static intgftpui_common_clear_show_subhelp (const char *topic){  if (strcmp (topic, "cache") == 0)    {      gftpui_common_logfunc (gftp_logging_misc, NULL,                             _("Clear the directory cache\n"));      return (1);    }  return (0);}static intgftpui_common_set_show_subhelp (const char *topic){   gftp_config_vars * cv;      if ((cv = g_hash_table_lookup (gftp_global_options_htable, topic)) != NULL)    {      gftpui_common_logfunc (gftp_logging_misc, NULL, "%s\n", cv->comment);      return (1);    }  return (0);}   static intgftpui_common_cmd_ls (void *uidata, gftp_request * request,                      void *other_uidata, gftp_request * other_request,                      const char *command){  char *startcolor, *endcolor, *tempstr;  gftpui_callback_data * cdata;  GList * templist;  gftp_file * fle;  if (!GFTP_IS_CONNECTED (request))    {      request->logging_function (gftp_logging_error, request,                     _("Error: Not connected to a remote site\n"));      return (1);    }  cdata = g_malloc0 (sizeof (*cdata));  cdata->request = request;  cdata->uidata = uidata;  cdata->source_string = *command != '\0' ? (char *) command : NULL;  cdata->run_function = gftpui_common_run_ls;  cdata->dont_refresh = 1;  gftpui_common_run_callback_function (cdata);  templist = cdata->files;  while (templist != NULL)    {      fle = templist->data;      gftpui_lookup_file_colors (fle, &startcolor, &endcolor);      tempstr = gftp_gen_ls_string (fle, startcolor, endcolor);      request->logging_function (gftp_logging_misc_nolog, request, "%s\n",                                 tempstr);      g_free (tempstr);      templist = templist->next;      gftp_file_destroy (fle, 1);    }  if (cdata->files != NULL)    g_list_free (cdata->files);  g_free (cdata);  return (1);}intgftpui_common_cmd_open (void *uidata, gftp_request * request,                        void *other_uidata, gftp_request * other_request,                        const char *command){  gftpui_callback_data * cdata;  intptr_t retries;  if (GFTP_IS_CONNECTED (request))    gftpui_disconnect (uidata);    if (command != NULL)    {      if (*command == '\0')        {          request->logging_function (gftp_logging_error, request,                                     _("usage: open " GFTP_URL_USAGE "\n"));          return (1);        }          if (gftp_parse_url (request, command) < 0)        return (1);    }  if (gftp_need_username (request))    gftpui_prompt_username (uidata, request);  if (gftp_need_password (request))    gftpui_prompt_password (uidata, request);  gftp_lookup_request_option (request, "retries", &retries);  cdata = g_malloc0 (sizeof (*cdata));  cdata->request = request;  cdata->uidata = uidata;  cdata->run_function = gftpui_common_run_connect;  cdata->retries = retries;  cdata->dont_check_connection = 1;  gftpui_common_run_callback_function (cdata);  g_free (cdata);  return (1);}static intgftpui_common_cmd_set (void *uidata, gftp_request * request,                       void *other_uidata, gftp_request * other_request,                       const char *command){  char *pos, *backpos, buf[256];  gftp_config_vars * cv, newcv;  GList * templist;  int i;    if (command == NULL || *command == '\0')    {      for (templist = gftp_options_list;           templist != NULL;            templist = templist->next)        {          cv = templist->data;          for (i=0; cv[i].key != NULL; i++)            {               if (!(cv[i].ports_shown & GFTP_PORT_TEXT))                continue;              if (*cv[i].key == '\0' ||                  gftp_option_types[cv[i].otype].write_function == NULL)                continue;              gftp_option_types[cv[i].otype].write_function (&cv[i], buf,                                                             sizeof (buf), 0);              gftpui_common_logfunc (gftp_logging_misc_nolog, request,                                     "%s = %s\n", cv[i].key, buf);            }        }    }  else    {      if ((pos = strchr (command, '=')) == NULL)        {          gftpui_common_logfunc (gftp_logging_error, request,                                 _("usage: set [variable = value]\n"));          return (1);        }      *pos = '\0';      for (backpos = pos - 1;           (*backpos == ' ' || *backpos == '\t') && backpos > command;           backpos--)        *backpos = '\0';      for (++pos; *pos == ' ' || *pos == '\t'; pos++);      if ((cv = g_hash_table_lookup (gftp_global_options_htable, command)) == NULL)        {          gftpui_common_logfunc (gftp_logging_error, request,                                 _("Error: Variable %s is not a valid configuration variable.\n"), command);          return (1);        }      if (!(cv->ports_shown & GFTP_PORT_TEXT))        {          gftpui_common_logfunc (gftp_logging_error, request,                                 _("Error: Variable %s is not available in the text port of gFTP\n"), command);          return (1);        }      if (gftp_option_types[cv->otype].read_function != NULL)        {          memcpy (&newcv, cv, sizeof (newcv));          newcv.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;          gftp_option_types[cv->otype].read_function (pos, &newcv, 1);          gftp_set_global_option (command, newcv.value);

⌨️ 快捷键说明

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