# HG changeset patch # User Mark Doliner # Date 1070862064 0 # Node ID c86f075b269ac73ac5f802541ad968c804d608f4 # Parent 5f0bb52c06092cdf472a39621a6480f485cadb72 [gaim-migrate @ 8453] I modified some of the libfaim connection stuff. I dunno, it seems cleaner this way. I like to be comfortable with what's going on. It's possible that FT and DC won't work now (although, they should), but I'll get to making them suck less pretty soon. Also upgraded the Doxyfile to 1 version newer. It mostly just moved some things around, but also removed the CGI_BLEH lines from the end. committer: Tailor Script diff -r 5f0bb52c0609 -r c86f075b269a Doxyfile.in --- a/Doxyfile.in Mon Dec 08 04:58:07 2003 +0000 +++ b/Doxyfile.in Mon Dec 08 05:41:04 2003 +0000 @@ -1,4 +1,4 @@ -# Doxyfile 1.3.3 +# Doxyfile 1.3.4 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -11,7 +11,7 @@ # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- -# General configuration options +# Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded @@ -53,6 +53,135 @@ USE_WINDOWS_ENCODING = NO +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited +# members of a class in the documentation of that class as if those members were +# ordinary class members. Constructors, destructors and assignment operators of +# the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. It is allowed to use relative paths in the argument list. + +STRIP_FROM_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explict @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# reimplements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = "signal=- @ref" \ + signaldef=@section \ + endsignaldef= \ + signalproto=@code \ + endsignalproto=@endcode \ + "signaldesc=@par Description:\n" \ + "signals=@b Signals:\n" \ + endsignals= + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless @@ -105,46 +234,6 @@ HIDE_IN_BODY_DOCS = NO -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = - # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. @@ -160,12 +249,6 @@ CASE_SENSE_NAMES = YES -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. @@ -178,35 +261,6 @@ SHOW_INCLUDE_FILES = YES -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. @@ -219,18 +273,6 @@ SORT_MEMBER_DOCS = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. @@ -255,22 +297,6 @@ GENERATE_DEPRECATEDLIST= YES -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = "signal=- @ref" -ALIASES += "signaldef=@section" -ALIASES += "endsignaldef=" -ALIASES += "signalproto=@code" -ALIASES += "endsignalproto=@endcode" -ALIASES += "signaldesc=@par Description:\n" -ALIASES += "signals=@b Signals:\n" -ALIASES += "endsignals=" - # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. @@ -286,34 +312,12 @@ MAX_INITIALIZER_LINES = 30 -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -364,16 +368,18 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = src doc +INPUT = src \ + doc # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs +# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc -FILE_PATTERNS = *.h *.dox +FILE_PATTERNS = *.h \ + *.dox # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -498,7 +504,9 @@ # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = Gaim _Gaim gaim +IGNORE_PREFIX = Gaim \ + _Gaim \ + gaim #--------------------------------------------------------------------------- # configuration options related to the HTML output @@ -1079,38 +1087,3 @@ # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO - -# The CGI_NAME tag should be the name of the CGI script that -# starts the search engine (doxysearch) with the correct parameters. -# A script with this name will be generated by doxygen. - -CGI_NAME = search.cgi - -# The CGI_URL tag should be the absolute URL to the directory where the -# cgi binaries are located. See the documentation of your http daemon for -# details. - -CGI_URL = - -# The DOC_URL tag should be the absolute URL to the directory where the -# documentation is located. If left blank the absolute path to the -# documentation, with file:// prepended to it, will be used. - -DOC_URL = - -# The DOC_ABSPATH tag should be the absolute path to the directory where the -# documentation is located. If left blank the directory on the local machine -# will be used. - -DOC_ABSPATH = - -# The BIN_ABSPATH tag must point to the directory where the doxysearch binary -# is installed. - -BIN_ABSPATH = /usr/local/bin/ - -# The EXT_DOC_PATHS tag can be used to specify one or more paths to -# documentation generated for other projects. This allows doxysearch to search -# the documentation for these projects as well. - -EXT_DOC_PATHS = diff -r 5f0bb52c0609 -r c86f075b269a src/protocols/oscar/aim.h --- a/src/protocols/oscar/aim.h Mon Dec 08 04:58:07 2003 +0000 +++ b/src/protocols/oscar/aim.h Mon Dec 08 05:41:04 2003 +0000 @@ -283,9 +283,9 @@ #define AIM_CONN_TYPE_BOS 0x0002 #define AIM_CONN_TYPE_ADS 0x0005 #define AIM_CONN_TYPE_AUTH 0x0007 -#define AIM_CONN_TYPE_CHATNAV 0x000d +#define AIM_CONN_TYPE_CHATNAV 0x000d #define AIM_CONN_TYPE_CHAT 0x000e -#define AIM_CONN_TYPE_SEARCH 0x000f +#define AIM_CONN_TYPE_SEARCH 0x000f #define AIM_CONN_TYPE_ICON 0x0010 #define AIM_CONN_TYPE_EMAIL 0x0018 @@ -300,7 +300,7 @@ #define AIM_CONN_SUBTYPE_OFT_GETFILE 0x0002 #define AIM_CONN_SUBTYPE_OFT_SENDFILE 0x0003 #define AIM_CONN_SUBTYPE_OFT_BUDDYICON 0x0004 -#define AIM_CONN_SUBTYPE_OFT_VOICE 0x0005 +#define AIM_CONN_SUBTYPE_OFT_VOICE 0x0005 /* * Status values returned from aim_conn_new(). ORed together. @@ -354,19 +354,18 @@ fu8_t hdrtype; /* defines which piece of the union to use */ union { struct { - fu8_t type; + fu8_t channel; flap_seqnum_t seqnum; } flap; struct { - fu8_t magic[4]; /* ODC2 or OFT2 */ + fu8_t magic[4]; /* ODC2 or OFT2 */ fu16_t hdrlen; fu16_t type; } rend; } hdr; - aim_bstream_t data; /* payload stream */ - fu8_t handled; /* 0 = new, !0 = been handled */ - fu8_t nofree; /* 0 = free data on purge, 1 = only unlink */ - aim_conn_t *conn; /* the connection it came in on... */ + aim_bstream_t data; /* payload stream */ + aim_conn_t *conn; /* the connection it came in on/is going out on */ + fu8_t handled; /* 0 = new, !0 = been handled */ struct aim_frame_s *next; } aim_frame_t; @@ -472,18 +471,18 @@ } aim_session_t; /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */ -#define AIM_ICQ_STATE_NORMAL 0x00000000 -#define AIM_ICQ_STATE_AWAY 0x00000001 -#define AIM_ICQ_STATE_DND 0x00000002 -#define AIM_ICQ_STATE_OUT 0x00000004 -#define AIM_ICQ_STATE_BUSY 0x00000010 -#define AIM_ICQ_STATE_CHAT 0x00000020 -#define AIM_ICQ_STATE_INVISIBLE 0x00000100 -#define AIM_ICQ_STATE_WEBAWARE 0x00010000 -#define AIM_ICQ_STATE_HIDEIP 0x00020000 -#define AIM_ICQ_STATE_BIRTHDAY 0x00080000 +#define AIM_ICQ_STATE_NORMAL 0x00000000 +#define AIM_ICQ_STATE_AWAY 0x00000001 +#define AIM_ICQ_STATE_DND 0x00000002 +#define AIM_ICQ_STATE_OUT 0x00000004 +#define AIM_ICQ_STATE_BUSY 0x00000010 +#define AIM_ICQ_STATE_CHAT 0x00000020 +#define AIM_ICQ_STATE_INVISIBLE 0x00000100 +#define AIM_ICQ_STATE_WEBAWARE 0x00010000 +#define AIM_ICQ_STATE_HIDEIP 0x00020000 +#define AIM_ICQ_STATE_BIRTHDAY 0x00080000 #define AIM_ICQ_STATE_DIRECTDISABLED 0x00100000 -#define AIM_ICQ_STATE_ICQHOMEPAGE 0x00200000 +#define AIM_ICQ_STATE_ICQHOMEPAGE 0x00200000 #define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000 #define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000 diff -r 5f0bb52c0609 -r c86f075b269a src/protocols/oscar/aim_internal.h --- a/src/protocols/oscar/aim_internal.h Mon Dec 08 04:58:07 2003 +0000 +++ b/src/protocols/oscar/aim_internal.h Mon Dec 08 05:41:04 2003 +0000 @@ -110,12 +110,9 @@ /* txqueue.c */ faim_internal aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, fu8_t framing, fu16_t chan, int datalen); faim_internal int aim_tx_enqueue(aim_session_t *, aim_frame_t *); -faim_internal flap_seqnum_t aim_get_next_txseqnum(aim_conn_t *); faim_internal int aim_tx_sendframe(aim_session_t *sess, aim_frame_t *cur); faim_internal void aim_tx_cleanqueue(aim_session_t *, aim_conn_t *); -/* XXX - What is this? faim_internal int aim_tx_printqueue(aim_session_t *); */ - /* * Generic SNAC structure. Rarely if ever used. */ diff -r 5f0bb52c0609 -r c86f075b269a src/protocols/oscar/rxhandlers.c --- a/src/protocols/oscar/rxhandlers.c Mon Dec 08 04:58:07 2003 +0000 +++ b/src/protocols/oscar/rxhandlers.c Mon Dec 08 05:41:04 2003 +0000 @@ -370,21 +370,21 @@ maxf = sizeof(literals) / sizeof(literals[0]); maxs = sizeof(literals[0]) / sizeof(literals[0][0]); - if (frame->hdr.flap.type == 0x02) { + if (frame->hdr.flap.channel == 0x02) { family = aimbs_get16(&frame->data); subtype = aimbs_get16(&frame->data); if ((family < maxf) && (subtype+1 < maxs) && (literals[family][subtype] != NULL)) - faimdprintf(sess, 0, "bleck: channel %s: null handler for %04x/%04x (%s)\n", channels[frame->hdr.flap.type], family, subtype, literals[family][subtype+1]); + faimdprintf(sess, 0, "bleck: channel %s: null handler for %04x/%04x (%s)\n", channels[frame->hdr.flap.channel], family, subtype, literals[family][subtype+1]); else - faimdprintf(sess, 0, "bleck: channel %s: null handler for %04x/%04x (no literal)\n", channels[frame->hdr.flap.type], family, subtype); + faimdprintf(sess, 0, "bleck: channel %s: null handler for %04x/%04x (no literal)\n", channels[frame->hdr.flap.channel], family, subtype); } else { - if (frame->hdr.flap.type <= maxchannels) - faimdprintf(sess, 0, "bleck: channel %s (0x%02x)\n", channels[frame->hdr.flap.type], frame->hdr.flap.type); + if (frame->hdr.flap.channel <= maxchannels) + faimdprintf(sess, 0, "bleck: channel %s (0x%02x)\n", channels[frame->hdr.flap.channel], frame->hdr.flap.channel); else - faimdprintf(sess, 0, "bleck: unknown channel 0x%02x\n", frame->hdr.flap.type); + faimdprintf(sess, 0, "bleck: unknown channel 0x%02x\n", frame->hdr.flap.channel); } @@ -517,19 +517,19 @@ continue; if (cur->hdrtype == AIM_FRAMETYPE_FLAP) { - if (cur->hdr.flap.type == 0x01) { + if (cur->hdr.flap.channel == 0x01) { cur->handled = aim_callhandler_noparam(sess, cur->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, cur); /* XXX use consumenonsnac */ continue; - } else if (cur->hdr.flap.type == 0x02) { + } else if (cur->hdr.flap.channel == 0x02) { if ((cur->handled = consumesnac(sess, cur))) continue; - } else if (cur->hdr.flap.type == 0x04) { + } else if (cur->hdr.flap.channel == 0x04) { cur->handled = negchan_middle(sess, cur); continue; - } else if (cur->hdr.flap.type == 0x05) { + } else if (cur->hdr.flap.channel == 0x05) { } diff -r 5f0bb52c0609 -r c86f075b269a src/protocols/oscar/rxqueue.c --- a/src/protocols/oscar/rxqueue.c Mon Dec 08 04:58:07 2003 +0000 +++ b/src/protocols/oscar/rxqueue.c Mon Dec 08 05:41:04 2003 +0000 @@ -64,11 +64,10 @@ } /** - * aim_frame_destroy - free aim_frame_t - * @frame: the frame to free + * Free an aim_frame_t * - * returns -1 on error; 0 on success. - * + * @param frame The frame to free. + * @return -1 on error; 0 on success. */ faim_internal void aim_frame_destroy(aim_frame_t *frame) { @@ -80,88 +79,94 @@ } /* - * Read a FLAP header from conn into fr, and return the number of bytes in the payload. + * Read a FLAP header from conn into fr, and return the number of + * bytes in the payload. + * + * @return -1 on error, otherwise return the length of the payload. */ static int aim_get_command_flap(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *fr) { - fu8_t flaphdr_raw[6]; - aim_bstream_t flaphdr; - fu16_t payloadlen; + fu8_t hdr_raw[6]; + aim_bstream_t hdr; - aim_bstream_init(&flaphdr, flaphdr_raw, sizeof(flaphdr_raw)); + fr->hdrtype = AIM_FRAMETYPE_FLAP; /* - * Read FLAP header. Six bytes: - * 0 char -- Always 0x2a - * 1 char -- Channel ID. Usually 2 -- 1 and 4 are used during login. - * 2 short -- Sequence number - * 4 short -- Number of data bytes that follow. + * Read FLAP header. Six bytes total. + * + * Byte # | Description + * -------|------------- + * 0x00 | Always 0x2a + * 0x01 | Channel number, usually "2." "1" is used during login, + * | 4 is used during logoff. + * 0x02 | Sequence number, 2 bytes. + * 0x04 | Number of data bytes that follow, 2 bytes. */ - if (aim_bstream_recv(&flaphdr, conn->fd, 6) < 6) { + aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); + if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) { aim_conn_close(conn); return -1; } - aim_bstream_rewind(&flaphdr); + aim_bstream_rewind(&hdr); /* * This shouldn't happen unless the socket breaks, the server breaks, * or we break. We must handle it just in case. */ - if (aimbs_get8(&flaphdr) != 0x2a) { - fu8_t start; - - aim_bstream_rewind(&flaphdr); - start = aimbs_get8(&flaphdr); - faimdprintf(sess, 0, "FLAP framing disrupted (0x%02x)", start); + if (aimbs_get8(&hdr) != 0x2a) { + faimdprintf(sess, 0, "Invalid FLAP frame received on FLAP connection!"); aim_conn_close(conn); return -1; } - /* we're doing FLAP if we're here */ - fr->hdrtype = AIM_FRAMETYPE_FLAP; + fr->hdr.flap.channel = aimbs_get8(&hdr); + fr->hdr.flap.seqnum = aimbs_get16(&hdr); - fr->hdr.flap.type = aimbs_get8(&flaphdr); - fr->hdr.flap.seqnum = aimbs_get16(&flaphdr); - payloadlen = aimbs_get16(&flaphdr); /* length of payload */ - - return payloadlen; + return aimbs_get16(&hdr); } /* - * Read a rendezvous header from conn into fr, and return the number of bytes in the payload. + * Read a rendezvous header from conn into fr, and return the number of + * bytes in the payload. + * + * @return -1 on error, otherwise return the length of the payload. */ static int aim_get_command_rendezvous(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *fr) { - fu8_t rendhdr_raw[8]; - aim_bstream_t rendhdr; + fu8_t hdr_raw[8]; + aim_bstream_t hdr; + + fr->hdrtype = AIM_FRAMETYPE_OFT; - aim_bstream_init(&rendhdr, rendhdr_raw, sizeof(rendhdr_raw)); - - if (aim_bstream_recv(&rendhdr, conn->fd, 8) < 8) { + /* + * Read rendezvous header + */ + aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); + if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) { aim_conn_close(conn); return -1; } - aim_bstream_rewind(&rendhdr); - - fr->hdrtype = AIM_FRAMETYPE_OFT; /* a misnomer--rendezvous */ + aim_bstream_rewind(&hdr); - aimbs_getrawbuf(&rendhdr, fr->hdr.rend.magic, 4); - fr->hdr.rend.hdrlen = aimbs_get16(&rendhdr) - 8; - fr->hdr.rend.type = aimbs_get16(&rendhdr); + aimbs_getrawbuf(&hdr, fr->hdr.rend.magic, 4); + fr->hdr.rend.hdrlen = aimbs_get16(&hdr); + fr->hdr.rend.type = aimbs_get16(&hdr); - return fr->hdr.rend.hdrlen; + return fr->hdr.rend.hdrlen - 8; } /* * Grab a single command sequence off the socket, and enqueue it in the incoming event queue * in a separate struct. + * + * @return 0 on success, otherwise return the error number. */ faim_export int aim_get_command(aim_session_t *sess, aim_conn_t *conn) { - aim_frame_t *newrx; - fu16_t payloadlen; + aim_frame_t *fr; + int payloadlen; if (!sess || !conn) return -EINVAL; @@ -175,81 +180,67 @@ if (conn->status & AIM_CONN_STATUS_INPROGRESS) return aim_conn_completeconnect(sess, conn); - if (!(newrx = (aim_frame_t *)calloc(sizeof(aim_frame_t), 1))) + if (!(fr = (aim_frame_t *)calloc(sizeof(aim_frame_t), 1))) return -ENOMEM; /* * Rendezvous (client to client) connections do not speak FLAP, so this * function will break on them. */ - if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { - int ret = aim_get_command_rendezvous(sess, conn, newrx); + if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) + payloadlen = aim_get_command_rendezvous(sess, conn, fr); + else if (conn->type == AIM_CONN_TYPE_LISTENER) { + faimdprintf(sess, 0, "AIM_CONN_TYPE_LISTENER on fd %d\n", conn->fd); + free(fr); + return -1; + } else + payloadlen = aim_get_command_flap(sess, conn, fr); - if (ret < 0) { - free(newrx); + if (payloadlen < 0) { + free(fr); + return -1; + } + + if (payloadlen > 0) { + fu8_t *payload = NULL; + + if (!(payload = (fu8_t *) malloc(payloadlen))) { + aim_frame_destroy(fr); return -1; } - payloadlen = ret; - } else if (conn->type == AIM_CONN_TYPE_LISTENER) { - faimdprintf(sess, 0, "AIM_CONN_TYPE_LISTENER on fd %d\n", conn->fd); - free(newrx); - return -1; - } else - payloadlen = aim_get_command_flap(sess, conn, newrx); - - newrx->nofree = 0; /* free by default */ - - if (payloadlen) { - fu8_t *payload = NULL; - - if (!(payload = (fu8_t *) malloc(payloadlen))) { - aim_frame_destroy(newrx); - return -1; - } - - aim_bstream_init(&newrx->data, payload, payloadlen); + aim_bstream_init(&fr->data, payload, payloadlen); /* read the payload */ - if (aim_bstream_recv(&newrx->data, conn->fd, payloadlen) < payloadlen) { - aim_frame_destroy(newrx); /* free's payload */ + if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) { + aim_frame_destroy(fr); /* free's payload */ aim_conn_close(conn); return -1; } } else - aim_bstream_init(&newrx->data, NULL, 0); + aim_bstream_init(&fr->data, NULL, 0); - - aim_bstream_rewind(&newrx->data); + aim_bstream_rewind(&fr->data); - newrx->conn = conn; + fr->conn = conn; - newrx->next = NULL; /* this will always be at the bottom */ - - if (!sess->queue_incoming) - sess->queue_incoming = newrx; + /* Enqueue this puppy */ + fr->next = NULL; /* this will always be at the bottom */ + if (sess->queue_incoming == NULL) + sess->queue_incoming = fr; else { aim_frame_t *cur; - - for (cur = sess->queue_incoming; cur->next; cur = cur->next) - ; - cur->next = newrx; + for (cur = sess->queue_incoming; cur->next; cur = cur->next); + cur->next = fr; } - newrx->conn->lastactivity = time(NULL); + fr->conn->lastactivity = time(NULL); return 0; } /* - * Purge recieve queue of all handled commands (->handled==1). Also - * allows for selective freeing using ->nofree so that the client can - * keep the data for various purposes. - * - * If ->nofree is nonzero, the frame will be delinked from the global list, - * but will not be free'ed. The client _must_ keep a pointer to the - * data -- libfaim will not! If the client marks ->nofree but - * does not keep a pointer, it's lost forever. + * Purge recieve queue of all handled commands (->handled==1). * */ faim_export void aim_purge_rxqueue(aim_session_t *sess) @@ -258,12 +249,8 @@ for (prev = &sess->queue_incoming; (cur = *prev); ) { if (cur->handled) { - *prev = cur->next; - - if (!cur->nofree) - aim_frame_destroy(cur); - + aim_frame_destroy(cur); } else prev = &cur->next; } @@ -286,5 +273,6 @@ if ((!currx->handled) && (currx->conn == conn)) currx->handled = 1; } + return; } diff -r 5f0bb52c0609 -r c86f075b269a src/protocols/oscar/txqueue.c --- a/src/protocols/oscar/txqueue.c Mon Dec 08 04:58:07 2003 +0000 +++ b/src/protocols/oscar/txqueue.c Mon Dec 08 05:41:04 2003 +0000 @@ -30,8 +30,8 @@ { aim_frame_t *fr; - if (!conn) { - faimdprintf(sess, 0, "aim_tx_new: ERROR: no connection specified\n"); + if (!sess || !conn) { + faimdprintf(sess, 0, "aim_tx_new: No session or no connection specified!\n"); return NULL; } @@ -48,23 +48,16 @@ } } - if (!(fr = (aim_frame_t *)malloc(sizeof(aim_frame_t)))) + if (!(fr = (aim_frame_t *)calloc(1, sizeof(aim_frame_t)))) return NULL; - memset(fr, 0, sizeof(aim_frame_t)); fr->conn = conn; - fr->hdrtype = framing; - - if (fr->hdrtype == AIM_FRAMETYPE_FLAP) { - - fr->hdr.flap.type = chan; - - } else if (fr->hdrtype == AIM_FRAMETYPE_OFT) { - + if (fr->hdrtype == AIM_FRAMETYPE_FLAP) + fr->hdr.flap.channel = chan; + else if (fr->hdrtype == AIM_FRAMETYPE_OFT) fr->hdr.rend.type = chan; - - } else + else faimdprintf(sess, 0, "tx_new: unknown framing\n"); if (datalen > 0) { @@ -81,9 +74,22 @@ return fr; } +/* + * This increments the tx command count, and returns the seqnum + * that should be stamped on the next FLAP packet sent. This is + * normally called during the final step of packet preparation + * before enqueuement (in aim_tx_enqueue()). + */ +static flap_seqnum_t aim_get_next_txseqnum(aim_conn_t *conn) +{ + flap_seqnum_t ret; + + ret = ++conn->seqnum; + + return ret; +} + /* - * aim_tx_enqeue__queuebased() - * * The overall purpose here is to enqueue the passed in command struct * into the outgoing (tx) queue. Basically... * 1) Make a scope-irrelevent copy of the struct @@ -115,9 +121,7 @@ sess->queue_outgoing = fr; else { aim_frame_t *cur; - - for (cur = sess->queue_outgoing; cur->next; cur = cur->next) - ; + for (cur = sess->queue_outgoing; cur->next; cur = cur->next); cur->next = fr; } @@ -125,8 +129,6 @@ } /* - * aim_tx_enqueue__immediate() - * * Parallel to aim_tx_enqueue__queuebased, however, this bypasses * the whole queue mess when you want immediate writes to happen. * @@ -177,7 +179,7 @@ { /* - * If we want to send a connection thats inprogress, we have to force + * If we want to send on a connection that is inprogress, we have to force * them to use the queue based version. Otherwise, use whatever they * want. */ @@ -189,24 +191,6 @@ return (*sess->tx_enqueue)(sess, fr); } -/* - * aim_get_next_txseqnum() - * - * This increments the tx command count, and returns the seqnum - * that should be stamped on the next FLAP packet sent. This is - * normally called during the final step of packet preparation - * before enqueuement (in aim_tx_enqueue()). - * - */ -faim_internal flap_seqnum_t aim_get_next_txseqnum(aim_conn_t *conn) -{ - flap_seqnum_t ret; - - ret = ++conn->seqnum; - - return ret; -} - static int aim_send(int fd, const void *buf, size_t count) { int left, cur; @@ -215,6 +199,7 @@ int ret; ret = send(fd, ((unsigned char *)buf)+cur, left, 0); + if (ret == -1) return -1; else if (ret == 0) @@ -230,45 +215,38 @@ static int aim_bstream_send(aim_bstream_t *bs, aim_conn_t *conn, size_t count) { int wrote = 0; + if (!bs || !conn || (count < 0)) return -EINVAL; + /* Make sure we don't send paste the end of the bs */ if (count > aim_bstream_empty(bs)) count = aim_bstream_empty(bs); /* truncate to remaining space */ if (count) { + /* + * If we're sending a large direct IM (maybe it contains an + * image or something), then we want to break it up into chunks + * of 1024 and update the UI between sending each one. This is + * kind of ugly. Ideally, if the client wants to send a large + * amount of data it should just write to the fd directly--we're + * not multithreaded and this is just a stop-gap thingy. + */ if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) && (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) { - /* I strongly suspect that this is a horrible thing to do - * and I feel really guilty doing it. */ const char *sn = aim_odc_getsn(conn); aim_rxcallback_t userfunc; + while (count - wrote > 1024) { wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, 1024); - if ((userfunc=aim_callhandler(conn->sessv, conn, - AIM_CB_FAM_SPECIAL, - AIM_CB_SPECIAL_IMAGETRANSFER))) - userfunc(conn->sessv, NULL, sn, - count-wrote>1024 ? ((double)wrote / count) : 1); + if ((userfunc=aim_callhandler(conn->sessv, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER))) + userfunc(conn->sessv, NULL, sn, count-wrote>1024 ? ((double)wrote / count) : 1); } } + if (count - wrote) { wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, count - wrote); } - - } - - if (((aim_session_t *)conn->sessv)->debug >= 2) { - int i; - aim_session_t *sess = (aim_session_t *)conn->sessv; - - faimdprintf(sess, 2, "\nOutgoing data: (%d bytes)", wrote); - for (i = 0; i < wrote; i++) { - if (!(i % 8)) - faimdprintf(sess, 2, "\n\t"); - faimdprintf(sess, 2, "0x%02x ", *(bs->data + bs->offset + i)); - } - faimdprintf(sess, 2, "\n"); } bs->offset += wrote; @@ -278,33 +256,33 @@ static int sendframe_flap(aim_session_t *sess, aim_frame_t *fr) { - aim_bstream_t obs; - fu8_t *obs_raw; - int payloadlen, err = 0, obslen; + aim_bstream_t bs; + fu8_t *bs_raw; + int payloadlen, err = 0, bslen; payloadlen = aim_bstream_curpos(&fr->data); - if (!(obs_raw = malloc(6 + payloadlen))) + if (!(bs_raw = malloc(6 + payloadlen))) return -ENOMEM; - aim_bstream_init(&obs, obs_raw, 6 + payloadlen); + aim_bstream_init(&bs, bs_raw, 6 + payloadlen); /* FLAP header */ - aimbs_put8(&obs, 0x2a); - aimbs_put8(&obs, fr->hdr.flap.type); - aimbs_put16(&obs, fr->hdr.flap.seqnum); - aimbs_put16(&obs, payloadlen); + aimbs_put8(&bs, 0x2a); + aimbs_put8(&bs, fr->hdr.flap.channel); + aimbs_put16(&bs, fr->hdr.flap.seqnum); + aimbs_put16(&bs, payloadlen); /* payload */ aim_bstream_rewind(&fr->data); - aimbs_putbs(&obs, &fr->data, payloadlen); + aimbs_putbs(&bs, &fr->data, payloadlen); - obslen = aim_bstream_curpos(&obs); - aim_bstream_rewind(&obs); - if (aim_bstream_send(&obs, fr->conn, obslen) != obslen) + bslen = aim_bstream_curpos(&bs); + aim_bstream_rewind(&bs); + if (aim_bstream_send(&bs, fr->conn, bslen) != bslen) err = -errno; - free(obs_raw); /* XXX aim_bstream_free */ + free(bs_raw); /* XXX aim_bstream_free */ fr->handled = 1; fr->conn->lastactivity = time(NULL); @@ -316,25 +294,27 @@ { aim_bstream_t bs; fu8_t *bs_raw; - int err = 0; - int totlen = 8 + aim_bstream_curpos(&fr->data); + int payloadlen, err = 0, bslen; + + payloadlen = aim_bstream_curpos(&fr->data); - if (!(bs_raw = malloc(totlen))) - return -1; + if (!(bs_raw = malloc(8 + payloadlen))) + return -ENOMEM; - aim_bstream_init(&bs, bs_raw, totlen); + aim_bstream_init(&bs, bs_raw, 8 + payloadlen); + /* Rendezvous header */ aimbs_putraw(&bs, fr->hdr.rend.magic, 4); - aimbs_put16(&bs, 8 + fr->hdr.rend.hdrlen); + aimbs_put16(&bs, fr->hdr.rend.hdrlen); aimbs_put16(&bs, fr->hdr.rend.type); /* payload */ aim_bstream_rewind(&fr->data); - aimbs_putbs(&bs, &fr->data, totlen - 8); + aimbs_putbs(&bs, &fr->data, payloadlen); + bslen = aim_bstream_curpos(&bs); aim_bstream_rewind(&bs); - - if (aim_bstream_send(&bs, fr->conn, totlen) != totlen) + if (aim_bstream_send(&bs, fr->conn, bslen) != bslen) err = -errno; free(bs_raw); /* XXX aim_bstream_free */ @@ -351,6 +331,7 @@ return sendframe_flap(sess, fr); else if (fr->hdrtype == AIM_FRAMETYPE_OFT) return sendframe_rendezvous(sess, fr); + return -1; } @@ -392,24 +373,18 @@ } /* - * aim_tx_purgequeue() - * * This is responsable for removing sent commands from the transmit * queue. This is not a required operation, but it of course helps * reduce memory footprint at run time! - * */ faim_export void aim_tx_purgequeue(aim_session_t *sess) { aim_frame_t *cur, **prev; for (prev = &sess->queue_outgoing; (cur = *prev); ) { - if (cur->handled) { *prev = cur->next; - aim_frame_destroy(cur); - } else prev = &cur->next; } @@ -418,13 +393,12 @@ } /** - * aim_tx_cleanqueue - get rid of packets waiting for tx on a dying conn - * @sess: session - * @conn: connection that's dying + * Get rid of packets waiting for tx on a dying conn. For now this + * simply marks all packets as sent and lets them disappear without + * warning. * - * for now this simply marks all packets as sent and lets them - * disappear without warning. - * + * @param sess A session. + * @param conn Connection that's dying. */ faim_internal void aim_tx_cleanqueue(aim_session_t *sess, aim_conn_t *conn) {