SBCLでコマンドラインからLispコードを実行するには、--scriptオプションを使って以下のようにします。
$ sbcl --script hello.lisp同じようにして、コンパイルしたコードも実行できます。
$ sbcl --script hello.fasl
--
$ sbcl --script hello.lisp同じようにして、コンパイルしたコードも実行できます。
$ sbcl --script hello.fasl
$ port install OpenSSL次に、サンプルをビルドします。
$ ./configure --with-openssl=/opt/local/ $ makeMacPortを使ってOpenSSLをインストールしたため、そのインストール場所を--with-opensslオプションによって指定しています。
$ ./wclient -h twitter.com -p 443 -i今度は、GnuTLSを使った場合と違い、すんなりとHTMLを取得できました。
$ port install gnutls他の環境でもパッケージシステムから同様にインストールできると思います。
/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
/* A very basic TLS client, with anonymous authentication.
*/
#define MAX_BUF 1024
#define MSG "GET / HTTP/1.0\r\n\r\n"
extern int tcp_connect (void);
extern void tcp_close (int sd);
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_anon_client_credentials_t anoncred;
/* Need to enable anonymous KX specifically. */
gnutls_global_init ();
gnutls_anon_allocate_client_credentials (&anoncred);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_priority_set_direct (session, "PERFORMANCE:+ANON-DH:!ARCFOUR-128",
NULL);
/* put the anonymous credentials to the current session
*/
gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
/* connect to the peer
*/
sd = tcp_connect ();
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* Perform the TLS handshake
*/
ret = gnutls_handshake (session);
if (ret < 0)
{
fprintf (stderr, "*** Handshake failed\n");
gnutls_perror (ret);
goto end;
}
else
{
printf ("- Handshake was completed\n");
}
gnutls_record_send (session, MSG, strlen (MSG));
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("- Peer has closed the TLS connection\n");
goto end;
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
gnutls_bye (session, GNUTLS_SHUT_RDWR);
end:
tcp_close (sd);
gnutls_deinit (session);
gnutls_anon_free_client_credentials (anoncred);
gnutls_global_deinit ();
return 0;
}/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#define SA struct sockaddr
/* tcp.c */
int tcp_connect (void);
void tcp_close (int sd);
/* Connects to the peer and returns a socket
* descriptor.
*/
extern int
tcp_connect (void)
{
const char *PORT = "5556";
const char *SERVER = "127.0.0.1";
int err, sd;
struct sockaddr_in sa;
/* connects to server
*/
sd = socket (AF_INET, SOCK_STREAM, 0);
memset (&sa, '\0', sizeof (sa));
sa.sin_family = AF_INET;
sa.sin_port = htons (atoi (PORT));
inet_pton (AF_INET, SERVER, &sa.sin_addr);
err = connect (sd, (SA *) & sa, sizeof (sa));
if (err < 0)
{
fprintf (stderr, "Connect error\n");
exit (1);
}
return sd;
}
/* closes the given socket descriptor.
*/
extern void
tcp_close (int sd)
{
shutdown (sd, SHUT_RDWR); /* no more receptions */
close (sd);
}※IP、ポートは適切に変更してくださいsample: sample.o helper.o gcc -o sample sample.o helper.o `pkg-config gnutls --libs` .c.o: gcc -c $< -I/opt/local/include
$ make $ ./sample *** Handshake failed GNUTLS ERROR: A TLS fatal alert has been received.
/usr/local/bin/pythonのようにフルパスでpythonコマンドを指定しなければいけない。
C[i] = A[i] + B[i]
$ sed -e "s/置換したい文字列/置換後の文字列/g" ファイル名
$ sed -e "s/置換したい文字列/置換後の文字列/g" ファイル名 > 保存先ファイル名
$ sed -i.bak -e "s/置換したい文字列/置換後の文字列/g" ファイル名
$ sed -i.bak -e "s/置換したい文字列/置換後の文字列/g" *
$ sed -f コマンドファイル名 編集対象ファイル名
挿入したい行(何番目の行か){
i\
挿入したい文字列
}
10{とすると、10行目の手前、つまり9行目と10行目の間に「この文字列を挿入します。」という文字列が挿入されます。
i\
この文字列を挿入します。
}
data RealFloat a => Complex a = !a +: !a実部と虚部に正格フラグが付けられており、これらのフィールドには評価後の値が保持される。
$ svn propget svn:mime-type hoge.texこれはmime-typeがapplication/octet-streamになってしまっていることを表しています。
application/octet-stream
$ svn propset svn:mime-type text/x-tex hoge.txtさらに文字コードを指定したい場合は svn:mime-type 'text/plain; charset=euc-jp' などとすればよいです。
$ または svn propdel svn:mime-type hoge.txt
$ svn commit -m ''