summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--neols.c13
-rw-r--r--shared.h23
2 files changed, 6 insertions, 30 deletions
diff --git a/neols.c b/neols.c
index a288fee..01ce98c 100644
--- a/neols.c
+++ b/neols.c
@@ -1,11 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "shared.h"
 
-/* A majority of lines in files.json
-are less than 80 characters long. */
-#define GUESS 80
 /* Each informative line has 6 spaces,
 a quote, then the data type, then a quote,
 then a colon, then a space, then a quote,
@@ -97,15 +93,15 @@ main(int argc, char **argv)
 		else
 			dir = argv[i];
 	}
-	char *line;
+	char *line = NULL;
 	/* The various statistics related to each entry are stored,
 	one entry at a time. A path may be any size, so each line need
 	be handled by realloc. */
 	char *path = NULL, *updated_at = NULL, *sha1_hash = NULL;
 	int is_directory = 0, size = 0;
-	int end, len;
-	for (end = 0; ! end;) {
-		line = storeline(in, &end, &len, GUESS);
+	int len;
+	unsigned long line_size = 0;
+	while ((len = getline(&line, &line_size, in)) > 0) {
 		/* Only on lines terminating an entry, '}' is the
 		fifth character. The ninth character of each data
 		line is unique. */
@@ -143,6 +139,7 @@ main(int argc, char **argv)
 		} else if (line[8] == 'h') {
 			sha1_hash = line;
 		}
+		line = NULL;
 	}
 	return 0;
 }
diff --git a/shared.h b/shared.h
index b4232ae..740984d 100644
--- a/shared.h
+++ b/shared.h
@@ -1,22 +1 @@
-static char *
-storeline(FILE *in, int *end, int *len, int guess)
-{
-	static char *line;
-	line = calloc(guess, sizeof(char));
-	int i = 0, buflen = guess;
-	char ch;
-	while ((ch = fgetc(in)) != EOF && ch != '\n') {
-		if (i == buflen - 1) {
-			buflen += guess;
-			line = realloc(line, buflen * sizeof(char));
-		}
-		line[i] = ch;
-		++i;
-	}
-	line[i] = '\0';
-	*len = i;
-	if (ch == EOF)
-		*end = 1;
-
-	return line;
-}
+char *site = "https://kaa.neocities.org/";
t { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package ranger</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>ranger</strong></big></big> (version 1.0.4)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/__init__.py">/home/hut/ranger/ranger/__init__.py</a></font></td></tr></table>
    <p><tt>Ranger&nbsp;-&nbsp;file&nbsp;browser&nbsp;for&nbsp;the&nbsp;unix&nbsp;terminal</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="ranger.__main__.html">__main__</a><br>
<a href="ranger.api.html"><strong>api</strong>&nbsp;(package)</a><br>
<a href="ranger.colorschemes.html"><strong>colorschemes</strong>&nbsp;(package)</a><br>
</td><td width="25%" valign=top><a href="ranger.container.html"><strong>container</strong>&nbsp;(package)</a><br>
<a href="ranger.core.html"><strong>core</strong>&nbsp;(package)</a><br>
<a href="ranger.defaults.html"><strong>defaults</strong>&nbsp;(package)</a><br>
</td><td width="25%" valign=top><a href="ranger.ext.html"><strong>ext</strong>&nbsp;(package)</a><br>
<a href="ranger.fsobject.html"><strong>fsobject</strong>&nbsp;(package)</a><br>
<a href="ranger.gui.html"><strong>gui</strong>&nbsp;(package)</a><br>
</td><td width="25%" valign=top><a href="ranger.help.html"><strong>help</strong>&nbsp;(package)</a><br>
<a href="ranger.shared.html"><strong>shared</strong>&nbsp;(package)</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-log"><strong>log</strong></a>(*objects, **keywords)</dt><dd><tt>Writes&nbsp;objects&nbsp;to&nbsp;a&nbsp;logfile&nbsp;(for&nbsp;the&nbsp;purpose&nbsp;of&nbsp;debugging&nbsp;only.)<br>
Has&nbsp;the&nbsp;same&nbsp;arguments&nbsp;as&nbsp;print()&nbsp;in&nbsp;python3.</tt></dd></dl>
 <dl><dt><a name="-relpath"><strong>relpath</strong></a>(*paths)</dt><dd><tt>returns&nbsp;the&nbsp;path&nbsp;relative&nbsp;to&nbsp;rangers&nbsp;library&nbsp;directory</tt></dd></dl>
 <dl><dt><a name="-relpath_conf"><strong>relpath_conf</strong></a>(*paths)</dt><dd><tt>returns&nbsp;the&nbsp;path&nbsp;relative&nbsp;to&nbsp;rangers&nbsp;configuration&nbsp;directory</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>DEFAULT_CONFDIR</strong> = '~/.ranger'<br>
<strong>LOGFILE</strong> = '/tmp/errorlog'<br>
<strong>RANGERDIR</strong> = '/home/hut/ranger/ranger'<br>
<strong>USAGE</strong> = '%prog [options] [path/filename]'<br>
<strong>__author__</strong> = 'Roman Zimbelmann'<br>
<strong>__copyright__</strong> = '<font color="#c040c0">\n</font>Copyright (C) 2009, 2010  Roman Zimbelmann &lt;romanz@lavabit.com&gt;<font color="#c040c0">\n</font>'<br>
<strong>__credits__</strong> = 'Roman Zimbelmann'<br>
<strong>__email__</strong> = 'romanz@lavabit.com'<br>
<strong>__license__</strong> = 'GPL3'<br>
<strong>__maintainer__</strong> = 'Roman Zimbelmann'<br>
<strong>__version__</strong> = '1.0.4'<br>
<strong>arg</strong> = {'debug': False, 'flags': '', 'mode': 0, 'clean': False, 'confdir': '~/.ranger', 'targets': []}</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Roman&nbsp;Zimbelmann</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Roman&nbsp;Zimbelmann</td></tr></table>
</body></html>