summaryrefslogtreecommitdiff
path: root/epan/wslua
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-06-17 16:32:04 +0000
committerGuy Harris <guy@alum.mit.edu>2012-06-17 16:32:04 +0000
commit4ad0bf65f2ebecf1b501ba7733063d9c0f8e3f1d (patch)
tree0c03124b7138a7f3a152a6ba09d3af97690fa4ab /epan/wslua
parent28e925a381d428ca1ae475a28e021235dc5a8cf6 (diff)
downloadwireshark-4ad0bf65f2ebecf1b501ba7733063d9c0f8e3f1d.tar.gz
Clean up indentation.
svn path=/trunk/; revision=43314
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/wslua_dumper.c170
1 files changed, 85 insertions, 85 deletions
diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c
index f228e136aa..77d9d7fef7 100644
--- a/epan/wslua/wslua_dumper.c
+++ b/epan/wslua/wslua_dumper.c
@@ -62,10 +62,10 @@ struct lua_pseudo_header {
};
WSLUA_CONSTRUCTOR PseudoHeader_none(lua_State* L) {
- /*
- Creates a "no" pseudoheader.
+ /*
+ Creates a "no" pseudoheader.
- */
+ */
PseudoHeader ph = g_malloc(sizeof(struct lua_pseudo_header));
ph->type = PHDR_NONE;
ph->wph = NULL;
@@ -73,13 +73,13 @@ WSLUA_CONSTRUCTOR PseudoHeader_none(lua_State* L) {
pushPseudoHeader(L,ph);
WSLUA_RETURN(1);
- /* A null pseudoheader */
+ /* A null pseudoheader */
}
WSLUA_CONSTRUCTOR PseudoHeader_eth(lua_State* L) {
- /*
- Creates an ethernet pseudoheader
- */
+ /*
+ Creates an ethernet pseudoheader
+ */
#define WSLUA_OPTARG_PseudoHeader_eth_FCSLEN 1 /* The fcs length */
@@ -90,13 +90,13 @@ WSLUA_CONSTRUCTOR PseudoHeader_eth(lua_State* L) {
pushPseudoHeader(L,ph);
- WSLUA_RETURN(1); /* The ethernet pseudoheader */
+ WSLUA_RETURN(1); /* The ethernet pseudoheader */
}
WSLUA_CONSTRUCTOR PseudoHeader_atm(lua_State* L) {
- /*
- Creates an ATM pseudoheader
- */
+ /*
+ Creates an ATM pseudoheader
+ */
#define WSLUA_OPTARG_PseudoHeader_atm_AAL 1 /* AAL number */
#define WSLUA_OPTARG_PseudoHeader_atm_VPI 2 /* VPI */
#define WSLUA_OPTARG_PseudoHeader_atm_VCI 3 /* VCI */
@@ -117,12 +117,12 @@ WSLUA_CONSTRUCTOR PseudoHeader_atm(lua_State* L) {
ph->wph->atm.aal5t_len = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_atm_AAL5LEN,0);
pushPseudoHeader(L,ph);
- WSLUA_RETURN(1);
- /* The ATM pseudoheader */
+ WSLUA_RETURN(1);
+ /* The ATM pseudoheader */
}
WSLUA_CONSTRUCTOR PseudoHeader_mtp2(lua_State* L) {
- /* Creates an MTP2 PseudoHeader */
+ /* Creates an MTP2 PseudoHeader */
#define WSLUA_OPTARG_PseudoHeader_mtp2_SENT 1 /* True if the packet is sent, False if received. */
#define WSLUA_OPTARG_PseudoHeader_mtp2_ANNEXA 2 /* True if annex A is used */
#define WSLUA_OPTARG_PseudoHeader_mtp2_LINKNUM 3 /* Link Number */
@@ -134,7 +134,7 @@ WSLUA_CONSTRUCTOR PseudoHeader_mtp2(lua_State* L) {
ph->wph->mtp2.link_number = luaL_optint(L,WSLUA_OPTARG_PseudoHeader_mtp2_LINKNUM,0);
pushPseudoHeader(L,ph);
- WSLUA_RETURN(1); /* The MTP2 pseudoheader */
+ WSLUA_RETURN(1); /* The MTP2 pseudoheader */
}
#if 0
@@ -149,19 +149,19 @@ static int PseudoHeader_k12(lua_State* L) { luaL_error(L,"not implemented"); ret
#endif
WSLUA_METHODS PseudoHeader_methods[] = {
- WSLUA_CLASS_FNREG(PseudoHeader,mtp2),
- WSLUA_CLASS_FNREG(PseudoHeader,atm),
- WSLUA_CLASS_FNREG(PseudoHeader,eth),
- WSLUA_CLASS_FNREG(PseudoHeader,none),
- {0,0}
+ WSLUA_CLASS_FNREG(PseudoHeader,mtp2),
+ WSLUA_CLASS_FNREG(PseudoHeader,atm),
+ WSLUA_CLASS_FNREG(PseudoHeader,eth),
+ WSLUA_CLASS_FNREG(PseudoHeader,none),
+ {0,0}
};
WSLUA_META PseudoHeader_meta[] = {
- {0,0}
+ {0,0}
};
int PseudoHeader_register(lua_State* L) {
- WSLUA_REGISTER_CLASS(PseudoHeader)
+ WSLUA_REGISTER_CLASS(PseudoHeader)
return 0;
}
@@ -172,30 +172,30 @@ static GHashTable* dumper_encaps = NULL;
#define DUMPER_ENCAP(d) GPOINTER_TO_INT(g_hash_table_lookup(dumper_encaps,d))
static const char* cross_plat_fname(const char* fname) {
- static char fname_clean[256];
- char* f;
-
- g_strlcpy(fname_clean,fname,255);
- fname_clean[255] = '\0';
-
- for(f = fname_clean; *f; f++) {
- switch(*f) {
- case '/': case '\\':
- *f = *(G_DIR_SEPARATOR_S);
- break;
- default:
- break;
- }
- }
-
- return fname_clean;
+ static char fname_clean[256];
+ char* f;
+
+ g_strlcpy(fname_clean,fname,255);
+ fname_clean[255] = '\0';
+
+ for(f = fname_clean; *f; f++) {
+ switch(*f) {
+ case '/': case '\\':
+ *f = *(G_DIR_SEPARATOR_S);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return fname_clean;
}
WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
- /*
- Creates a file to write packets.
- Dumper:new_for_current() will probably be a better choice.
- */
+ /*
+ Creates a file to write packets.
+ Dumper:new_for_current() will probably be a better choice.
+ */
#define WSLUA_ARG_Dumper_new_FILENAME 1 /* The name of the capture file to be created */
#define WSLUA_OPTARG_Dumper_new_FILETYPE 2 /* The type of the file to be created */
#define WSLUA_OPTARG_Dumper_new_ENCAP 3 /* The encapsulation to be used in the file to be created */
@@ -208,7 +208,7 @@ WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
if (! fname) return 0;
- filename = cross_plat_fname(fname);
+ filename = cross_plat_fname(fname);
if (!wtap_dump_can_write_encap(filetype, encap))
WSLUA_ERROR(Dumper_new,"Not every filetype handles every encap");
@@ -216,7 +216,7 @@ WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
d = wtap_dump_open(filename, filetype, encap,0 , FALSE, &err);
if (! d ) {
- /* WSLUA_ERROR("Error while opening file for writing"); */
+ /* WSLUA_ERROR("Error while opening file for writing"); */
luaL_error(L,"error while opening `%s': %s",
filename,
wtap_strerror(err));
@@ -227,16 +227,16 @@ WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
pushDumper(L,d);
WSLUA_RETURN(1);
- /* The newly created Dumper object */
+ /* The newly created Dumper object */
}
WSLUA_METHOD Dumper_close(lua_State* L) {
- /* Closes a dumper */
- Dumper* dp = (Dumper*)luaL_checkudata(L, 1, "Dumper");
+ /* Closes a dumper */
+ Dumper* dp = (Dumper*)luaL_checkudata(L, 1, "Dumper");
int err;
if (! *dp)
- WSLUA_ERROR(Dumper_close,"Cannot operate on a closed dumper");
+ WSLUA_ERROR(Dumper_close,"Cannot operate on a closed dumper");
g_hash_table_remove(dumper_encaps,*dp);
@@ -245,16 +245,16 @@ WSLUA_METHOD Dumper_close(lua_State* L) {
wtap_strerror(err));
}
- /* this way if we close a dumper any attempt to use it (for everything but GC) will yield an error */
- *dp = NULL;
+ /* this way if we close a dumper any attempt to use it (for everything but GC) will yield an error */
+ *dp = NULL;
return 0;
}
WSLUA_METHOD Dumper_flush(lua_State* L) {
- /*
- Writes all unsaved data of a dumper to the disk.
- */
+ /*
+ Writes all unsaved data of a dumper to the disk.
+ */
Dumper d = checkDumper(L,1);
if (!d) return 0;
@@ -265,15 +265,15 @@ WSLUA_METHOD Dumper_flush(lua_State* L) {
}
WSLUA_METHOD Dumper_dump(lua_State* L) {
- /*
- Dumps an arbitrary packet.
- Note: Dumper:dump_current() will fit best in most cases.
- */
+ /*
+ Dumps an arbitrary packet.
+ Note: Dumper:dump_current() will fit best in most cases.
+ */
#define WSLUA_ARG_Dumper_dump_TIMESTAMP 2 /* The absolute timestamp the packet will have */
#define WSLUA_ARG_Dumper_dump_PSEUDOHEADER 3 /* The Pseudoheader to use. */
#define WSLUA_ARG_Dumper_dump_BYTEARRAY 4 /* the data to be saved */
- Dumper d = checkDumper(L,1);
+ Dumper d = checkDumper(L,1);
PseudoHeader ph;
ByteArray ba;
struct wtap_pkthdr pkthdr;
@@ -289,10 +289,10 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
ba = checkByteArray(L,WSLUA_ARG_Dumper_dump_BYTEARRAY);
- if (! ba) WSLUA_ARG_ERROR(Dumper_dump,BYTEARRAY,"must be a ByteArray");
+ if (! ba) WSLUA_ARG_ERROR(Dumper_dump,BYTEARRAY,"must be a ByteArray");
- pkthdr.ts.secs = (unsigned)floor(ts);
- pkthdr.ts.nsecs = (unsigned)floor((ts - (double)pkthdr.ts.secs) * 1000000000);
+ pkthdr.ts.secs = (unsigned)floor(ts);
+ pkthdr.ts.nsecs = (unsigned)floor((ts - (double)pkthdr.ts.secs) * 1000000000);
pkthdr.len = ba->len;
pkthdr.caplen = ba->len;
@@ -308,23 +308,23 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
}
WSLUA_METHOD Dumper_new_for_current(lua_State* L) {
- /*
- Creates a capture file using the same encapsulation as the one of the cuurrent packet
- */
+ /*
+ Creates a capture file using the same encapsulation as the one of the cuurrent packet
+ */
#define WSLUA_OPTARG_Dumper_new_for_current_FILETYPE 2 /* The file type. Defaults to pcap. */
- Dumper d;
+ Dumper d;
const char* fname = luaL_checkstring(L,1);
int filetype = luaL_optint(L,WSLUA_OPTARG_Dumper_new_for_current_FILETYPE,WTAP_FILE_PCAP);
int encap;
int err = 0;
- const char* filename;
+ const char* filename;
if (! fname) return 0;
- filename = cross_plat_fname(fname);
+ filename = cross_plat_fname(fname);
if (! lua_pinfo )
- WSLUA_ERROR(Dumper_new_for_current,"Cannot be used outside a tap or a dissector");
+ WSLUA_ERROR(Dumper_new_for_current,"Cannot be used outside a tap or a dissector");
encap = lua_pinfo->fd->lnk_t;
@@ -350,9 +350,9 @@ WSLUA_METHOD Dumper_new_for_current(lua_State* L) {
}
WSLUA_METHOD Dumper_dump_current(lua_State* L) {
- /*
- Dumps the current packet as it is.
- */
+ /*
+ Dumps the current packet as it is.
+ */
Dumper d = checkDumper(L,1);
struct wtap_pkthdr pkthdr;
const guchar* data;
@@ -362,7 +362,7 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
if (!d) return 0;
- if (! lua_pinfo ) WSLUA_ERROR(Dumper_new_for_current,"Cannot be used outside a tap or a dissector");
+ if (! lua_pinfo ) WSLUA_ERROR(Dumper_new_for_current,"Cannot be used outside a tap or a dissector");
data_src = (data_source*) (lua_pinfo->data_src->data);
if (!data_src)
@@ -387,22 +387,22 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
}
static int Dumper__gc(lua_State* L) {
- Dumper* dp = (Dumper*)luaL_checkudata(L, 1, "Dumper");
- int err;
+ Dumper* dp = (Dumper*)luaL_checkudata(L, 1, "Dumper");
+ int err;
- /* If we are Garbage Collected it means the Dumper is no longer usable. Close it */
+ /* If we are Garbage Collected it means the Dumper is no longer usable. Close it */
- if (! *dp)
- return 0; /* already closed, nothing to do! */
+ if (! *dp)
+ return 0; /* already closed, nothing to do! */
- g_hash_table_remove(dumper_encaps,*dp);
+ g_hash_table_remove(dumper_encaps,*dp);
- if (!wtap_dump_close(*dp, &err)) {
- luaL_error(L,"error closing: %s",
- wtap_strerror(err));
- }
+ if (!wtap_dump_close(*dp, &err)) {
+ luaL_error(L,"error closing: %s",
+ wtap_strerror(err));
+ }
- return 0;
+ return 0;
}
@@ -417,7 +417,7 @@ WSLUA_METHODS Dumper_methods[] = {
};
WSLUA_META Dumper_meta[] = {
- {"__gc", Dumper__gc},
+ {"__gc", Dumper__gc},
{0, 0}
};