Beispiel #1
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_wget_process, ev, data)
{
  PROCESS_BEGIN();

  strncpy(url, data, sizeof(url));
  open_url(url);

  running = 1;
  
  while(running) {
    PROCESS_WAIT_EVENT();
    
    if(ev == tcpip_event) {
      webclient_appcall(data);
    } else if(ev == resolv_event_found) {
      /* Either found a hostname, or not. */
      if((char *)data != NULL &&
	 resolv_lookup((char *)data) != NULL) {
	open_url(url);
      } else {
	shell_output_str(&wget_command, "Host not found.", "");
      }
    }
  }

  PROCESS_END();
}
CondorFile * CondorFileTable::open_url_retry( char const *url, int flags, int mode )
{
	CondorFile *f;

	f = open_url( url, flags, mode );
	if(f) return f;

	if( RemoteSysCalls() ) {
		const char *path;

		if( strstr(url,"remote:") ) return 0;

		path = strrchr(url,':');
		if(!path) return 0;

		path++;
		if(!*path) return 0;

		char *new_url = (char *)malloc(strlen(path)+15);
		sprintf(new_url,"buffer:remote:%s",path);
		CondorFile *result = open_url( new_url, flags, mode );
		free( new_url );
		return result;
	}

	return 0;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    char *phrase = argv[1];
    char *vars[] = {"RSS_FEED=http://www.ftchinese.com/rss/diglossia", NULL};
    int fd[2];
    if (pipe(fd) == -1) {
        error("Can't create the pipe");
    }
    pid_t pid = fork();
    if (pid == -1) {
        error("Can't fork process");
    }
    if (!pid) {
        dup2(fd[1], 1);
        close(fd[0]);
        if (execle("/usr/bin/python", "/usr/bin/python", "../9/rss/rssgossip.py", phrase, NULL, vars) == -1) {
            error("Can't run script");
        }
    }
    dup2(fd[0], 0);
    close(fd[1]);
    char line[255];
    while (fgets(line, 255, stdin)) {
        if (line[0] == '\t')
            open_url(line + 1);
    }
    return 0;
}
Beispiel #4
0
static void webtool_open ( VikExtTool *self, VikWindow *vwindow )
{
  VikWebtool *vwd = VIK_WEBTOOL ( self );
  gchar *url = vik_webtool_get_url ( vwd, vwindow );
  open_url ( NULL, url );
  g_free ( url );
}
Beispiel #5
0
static void parser_payload(char *payload)
{
	char **arr = NULL;
	char *get  = NULL;
	char *host = NULL;
	char *url  = NULL;


	g_return_if_fail(payload != NULL);

	arr = g_strsplit(payload, "\r\n", -1);
	if(arr == NULL) {
		fprintf(stderr, "NULL Pointer\n");
		return;
	}

	get  = g_strdup(arr[0]);
	host = g_strdup(arr[1]);

	url = parser_data(get, host);

	open_url(url);

	g_strfreev(arr);
}
Beispiel #6
0
void lcrt_help_on_home_page_activate(GtkMenuItem * menuitem, gpointer user_data)
{
    struct lcrt_help *lhelp = (struct lcrt_help *)user_data;
    open_url(GTK_WINDOW(lhelp->parent->parent->window), 
             "http://code.google.com/p/lcrt", 
             gtk_get_current_event_time(), NULL);
}
Beispiel #7
0
static int query_repository(char **keywords, char *repo) {
  char url[STRLEN];
  FILE *f;
  struct pkgdb db;
  struct pkg *pkg;

  snprintf(url, sizeof(url), "%s/db", repo);
  f = open_url(url, "pkg");
  if (!f) return 1;

  memset(&db, 0, sizeof(struct pkgdb));
  read_pkgdb_from_file(f, &db);
  fclose(f);

  for (pkg = db.head; pkg; pkg = pkg->next) {
    int match = 0;
    if (*keywords) {
      char **k = keywords;
      while (*k) {
        match = strstr(pkg->name, *k) != NULL || strstr(pkg->description, *k) != NULL;
        if (match) break;
        k++;
      }
    } else {
      match = 1;
    }
    if (match) printf("%-15s %s\n", pkg->name, pkg->description);
  }
  delete_pkgdb(&db);

  return 0;
}
Beispiel #8
0
void OpenURL (const char *url)
{
	// let's put a little comment
	globalOutputStream() << "OpenURL: " << url << "\n";
	if (!open_url(url)) {
		gtkutil::errorDialog(_("Failed to launch browser!"));
	}
}
Beispiel #9
0
void OpenURL(const char *url)
{
    // let's put a little comment
    globalOutputStream() << "OpenURL: " << url << "\n";
    if(!open_url(url))
    {
        gtk_MessageBox(GTK_WIDGET(MainFrame_getWindow()), "Failed to launch browser!");
    }
}
Beispiel #10
0
void lcrt_help_on_download_page_activate(GtkMenuItem * menuitem, gpointer user_data)
{
#if 0
    struct lcrt_help *lhelp = (struct lcrt_help *)user_data;
    open_url(GTK_WINDOW(lhelp->parent->parent->window), 
             "http://code.google.com/p/lcrt/downloads/list", 
             gtk_get_current_event_time(), NULL);
#else
    gtk_timeout_add(1, lcrt_help_check_update, user_data);
#endif
}
Beispiel #11
0
static int open_input(struct variant *var)
{
    struct segment *seg = var->segments[var->cur_seq_no - var->start_seq_no];
    if (seg->key_type == KEY_NONE) {
        return  open_url(var->parent->priv_data, &var->input, seg->url);
    } else if (seg->key_type == KEY_AES_128) {
        HLSContext *c = var->parent->priv_data;
        char iv[33], key[33], url[MAX_URL_SIZE];
        int ret;
        if (strcmp(seg->key, var->key_url)) {
            URLContext *uc;
            if (open_url(var->parent->priv_data, &uc, seg->key) == 0) {
                if (ffurl_read_complete(uc, var->key, sizeof(var->key))
                    != sizeof(var->key)) {
                    av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
                           seg->key);
                }
                ffurl_close(uc);
            } else {
                av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n",
                       seg->key);
            }
            av_strlcpy(var->key_url, seg->key, sizeof(var->key_url));
        }
        ff_data_to_hex(iv, seg->iv, sizeof(seg->iv), 0);
        ff_data_to_hex(key, var->key, sizeof(var->key), 0);
        iv[32] = key[32] = '\0';
        if (strstr(seg->url, "://"))
            snprintf(url, sizeof(url), "crypto+%s", seg->url);
        else
            snprintf(url, sizeof(url), "crypto:%s", seg->url);
        if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ,
                               &var->parent->interrupt_callback)) < 0)
            return ret;
        av_opt_set(var->input->priv_data, "key", key, 0);
        av_opt_set(var->input->priv_data, "iv", iv, 0);

        return url_connect(var, c->avio_opts);
    }
    return AVERROR(ENOSYS);
}
Beispiel #12
0
static void
directory_pressed (GtkEntry       *entry,
		gint            position,
		GdkEventButton *event,
		gchar *file)
{
	if (position == GTK_ENTRY_ICON_SECONDARY && file) {
		gchar *uri = get_display_filename(file, TRUE);
		open_url(NULL, uri);
		g_free(uri);
	}
}
Beispiel #13
0
static gboolean report_generate(ReportDialog * rd)
{
    GSList *modules;
    ReportContext *ctx;
    ReportContext *(*create_context) ();
    gchar *file;
    FILE *stream;

    if (!(file = report_get_filename()))
        return FALSE;

    if (!(stream = fopen(file, "w+"))) {
        g_free(file);
        return FALSE;
    }

    create_context = file_types_get_data_by_name(file_types, file);

    if (!create_context) {
        g_warning("Cannot create ReportContext. Programming bug?");
        g_free(file);
        return FALSE;
    }

    ctx = create_context();
    modules = report_create_module_list_from_dialog(rd);

    report_create_from_module_list(ctx, modules);
    fputs(ctx->output, stream);
    fclose(stream);

    if (ctx->format == REPORT_FORMAT_HTML) {
        GtkWidget *dialog;
        dialog = gtk_message_dialog_new(NULL,
                                        GTK_DIALOG_DESTROY_WITH_PARENT,
                                        GTK_MESSAGE_QUESTION,
                                        GTK_BUTTONS_NONE,
                                        "Open the report with your web browser?");
        gtk_dialog_add_buttons(GTK_DIALOG(dialog),
                               GTK_STOCK_NO, GTK_RESPONSE_REJECT,
                               GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
        if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
            open_url(file);

        gtk_widget_destroy(dialog);
    }

    report_context_free(ctx);
    g_free(file);

    return TRUE;
}
Beispiel #14
0
static gboolean new_version_available_message ( new_version_thread_data *nvtd )
{
	// Only a simple goto website option is offered
	// Trying to do an installation update is platform specific
	if ( a_dialog_yes_or_no ( nvtd->window,
	                        _("There is a newer version of Viking available: %s\n\nDo you wish to go to Viking's website now?"), nvtd->version ) )
		// NB 'VIKING_URL' redirects to the Wiki, here we want to go the main site.
		open_url ( nvtd->window, "http://sourceforge.net/projects/viking/" );

	g_free ( nvtd->version );
	g_free ( nvtd );
	return FALSE;
}
void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url)
{
    if (isInitialized()) {
        QByteArray data = url.toString().toUtf8();

        static const int chunkSize = 128;
        while (!data.isEmpty()) {
            QByteArray chunk = data.left(chunkSize);
            data = data.mid(chunkSize);
            open_url(!data.isEmpty(), QString::fromUtf8(chunk));
        }
    }
}
Beispiel #16
0
int ffmpegWrap::run_once(bool retry)
{
    if (!ic_) {
        if (open_url() < 0) {
            return RC_FAILURE;
        }
    }

    int rc = next_frame();
    if (rc < 0 && retry) {
        avformat_close_input(&ic_);
        ic_ = 0;
        if (open_url() < 0) {
            return RC_FAILURE;
        }

        return next_frame();
    }
    else {
        return rc;
    }
}
Beispiel #17
0
static void
popup_menu_open_folder (GtkMenuItem *menuitem, gpointer storage)
{
	GtkWidget *entry_file;
	const gchar *file;
	gchar *uri;

	entry_file = g_object_get_data (storage, "entry_file");
	struct con_win *cwin = g_object_get_data (storage, "cwin");

	file = gtk_entry_get_text (GTK_ENTRY(entry_file));
	uri = get_display_filename (file, TRUE);

	open_url (cwin, uri);
	g_free (uri);
}
Beispiel #18
0
void
house::_connect_signals() {
    connect(_action_quit,   SIGNAL(triggered()), app(), SLOT(quit()));
    connect(_msg_field,     SIGNAL(returnPressed()), this, SLOT(send_message()));
    connect(_action_cancel, SIGNAL(triggered()), this, SLOT(interrupt()));

    connect(_action_chatting,     SIGNAL(triggered()), this, SLOT(change_user_status_to_chatting()));
    connect(_action_away,         SIGNAL(triggered()), this, SLOT(change_user_status_to_away()));
    connect(_action_playing,      SIGNAL(triggered()), this, SLOT(change_user_status_to_playing()));
    connect(_action_donotdisturb, SIGNAL(triggered()), this, SLOT(change_user_status_to_dont_disturb()));

    connect(_action_create_room, SIGNAL(triggered()), this, SLOT(room_create()));
    connect(_action_join_room,   SIGNAL(triggered()), this, SLOT(room_join_selected()));
    connect(_action_refresh,     SIGNAL(triggered()), this, SLOT(refresh()));

    connect(_action_settings,  SIGNAL(triggered()), this, SLOT(open_settings()));

    _menu_comp->addAction(_action_rvr_1vs1);
    _menu_comp->addAction(_action_rvr_player_profiles);

    connect(_action_about_rvh, SIGNAL(triggered()), this, SLOT(open_about()));
    connect(_rooms_view,       SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(room_join_selected(QTreeWidgetItem *, int)));
    connect(_users_view,       SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(open_private_room(QTreeWidgetItem *, int)));

    QSignalMapper *openUrlSignalMapper = new QSignalMapper(this);
    openUrlSignalMapper->setMapping(_action_rvr_wwwsite,         conf()->get_value("www/rvr_home").c_str());
    openUrlSignalMapper->setMapping(_action_rvr_1vs1,            conf()->get_value("www/rvr_1vs1").c_str());
    openUrlSignalMapper->setMapping(_action_rvr_player_profiles, conf()->get_value("www/rvr_players").c_str());

    openUrlSignalMapper->setMapping(_action_routerfw_help,   conf()->get_value("www/help_router").c_str());
    openUrlSignalMapper->setMapping(_action_connection_help, conf()->get_value("www/help_connection").c_str());
    openUrlSignalMapper->setMapping(_action_rvh_faq,         conf()->get_value("www/help_faq").c_str());

    connect(_action_rvr_wwwsite,         SIGNAL(triggered()), openUrlSignalMapper, SLOT(map()));
    connect(_action_rvr_1vs1,            SIGNAL(triggered()), openUrlSignalMapper, SLOT(map()));
    connect(_action_rvr_player_profiles, SIGNAL(triggered()), openUrlSignalMapper, SLOT(map()));

    connect(_action_routerfw_help,   SIGNAL(triggered()), openUrlSignalMapper, SLOT(map()));
    connect(_action_connection_help, SIGNAL(triggered()), openUrlSignalMapper, SLOT(map()));
    connect(_action_rvh_faq,         SIGNAL(triggered()), openUrlSignalMapper, SLOT(map()));

    connect(openUrlSignalMapper, SIGNAL(mapped(QString)), this, SLOT(open_url(QString)));

}
Beispiel #19
0
/* open_link(link):
 *
 * Will format a link from the current web pages so that it suits the
 * open_url() function and finally call it to open the requested URL.
 */
static void
open_link(char *link)
{
  char *urlptr;
    
  if(strncmp(link, http_http, 7) == 0) {
    /* The link starts with http://. We just copy the contents of the
       link into the url string and jump away. */
    strncpy(url, link, WWW_CONF_MAX_URLLEN);
  } else if(*link == ISO_slash &&
	    *(link + 1) == ISO_slash) {
    /* The link starts with //, so we'll copy it into the url
       variable, starting after the http (which already is present in
       the url variable since we were able to open the web page on
       which this link was found in the first place). */
    strncpy(&url[5], link, WWW_CONF_MAX_URLLEN);
  } else if(*link == ISO_slash) {
    /* The link starts with a slash, so it is a non-relative link
       within the same web site. We find the start of the filename of
       the current URL and paste the contents of this link there, and
       head off to the new URL. */
    for(urlptr = &url[7];
	*urlptr != 0 && *urlptr != ISO_slash;
	++urlptr);
    strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
  } else {
    /* A fully relative link is found. We find the last slash in the
       current URL and paste the link there. */
    
    /* XXX: we should really parse any ../ in the link as well. */
    for(urlptr = url + strlen(url);
	urlptr != url && *urlptr != ISO_slash;
	--urlptr);
    ++urlptr;
    strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
  }

  /* Open the URL. */
  show_url();
  open_url();

  start_loading();
}
Beispiel #20
0
Resource get_resource(const char* url){
    char pack[1024]={0};
    char buf[1024]={0};
    char redirect[256]={0},new_url[256]={0},old_url[256]={0};
    static int redirect_count=0;
    char* i;
    char* j;
    char* z;
    Resource res;
    Connection conn=open_url(url);
    if(!conn.avaliable){
        return res;
    }
    sprintf(pack,"GET %s HTTP/1.1\nHost: %s\nAccept: */*\nReferer: http://%s\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)\nPragma: no-cache\nCache-Control: no-cache\nConnection: close\n\n",conn.url_info.file,conn.url_info.host_name,conn.url_info.host_name);
    send(conn.sock,pack,strlen(pack),0);
    recv(conn.sock,buf,sizeof(buf),0);
    //printf("%s\n",buf);
    if(strstr(buf,"HTTP/1.1 404")!=NULL || strstr(buf,"HTTP/1.0 404")!=NULL){
       return res;
    }
    i=(char *)strstr(buf,"Location:");
    if(i!=NULL && redirect_count<5){
        sscanf(i,"Location: %s",redirect);
        sprintf(old_url,"%s://%s:%d%s",conn.url_info.schema,conn.url_info.host_name,conn.url_info.port,conn.url_info.file);
        join_url(old_url,redirect,new_url);
        //printf("@#%s\n",new_url);
        redirect_count++;
        return get_resource(new_url);
    }
    i=(char *)strstr(buf,"Content-Length:");
    if(i!=NULL){
        sscanf(i,"Content-Length: %d",&res.file_size);
    }
    strcpy(res.file_url,url);
    //printf("#%d\n",res.file_size);
    for(z=(char*)url;(j=strstr(z,"/"))!=NULL;){
        z=j+sizeof(char);
    }
    strcpy(res.file_name,z);
    close(conn.sock);
    return res;
}
Beispiel #21
0
static gboolean mouse_click_callback(GtkWidget *text_view,
	GdkEventButton *event)
{
	gint x, y;
	gchar *url = NULL;

	if (event->type != GDK_2BUTTON_PRESS)
		return FALSE;

	gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text_view),
		GTK_TEXT_WINDOW_WIDGET, event->x, event->y, &x, &y);

	get_url_at_location(&url, GTK_TEXT_VIEW(text_view), x, y);

	if (url != NULL) {
		open_url(text_view, url);
	}

	return TRUE;
}
Beispiel #22
0
BoolType init_kanamap(const char *libdir, const char *key_type)
{
	FILEsIO	*fp;
	unsigned char	buf[KMAXLEN];
	int	i, cc;
	kanachar k0, kv;
	static int	alreadyused = 0;
	StrType mapfile;

	if (alreadyused)
		return TRUE;
	for (i = 0; i < 256; i++)
		kanamap[i] = kchars[s_sp];
	if (isHttp) {
		sprintf(mapfile, "%s/%s.map", libdir, key_type);
		fp = open_url(mapfile);
	}else {
		sprintf(mapfile, "%s%c%s.map", libdir, DELIM, key_type);
		fp = makeFilesio( fopen(mapfile, "r") );
	}
	if (fp == NULL)
		return FALSE;
	while (iogets((char *)buf, KMAXLEN, fp) != NULL) {
		if ((cc = buf[0]) <= ' ') continue;
		for (i = 1; buf[i] == ' ' || buf[i] == '\t'; i++)
			;
		k0 = buf[i++] & 0xff;
		kv = (k0 << 8) | (buf[i++] & 0xff);
#if (KANA_CODE == UTF_8)
		if (k0 >= 0xe0) {
			kv = (kv << 8) | (buf[i++] & 0xff);
			if (k0 > 0xef)
				kv = (kv << 8) | (buf[i++] & 0xff);
		}
#endif
		kanamap[cc] = kv;
	}
	alreadyused = 1;
	ioclose(fp);
	return TRUE;
}
Beispiel #23
0
static int retrieve_package_timestamps(struct pkgdb *db, char *repo) {
  char url[STRLEN];
  FILE *f;
  struct pkgdb rdb;
  struct pkg *pkg;
  struct pkg *rpkg;

  snprintf(url, sizeof(url), "%s/db", repo);
  f = open_url(url, "pkg");
  if (!f) return 1;

  memset(&rdb, 0, sizeof(struct pkgdb));
  read_pkgdb_from_file(f, &rdb);
  fclose(f);

  for (pkg = db->head; pkg; pkg = pkg->next) {
    rpkg = find_package(&rdb, pkg->name);
    if (rpkg) pkg->avail = rpkg->time;
  }
  delete_pkgdb(&rdb);
  return 0;
}
Beispiel #24
0
void library_view_search_cover_art(GtkMenuItem* item, GObject* lview)
{
  library_view_t* view = (library_view_t*) g_object_get_data(lview, "library_view_t");

  GtkTreeSelection* sel = gtk_tree_view_get_selection(view->tview);
  GtkTreeModel* model;
  GtkTreeIter iter;

  if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
    int row = gtk_list_model_iter_to_row(GTK_LIST_MODEL(model), iter);
    track_t* track = playlist_model_get_track(view->playlist_model, row);

    char s[10240];
    strcpy(s, "https://www.google.nl/search?tbm=isch&q=%s");
    char url[20480];
    char query[10240];
  
    sprintf(query,"%s+%s",track_get_artist(track), track_get_album_title(track));
    char* q = to_http_get_query(query);
  
    sprintf(url, s, q);
    open_url(GTK_WIDGET(item), url);
    
    mc_free(q);
  } else {
    GtkMessageDialog* dialog = GTK_MESSAGE_DIALOG(
                                gtk_message_dialog_new(btb_main_window(view->btb),
                                                       GTK_DIALOG_DESTROY_WITH_PARENT,
                                                       GTK_MESSAGE_ERROR,
                                                       GTK_BUTTONS_CLOSE,
                                                       _("Please select a track to set the cover art for")
                                                       )
                                );
    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (GTK_WIDGET(dialog));        
  }
  
}
Beispiel #25
0
/**
 * Display a dialog presenting the license of a map.
 * Allow to read the license by launching a web browser.
 */
void a_dialog_license ( GtkWindow *parent, const gchar *map, const gchar *license, const gchar *url)
{
  GtkWidget *dialog = gtk_message_dialog_new (parent,
                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                 GTK_MESSAGE_INFO,
                                 GTK_BUTTONS_OK,
                                 _("The map data is licensed: %s."),
                                 license);
  gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
    _("The data provided by '<b>%s</b>' are licensed under the following license: <b>%s</b>."),
    map, license);
#define RESPONSE_OPEN_LICENSE 600
  if (url != NULL) {
    gtk_dialog_add_button (GTK_DIALOG (dialog), _("Open license"), RESPONSE_OPEN_LICENSE);
  }
  gint response;
  do {
    response = gtk_dialog_run (GTK_DIALOG (dialog));
    if (response == RESPONSE_OPEN_LICENSE) {
      open_url (parent, url);
    }
  } while (response != GTK_RESPONSE_DELETE_EVENT && response != GTK_RESPONSE_OK);
  gtk_widget_destroy (dialog);
}
Beispiel #26
0
void lcrt_help_show_help(const char *topic, struct lcrt_help *lhelp)
{
    char *uri = NULL, *url;
    int i;
    char help_path[3][256];
    char language[32], *p;

    strcpy(language, basename((char *)lcrt_config_get_language()));
    p = strchr(language, '.');
    if (p)
        *p = '\0';

    snprintf(help_path[0], 256, LCRT_HELP_DIR"/%s/lcrt.xml", language);
    snprintf(help_path[1], 256, "%s/help/%s/lcrt.xml", getenv("PWD"), language);
    snprintf(help_path[2], 256, "%s/../help/%s/lcrt.xml", getenv("PWD"), language);
    for (i = 0; i < 3; i++) {
        if (access(help_path[i], F_OK | R_OK) == 0) {
            uri = help_path[i];
            break;
        }
    }
    if (uri == NULL) {
        lcrt_message_error(lhelp->parent->parent->window,
                           lhelp->config.value[LCRT_H_MISSING_DOC]);
        return;
    }
    if (topic) {
        url = g_strdup_printf("ghelp://%s?%s", uri, topic);
    } else {
        url = g_strdup_printf("ghelp://%s", uri);
    }

    open_url(GTK_WINDOW(lhelp->parent->parent->window), url, gtk_get_current_event_time(), NULL);

    g_free(url);
}
Beispiel #27
0
BoolType find_lesson(const char *name)
/* locate given lesson, leave lesson_file open so next line begins */
{
    StrType fullName;
    StrType current_line;
    char slash;
    FILEsIO *lesson_file;
    size_t linesInLesson;
    int idx, lng, kind;

    if ((idx = check_lesson_name(name)) < 0) {
	stand_out(BOLD);
#ifdef JPN
	add_fmt("\n \"%s\" というレッスンはありません.\n", name);
#else
	add_fmt("\n %s: No such Lesson.\n", name);
#endif
	stand_end(BOLD);
	(void) wait_user();
	return FALSE;
    }
    /* gf: Added LessonDir */
    slash = isHttp ? '/' : DELIM;
    if (typeLessons[idx].path == NULL)
	sprintf(fullName, "%s%c%c.typ", LessonDir, slash, name[0]);
    else
	sprintf(fullName, "%s%c%s.typ",
			LessonDir, slash, typeLessons[idx].path);
    lesson_file = isHttp ? open_url(fullName)
		: makeFilesio( fopen(fullName, "r") );
    if (lesson_file == NULL) {
	stand_out(BOLD);
	add_fmt("OPEN ERROR: %s (errno=%d)\n", fullName, errno);
	stand_end(BOLD);
	(void) wait_user();
	return FALSE;
    }

    if (!seek_lesson(lesson_file, name))
	goto ERR_EXIT;

    /* clear previous lesson */
    clear_dictionary();
    clear_cache();
    linesInLesson = 0;
    while ((lng = get_lesson_line(lesson_file, current_line)) >= 0) {
	/* Loop ends if EOF or End of Lesson */
	kind = 0;
	if (lng >= 2 && current_line[lng - 2] == '\\') { /* expected terminator */
	    kind = current_line[lng - 1];
	    current_line[lng -= 2] = '\0'; /* remove */
	}
	if (lng == 0)
	    cached_lines[linesInLesson] = empty;
	else {
	    char *pp = (char *)malloc(lng + 1);
	    if (pp == NULL) {
		fprintf(stderr, "SYSTEM ERROR: malloc() failure\n");
		cleanup(1);
	    }
	    strcpy(pp, current_line);
	    cached_lines[linesInLesson] = pp;
	}
	cached_attr[linesInLesson] = kind;
	if (++linesInLesson >= cacheCapacity - 1)
	    increse_cache();
    }
    /* The next of the last line, cached_lines[linesInLesson] should be NULL */

    ioclose(lesson_file);
    return TRUE;

ERR_EXIT:
	stand_out(BOLD);
#ifdef JPN
	add_fmt("レッスン%s は利用できません.\n", &name[1]);
#else
	add_fmt("Lesson %s is not available.\n", &name[1]);
#endif
	stand_end(BOLD);

	(void) wait_user();
	ioclose(lesson_file);
	return FALSE;
}
Beispiel #28
0
int main(){
  open_url("www.bing.com");
}
Beispiel #29
0
void cb_donate()
{
    open_url("http://wiki.hardinfo.org/Donate");
}
Beispiel #30
0
void cb_report_bug()
{
    open_url("http://wiki.hardinfo.org/BugReports");
}